Skip to content

Conversation

@mkeskells
Copy link
Contributor

SUMMARY

  • Describe your changes, including rationale and design decisions
    Remove the allocations in the lookup path (other than the ContainerAndIndex, which would be removed by removing the HighLowContainer and is subject of a separate discussion)
    These were byte array allocations to represent a key path, which is specified as a long to the API anyway

In my tests (not checked in this PR) this reduces the CPU usage on thread by 23% (and GC overhead on other threads

Automated Checks

  • I have run ./gradlew test and made sure that my PR does not break any unit test.

Discussion

  • IMHO there seem to be still too much time taken in private LeafNode findByKey(Node node, long key) looking at the profiler, but didn't want to change the API too much in this simple PR, so added some comments
  • I made an arbitrary choice to represent the key in the upper 48 bits of the key passed to findByKey. There doesn't seem to be a 'standard' for this. - some usages are in the high 48 bits, and some are in the low 48 bits (e.g. LeafNode.getKey). Happy to change if there is a direction

// common prefix is the same ,then increase the depth
depth += branchNodePrefixLength;
}
//TODO - expose an API that avoids this double dipping
Copy link
Contributor Author

@mkeskells mkeskells Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exposing this additional API (and associated initial implementation) further reduces CPU by 13% on my tests, but thought it would be better to discuss in a separate PR, but happy to include if preferred

@lemire
Copy link
Member

lemire commented Aug 17, 2025

This looks fine to me, please consider my suggestion (optional).

@mkeskells mkeskells force-pushed the remove-allocations-lookup branch from f828ea2 to 6aa9546 Compare August 17, 2025 23:29
…ls.java

Co-authored-by: Daniel Lemire <daniel@lemire.me>
@mkeskells
Copy link
Contributor Author

This looks fine to me, please consider my suggestion (optional).

taken

@mkeskells mkeskells merged commit 0054a40 into RoaringBitmap:master Aug 18, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants