Repository navigation
Conversation
| @Nullable | ||
| static byte[] pack(NBTTagCompound tag) { | ||
| try { | ||
| ByteArrayOutputStream raw = new ByteArrayOutputStream(4096); |
Collaborator
There was a problem hiding this comment.
If you use CCNBTUtils.getTagSizeEstimate you can avoid over-allocating the buffer for small tags. 4096 is basically nothing, but the jvm has to do a memset 0 on arrays so their allocation cost increases with size. getTagSizeEstimate avoids buffer reallocations too.
Eventually I'd like to use netty's pooling in a lot of places, or have a byte[] / int[] / long[] cache, because these arrays are 99% of CC's allocations.
Contributor
Author
|
changed it to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current CubeIO's cube and column caches keep the NBT of every saved and preloaded cube as objects: up to 30,000 entries, and up to 60,000 while entries are younger than 120s.
In a test run on a nearly empty world,one player flying 1,500 blocks and back causes the current cube cache to reach 60,086 entries. Heap after GC stayed 300–500 MiB higher than with this PR.
This PR replaces both caches with one
IOCacheper kind:flush()/close(): wait until every save has been written, also after write failures.New config option:
optimizations.saveCacheMegabytes. The default is 32 MiB per cubic dimension for cubes; columns get an eighth on top. 0 keeps only the pending saves. Using LZ4 compression, 32MiB can hold about 40.000 cubesThe first commit makes each dimension write its saves one batch at a time, in the order they were made. On master, two background threads could write batches of the same dimension at once, so an older save of a cube could reach the disk after a newer one and overwrite it. The old cache kept returning the newer data for up to 120 s, which hid this until a restart. Reads, world generation and other dimensions still run in parallel.
This is also preparation for 2x2x2 cube bundles in #139: pending saves are tracked per position and written in order, so a later change can hold them briefly and write whole bundles.