{"id":103,"date":"2016-04-02T10:06:13","date_gmt":"2016-04-02T10:06:13","guid":{"rendered":"http:\/\/blog.qubekwest.com\/?p=103"},"modified":"2017-01-22T11:59:46","modified_gmt":"2017-01-22T11:59:46","slug":"rearranged-world","status":"publish","type":"post","link":"https:\/\/blog.qubekwest.com\/?p=103","title":{"rendered":"Rearranged World"},"content":{"rendered":"<p>The\u00a0original layout of the geometry for QubeKwest was simply blocks in 16x16x16 block chunks in the world. \u00a0This was designed to accommodate bulk network transmissions. \u00a0After all, sending 4,096 blocks in a neat little package is a good deal more efficient than sending them one at a time. \u00a0At the moment, that means that a chunk is around 65 KB of data. \u00a0As I was working on the idea of how to store chunks in permanent storage on the server, I got to thinking about how obnoxious it would be to have vast numbers of 65 KB chunks all over the disk.<\/p>\n<p>Instead of making an artificial storage construct for chunks on the disk drive, I got to thinking about how to best manage it and came up with an honest to goodness layer of physical space that can be used directly. \u00a0This may end up being handy for generation of the world as well since it gives a slightly more impressive physical space into which I can easily render advanced features. \u00a0The idea is that above chunks, we now have clusters. \u00a0These hold 8x8x8 chunks (512 chunks total) and are designed to be the way of storing the world on a hard disk. \u00a0These presently average something near 26 MB each in their uncompressed form, but they will likely be stored as compressed gzip streams so the world doesn&#8217;t take over your whole drive after 20 seconds of exploring.<\/p>\n<p>These clusters are also designed to be a semi-sparse structure. \u00a0In other words, they have a hard list of 512 Chunks in them, but those chunks are allowed to be &#8220;EmptyChunk&#8221; objects instead of real ones. \u00a0This type of chunk takes approximately 4 bytes instead of 50,000. \u00a0After all, if there are parts of the cluster that haven&#8217;t been generated yet, then there is no need to store massive amounts of block data that is just waiting to be replaced by the generator later on. \u00a0This is especially likely in the vast depths of the underground. \u00a0If you haven&#8217;t dug down close to it, it really doesn&#8217;t need to have been generated yet. \u00a0If it hasn&#8217;t been generated yet, don&#8217;t waste the hard drive space yet either.<\/p>\n<p>There were a few different trade offs on the sizing of a cluster before I settled on 8x8x8 chunks. \u00a0My first theory was 16x16x16 chunks in a cluster (after all I&#8217;d already done the math for storing 16x16x16 blocks in a chunk), but I soon realized that would mean way too much memory to load them off the disk to make them active on the server. \u00a0After that, I briefly toyed with the idea of getting rid of clusters altogether. \u00a0In the end, I decided they would still be useful to prevent the need for obscene numbers of individual chunk files.<\/p>\n<p>Consider for a moment a world that is a small\u00a0128x128x32 blocks. \u00a0If it was nice and flat and you were running at 6m\/s it would still take you over 20 seconds to walk end to end of this tiny world. \u00a0If I got rid of the cluster concept, that volume of world data would be stored in 128\u00a0files. \u00a0With an 8x8x8 chunk cluster, that world fits neatly into a single file with loads of room to spare for more vertical exploring. \u00a0This is much friendlier to the storage system on the server, especially as the worlds get larger.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The\u00a0original layout of the geometry for QubeKwest was simply blocks in 16x16x16 block chunks in the world. \u00a0This was designed to accommodate bulk network transmissions. \u00a0After all, sending 4,096 blocks in a neat little package is a good deal more efficient than sending them one at a time. \u00a0At the moment, that means that a &hellip; <a href=\"https:\/\/blog.qubekwest.com\/?p=103\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Rearranged World<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=103"}],"version-history":[{"count":5,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions"}],"predecessor-version":[{"id":203,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions\/203"}],"wp:attachment":[{"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qubekwest.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}