Adding transitionStore optimization back to ByteState #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.