question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance differences in working with Heap vs DirectByteBuffer-backed ImmutableRB

See original GitHub issue

I’m getting a ~2-4x performance drop when working with HeapByteBuffer backed ImmutableRoaringBitmaps compared to ones backed by a DirectByteBuffer. It seems unlikely for me that this can be only attributed to different performance of the ByteBuffer implementations (but I can see myself being wrong here!).

@lemire are you aware of this performance characteristic?

Running:

  • JMH1.13
  • JDK 1.8.0_101, VM 25.101-b13
  • MacBookProc 15’ Late 2013, Intel® Core™ i7-4960HQ CPU @ 2.60GHz, 16GiB
.
  • OSX 10.11.6
Benchmark                            (bufferType)           (dataset)  Mode  Cnt    Score   Error  Units
BackingBufferBenchmark.intersectAll          heap  wikileaks-noquotes  avgt   20   13.648 ± 0.100  us/op
BackingBufferBenchmark.intersectAll        direct  wikileaks-noquotes  avgt   20    6.250 ± 0.047  us/op
BackingBufferBenchmark.intersectAll          heap     weather_sept_85  avgt   20  108.748 ± 1.671  us/op
BackingBufferBenchmark.intersectAll        direct     weather_sept_85  avgt   20   39.418 ± 0.373  us/op
BackingBufferBenchmark.intersectAll          heap       dimension_033  avgt   20  422.748 ± 5.789  us/op
BackingBufferBenchmark.intersectAll        direct       dimension_033  avgt   20  102.691 ± 0.859  us/op
BackingBufferBenchmark.intersectAll          heap       census-income  avgt   20   24.322 ± 0.277  us/op
BackingBufferBenchmark.intersectAll        direct       census-income  avgt   20    7.409 ± 0.072  us/op
BackingBufferBenchmark.intersectAll          heap        uscensus2000  avgt   20    2.980 ± 0.024  us/op
BackingBufferBenchmark.intersectAll        direct        uscensus2000  avgt   20    3.064 ± 0.028  us/op

The benchmark code can be found here.

One thing I’ve noticed looking at code of RoaringBitmaps is that BufferUtil.isBackedBySimpleArray is used in a couple of places to branch to two different code paths depending on the backing buffer type. Do both code paths have similar performance?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
maciejcommented, Jul 28, 2016

@lemire absolutely! It’s my bad that I haven’t notice the fact that Roaring uses through the “buffer” branch whenever a HeapByteBuffer is passed. And clearly 4x perf drop makes sense then! Thank you for your help on that one!

I’m closing it.

0reactions
lemirecommented, Jul 27, 2016

@maciej Let me know if you agree with my answer. If so, I will close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Which memory is faster Heap or ByteBuffer or Direct ?
In this blog i will share my experiment with different types of memory allocation that can be done in java and what type...
Read more >
ByteBuffer (Java Platform SE 8 ) - Oracle Help Center
A byte buffer. This class defines six categories of operations upon byte buffers: Absolute and relative get and put methods that read and...
Read more >
Direct java.nio.ByteBuffer vs Java Array Performance Test
I wanted to compare performance of a direct byte buffer (java.nio.ByteBuffer, off-heap) and a heap buffer (achieved via array) for both read ...
Read more >
Compact Off-Heap Structures/Tuples In Java
So one method of managing structures is to fake them within a ByteBuffer as a reasonable approach. This can allow compact data representations, ......
Read more >
Difference between Direct, Non Direct and Mapped ByteBuffer ...
It was introduced in java.nio package on JDK 1.4, it not only allows you to operate on heap byte arrays but also with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found