Description
By design changes to a content tree get written to a segment using a depth-first traversal. As a consequence the top-down access pattern used for reading content ends up parsing the content from the end to the beginning. This is somewhat troublesome as many memory and disk caches are optimized for the opposite direction of access.
To better leverage cache prefetching features (like readahead in Linux), it would be useful to reverse the order in which segments get written. In other words, instead of filling the segment buffer from the beginning to the end as the depth-first traversal proceeds, we could fill the buffer from the end to the beginning and count segment offsets from the end of a segment instead of its beginning.
While at it, it might also make sense to align record offsets at four or eight byte boundaries to further (micro-)optimize access. It might also be worth it to reduce the segment size limit to something like 512kB so we could squeeze record references down from four to three bytes.