That’s a lot of voxels

A typical Minecraft world, which is made of voxels, is 128 blocks high and 2048 blocks wide and deep, for a total volume of 536,870,912 blocks. We’ll call it 500 million. So now that we have LLM’s like Claude, we can get some advice on how to build bigger worlds, which I did. I asked Claude about using a filesystem based “database” to store worlds as big as 10,000×10,000×10,000 which is a trillion (10^12) blocks.

Claude agreed with me that traditional RDBMS won’t work for that. Claude also pointed out that it’s not typical to store a trillion files on a filesystem. However, for a 3D world with a trillion blocks, we could store 30 million files, each of which was 32x32x32. The math is:

10^12/32^3 = 30,517,578.125. About 30 million files.

As long as they’re in directories, it could work. FreeBSD UFS can store 32,767 files per directory or we could just use ZFS which can store 2^48 (281 trillion) files per directory. Linux ext4 can store roughly 10 million files per directory.

I asked Claude for a POC which it created in rust in about 8 minutes.

So, after a couple hours additional work and learning I now have kBlockDB.

  • Capable of storing 1 trillion voxels, perhaps more.
  • Each voxel can have an arbitrary number of key-value pairs. The keys are strings, and the values are string, float, int64 or boolean.
  • Arbitrary dimensions. Typically we think of a 3-dimensional world, however if we wanted to think about layers we could imagine 4 dimensions. KBlockDB supports any number of dimensions.
  • A query language
  • There is a write-through cache to speed performance
  • kBlockDB has an RESTful interface, and a custom binary interface which is about 50% faster

On my Macbook, the performance numbers are “ok”. 2500-3000 write operations per second and about 10,000 read operations per second over HTTP.

Next steps could include

  • I’d like to explore the idea of custom indices to enable fast querying
  • Synchronization of kBlockDB databases across hosts, with appropriate version management.
  • Potential implementation of compression to save space
  • There is support for username and password login, but I’ll likely add LDAP support.

Similar Posts

  • Reading Paradox Files

    Back in the day, Paradox was a pretty amazing database.  I recently had a reason to read some Paradox files for a friend, who had a client with a Paradox database.  They needed their data out of the database to insert into something more modern. Googling for the file format of a Paradox DB didn’t…

  • |

    Embedding Jasper

    Jasper is the JSP compiler inside Tomcat. For reasons, mainly of curiosity, I wanted to build a Pragmatach plugin which exposes Jasper.  Pragmatach supports some template engines such as FreeMarker, ThymeLeaf and Velocity, but I thought Jasper would be a good addition. I chose to use Tomcat 6, mainly because Tomcat 7 uses Servlet 3.0.  Pragmatach…

  • Parsing HTML

    I’ve been interested in HTML parsing for a while now.  There are a number of reasons to do this, such as: Validating that what claims to be HTML, is HTML Finding every style sheet and script in an HTML file Pretty-printing Syntax highlighting Linting Translating between markup languages, for example generating JSPs from PHP, or…

  • Building a simple RIAK ORM

    I’ve been interested in RIAK for a while, and ORM’s are nothing short of fascinating. I decided to try writing an ORM for Riak, and the results are here: https://github.com/teverett/cbean My ORM is not an ORM of course, because RIAK is not relational. However it is ORM-like; I can store POJO’s and retrieve them. The…

  • phpGrammar

    I’ve recently becoming interested in porting legacy PHP sites to JSPs.   It seemed to me that one of the hardest parts of this problem was parsing the PHP code.  Once a parse tree was created, the next step would be to emit equivalent JSP code. I went looking for an ANTL4 grammar for PHP,…

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.