Eliminate transient objects for looking up symbol by bytelist#5512
Merged
headius merged 1 commit intojruby:masterfrom Dec 13, 2018
Merged
Eliminate transient objects for looking up symbol by bytelist#5512headius merged 1 commit intojruby:masterfrom
headius merged 1 commit intojruby:masterfrom
Conversation
The old logic constructed an intermediate java.lang.String and called hashCode, which in turn created an ISO8859_1 decoder and buffers to do the decoding. This showed up in heap profiles of the state_machine library, but would generically affect any case where a Ruby String was used to retrieve a Ruby Symbol. The logic here should match what an ISO8859_1 Java String would do. The accompanying tests makes sure this is so.
kares
approved these changes
Dec 13, 2018
Member
kares
left a comment
There was a problem hiding this comment.
+1 ... guess String hashCode is standardized
guaranteed to be the same across JVMs, since otherwise case(str) byte-code would break
Member
Author
|
@kares Yes, Java's String hashcode calculation is set in stone (i.e. in the spec). |
enebo
approved these changes
Dec 13, 2018
Member
Author
|
Good improvement from this...here's before and after: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The old logic constructed an intermediate java.lang.String and
called hashCode, which in turn created an ISO8859_1 decoder and
buffers to do the decoding. This showed up in heap profiles of the
state_machine library, but would generically affect any case where
a Ruby String was used to retrieve a Ruby Symbol.
The logic here should match what an ISO8859_1 Java String would
do. The accompanying tests makes sure this is so.
For the profiled run in question, the only ISO8859_1 decoders in the process were created by the old logic: