Conversation
Port the single byte COW heuristic from the 1.8 code path to 1.9. This fixes jruby#168.
Member
|
Great find, btw! Thank you! |
This pull request was closed.
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.
Had a peek at #168 and determined the problem is indeed a pathological copy-on-write case: the 1.9 code path was missing a heuristic that the 1.8 code uses around not sharing for single character substrings. For 1.9, each read of a character in bench_threaded_reverse.rb was marking the (very long) source string shared, causing an expensive copy of it for each character written in the bench. Lots of extra work.
This pull ports that heuristic to the 1.9 case, taking into account that the string is probably non-ascii encoded.
My before numbers looks very similar to the ones @headius posted in #168. Here are the after numbers on my machine:
Natural questions would be "Is this optimization too localized to the benchmark?" and "How do we know this doesn't degrade performance elsewhere". Here are my thoughts:
Hopefully I haven't missed anything here... let me know if there's any questions!