PolyhedralDev / Terra

Voxel world generation modding platform
MIT License
642 stars 85 forks source link

Reduce pipeline v2 caching #401

Closed Astrashh closed 1 year ago

Astrashh commented 1 year ago

Pull Request

Brief description.

Reduces the amount of cached pipeline chunks from 1024 to 64, and reduces the target size of chunks from 500 to 128. This represents an approximate reduction from a 16k x 16k block area to a more sensible 1024 x 1024 block area per pipeline provider loaded by the server.

What Issues Does This Fix?

Fixes excessive memory usage, reported by @ccorp2002 on discord.

Licensing

Types of changes

Compatiblity

Contribution Guidelines.

Documentation

Testing

solonovamax commented 1 year ago

has it been measured what the original memory usage was from this, and how much this causes it to decrease by?

Also, this should be a config option

Astrashh commented 1 year ago

From C_Corp's report on discord, there was ~12gb worth of PipelineBiome[] instances, with a decrease down to 9gb by simply reducing cache size by some amount (not sure what exactly he decreased it by) - usage will vary by how many packs are installed but it probably shouldn't be that high.

Wasn't too scientific with picking numbers, just figured a lower default would be better for now, then revisit it if and or when it becomes an issue (unlikely it will be until more packs that use pipeline v2 such as OW2 are more prevalent), or memory usage is critically examined. Cache size could probably even be smaller, cache hits I believe only tend to happen in a fairly local area, a larger cache would still be somewhat beneficial for the speed of /locate I would think but this would need to be profiled.

Already opened #402 regarding it being a config option.

solonovamax commented 1 year ago

yeah, this definitely needs to be profiled further & cache hits/misses need to be recorded to see how large we should try and make it for optimal performance/memory tradeoff