Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding transitionStore optimization back to ByteState #90

Merged
merged 1 commit into from
May 1, 2023

Conversation

jonessha
Copy link
Contributor

Description of changes:

I removed transitionStore in favor of ByteMap when adding wildcard matching.

transitionStore was an Object that could be null if 0 transitions were present, a simple object if 1 transition was present, or a Map if 2 transitions were present. I had replaced this with the new class ByteMap, which greatly simplified the code. However, it is not as memory efficient to always allocate a ByteMap. Hence, I am re-introducing transitionStore, which again, can be null, a simple object, or a ByteMap (for 2+ transitions). The downside of this is it does bloat the code quite a bit.

Through some crude testing, I expect this to replace nearly 50% of ByteMaps with the simple object SingleByteTransitionEntry. In this case (1 transition), my back-of-the-napkin math suggests ByteMap would require 96 bytes and SingleByteTransitionEntry would require 8 bytes, a 12x difference. So this is, on average, a 44 bytes saving for each ByteState.

I have run this in a high volume production environment and have observed a modest improvement in GC activity (maybe a 10% reduction).


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@baldawar baldawar merged commit e942dc6 into main May 1, 2023
2 checks passed
@jonessha jonessha deleted the transition_store_optimization branch May 1, 2023 16:49
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.

None yet

2 participants