-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8259947: (fs) Optimize UnixPath.encode implementation #2135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…caching - use FileOpen as a baseline
|
Microbenchmark results, baseline: Target: |
|
👋 Welcome back redestad! A progress list of the required criteria for merging this PR into |
Webrevs
|
ChrisHegarty
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this looks good ( I had a similar thought when looking through this code recently, for a separate issue ).
|
@cl4es This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
| public void mix(Blackhole bh) { | ||
| bh.consume(new File(normalFile).toPath()); | ||
| bh.consume(new File(trailingSlash).toPath()); | ||
| bh.consume(new File(root).toPath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No singular test for new File(root), but here it is in the mix anyway? What would probably be not comparable.
| input = fs.normalizeNativePath(input); | ||
| try { | ||
| return JLA.getBytesNoRepl(input, Util.jnuEncoding()); | ||
| } catch (CharacterCodingException cce) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The encode method pre-dates JLA.getBytesNoRepl and the recent optimisations so this is a good cleanup.
| @BenchmarkMode(Mode.AverageTime) | ||
| @OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
| @State(Scope.Thread) | ||
| @Warmup(time=2, iterations=5) | ||
| @Measurement(time=3, iterations=5) | ||
| @Fork(value=2, jvmArgs="-Xmx1g") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this can be inherited from the enclosing benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's only @State that doesn't inherit.
| @Warmup(time=2, iterations=5) | ||
| @Measurement(time=3, iterations=5) | ||
| @Fork(value=2, jvmArgs="-Xmx1g") | ||
| public static class ToPath { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really have to nest this test? It seems to gain nothing per se: the annotations and fields are still pretty much duplicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, no. Nesting was to pre-emptively decouple the micros, but it makes sense to squash them into one for now.
|
/integrate |
|
@cl4es Since your change was applied there have been 2 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 5891509. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This patch improves
UnixPath.encodeby reusingJLA.getBytesNoRepl(which has fast-paths for common encoding) and avoiding atoCharArraycall on the input by refactoring thenormalizeNativePathcode to operate onString. This might have a cost on files on Mac that need additional native normalization.This removes another
ThreadLocaland a source ofSoftReferences. Together with the UTF-8 fast-path my UTF-8 encoded file system see substantial speed-ups in a trivialnew File(str).toPath()microbenchmark.Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2135/head:pull/2135$ git checkout pull/2135