BlueMap

BlueMap

85.1k Downloads

Convert to using Mutable Vectors [Performance/RAM]

TBlueF opened this issue ยท 4 comments

commented

Background

BlueMap uses (since always) the immutable vectors from com.flowpowered to process all block-models and generate the map-tile-models. During rendering it will use and calculate with those vectors a lot! Since vectors are immutable, this means that each time a block or face or model is created/moved/scaled/rotated, it creates at least one, often multiple, new vector-instances.

This raises multiple problems:

  • Creating a new instance in Java is one of the slower operations, as it needs to allocate new space in memory to put the new object.
  • Each time a vector is mutated, since it creates a new instance, the old vector-instance will still block that memory until Java's Garbage-Collector finds and removes it. A lot of vector instances mean a lot of work for the Garbage-Collector which again costs performance.
  • If BlueMap is rendering too fast, e.g. by using a lot of render-threads, it can happen that the Garbage-Collector is not fast enough and can't keep up with finding and clearing all those vector-instances. Resulting in a OutOfMemoryError and a crash.

Solution

The planned solution for this is refactoring the render-code to not use those immutable vectors and work as close to primitive-variables as possible.
This would hopefully remove all the problems above, resulting in a big performance improvement, using way less RAM during rendering and getting rid of those OutOfMemoryError's :)

commented

This has been implemented in 1.6.0 and 1.6.1.

commented

This would hopefully remove all the problems above, resulting in a big performance improvement, using way less RAM during rendering and getting rid of those OutOfMemoryError's :)

That would be amazing. I am currently having to restart the server every now and then, because it crashes due to being out of memory (which is strange, as the Minecraft server has 16gb of memory and when I ran a identical render on my Windows machine with 12gb, it worked like a charm. Big modpack and all.)

I'm slowly getting the initial render done, it's just a bit time consuming and tedious finishing the first, initial, fullrender.

Seeing performance improvements would be a heaven sent.

commented

Tried setting it to -2,-4,-6,-8,-10, but no change between those. OOM everytime after about 8 minues.
It's alrighty, though. Fullrender got finished eventually and now everything seems to be stable.

commented

@Griefed reducing your renderThreads in the core.conf helps a lot against the OOM's already :)