Implement jar directory snapshot caching.#1546
Merged
enebo merged 2 commits intojruby:jruby-1_7from Mar 12, 2014
Merged
Conversation
Contributor
Author
|
I've updated the PR to make sure that caching respects modification time and added a test to verify it. This didn't really affect runtime for my stuff.jar test: Please review/merge. :) |
Contributor
Author
|
Seems like the break is due to jruby-1_7 being broken. |
added 2 commits
March 12, 2014 13:24
This improves jar globbing performance by about 4x on a simple benchmark.
For a jar containing 9156 files, 5.times { Dir.glob("file.jar!/**/*") } is:
1.7.10: user 1m24.332s
HEAD: user 0m19.604s
enebo
added a commit
that referenced
this pull request
Mar 12, 2014
Implement jar directory snapshot caching.
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.
Currently, when we try to load a jar resource, we go through all the jar entries to figure out if there are any that match the directory information. When doing globbing or Dir.entries it also currently scans the jar again.
This PR optimizes this by creating a static JarCache reference that caches information about loaded jars, including representation of the directory structure. The inform1.7.10: user 1m24.332s
HEAD: user 0m19.604sation is stored in a WeakHashMap which should allow it to be garbage collected. Benchmarking on a jar containing files from jruby.git/core (just over 9000 files) shows about 4x improvement:
Results for 1.7.10: 1m24.332s
Results for HEAD: 0m19.604s
I have considered doing a per Ruby runtime cache, but that would require resources to have a reference to a Runtime and caching cross-runtime jar contents is also probably okay.