PERFORMANCE: Intern Multiple String Constants#4754
Closed
original-brownbear wants to merge 1 commit intojruby:masterfrom
Closed
PERFORMANCE: Intern Multiple String Constants#4754original-brownbear wants to merge 1 commit intojruby:masterfrom
original-brownbear wants to merge 1 commit intojruby:masterfrom
Conversation
Contributor
Author
|
this is not ready, closing until fixed ... |
Member
|
@original-brownbear also check out symbol_love which is a branch which will be eliminating any String's from existing. Everything will be RubySymbol and we will have backwards compat signatures for people interacting via Java. That branch is not a sure thing for the future but j.l.String needs to go since it limits our compatibility with non-Java-charset encodings. |
Contributor
Author
|
@enebo thanks will take a look :) |
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.
JRuby
interns mostStrings that come up in Ruby code just fine inorg.jruby.ir.persistence.IRReaderStream#decodeString:, but a few duplicates from more dynamic contexts are not caught. In the red-black benchmark, this adds up to ~200kb of wasted memory (memory wise this is irrelevant obviously, but duplicates make call site cache lookups slower and waste CPU cache => fixing all these spots resulted in a visible ~2% speedup in the red-black benchmark for me over very large sample sizes 2k+ runs).
So I:
ASTish code pathsinternbyinterning in constructors wherever possible instead of further upstreaminterncalls made it into the hot path by checking that the method isn't called in the hot path (checked red-black benchmark and Logstash after warm up andinternwas never called in either => I have a bit of confidence)Also:
public synchronized void defineAliases(List<String> aliases, String oldName)since it was one of the cases that looked like they would create duplicateStringconstants but then realized that it's never used (checked for dynamic invocations too)public static JavaCallable getMatchingCallable(Ruby runtime, Class<?> javaClass, String methodName, Class<?>[] argumentTypes)since this method was in a path affected by the addedinterncalls and only usedprivately=> I didn't want to add redundant calls tointernto it, when I can be sure that its only callerinternsStrings just fine already