SwayDB icon indicating copy to clipboard operation
SwayDB copied to clipboard

Creating Off-heap bytes and objects

Open simerplaha opened this issue 4 years ago • 3 comments

Having the ability to directly allocate objects and byte-arrays off heap would be a major improvement.

If cacheSegmentBlocksOnCreate is disabled then compaction bytes can be discarded immediately skipping the JVMs GC. The same also applies to objects created during compaction.

JDK-16 has Foreign-Memory Access API but this is still far away and we need to support Java8.

simerplaha avatar Nov 06 '20 02:11 simerplaha

Foreign-memory access API although in incubation is actually a well tested API since Java 14. Another option is to use sun.misc.Unsafe if Java 8 builds are important for us.

After running some tests the overall database performance would triple if moved off-heap for all byte arrays. On a very heavy & concurrent write and read workload a little over 60% of total data sitting on heap is byte[]. Moving all Slice[Byte] off-heap would be a major performance advantage.

simerplaha avatar Oct 18 '21 16:10 simerplaha

Are you testing with J8 (which is EOL in 4 months) or J11 ? The J11 heap is MUCH better

dabayliss avatar Nov 08 '21 20:11 dabayliss

Are you testing with J8 (which is EOL in 4 months) or J11?

J8 up until now. I didn't know about the EOL. Thanks for letting me know.

The J11 heap is MUCH better

You are right, seems like J11's heap has improved. I will run some tests on J11 soon.

simerplaha avatar Nov 09 '21 05:11 simerplaha