Re: RFR: 8259947: (fs) Optimize UnixPath.encode implementation [v2]
On Tue, 19 Jan 2021 12:02:13 GMT, Claes Redestad wrote: >> This patch improves `UnixPath.encode` by reusing `JLA.getBytesNoRepl` (which >> has fast-paths for common encoding) and avoiding a `toCharArray` call on the >> input by refactoring the `normalizeNativePath` code to operate on `String`. >> This might have a cost on files on Mac that need additional native >> normalization. >> >> This removes another `ThreadLocal` and a source of `SoftReference`s. >> Together with the UTF-8 fast-path my UTF-8 encoded file system see >> substantial speed-ups in a trivial `new File(str).toPath()` microbenchmark. > > Claes Redestad has updated the pull request incrementally with one additional > commit since the last revision: > > Fold ToPath into FileOpen, add root benchmarks to keep mix comparable src/java.base/unix/classes/sun/nio/fs/UnixPath.java line 112: > 110: private static final jdk.internal.access.JavaLangAccess JLA = > 111: jdk.internal.access.SharedSecrets.getJavaLangAccess(); > 112: Can you move this to the top, before the instance fields? Also let's import the jdk.internal.acces classes rather than using fully qualified names. That will keep it consistent with the existing code in this area. - PR: https://git.openjdk.java.net/jdk/pull/2135
Re: RFR: 8259947: (fs) Optimize UnixPath.encode implementation [v2]
On Tue, 19 Jan 2021 12:02:13 GMT, Claes Redestad wrote: >> This patch improves `UnixPath.encode` by reusing `JLA.getBytesNoRepl` (which >> has fast-paths for common encoding) and avoiding a `toCharArray` call on the >> input by refactoring the `normalizeNativePath` code to operate on `String`. >> This might have a cost on files on Mac that need additional native >> normalization. >> >> This removes another `ThreadLocal` and a source of `SoftReference`s. >> Together with the UTF-8 fast-path my UTF-8 encoded file system see >> substantial speed-ups in a trivial `new File(str).toPath()` microbenchmark. > > Claes Redestad has updated the pull request incrementally with one additional > commit since the last revision: > > Fold ToPath into FileOpen, add root benchmarks to keep mix comparable src/java.base/unix/classes/sun/nio/fs/UnixPath.java line 118: > 116: try { > 117: return JLA.getBytesNoRepl(input, Util.jnuEncoding()); > 118: } catch (CharacterCodingException cce) { The encode method pre-dates JLA.getBytesNoRepl and the recent optimisations so this is a good cleanup. - PR: https://git.openjdk.java.net/jdk/pull/2135
Re: RFR: 8259947: (fs) Optimize UnixPath.encode implementation [v2]
> This patch improves `UnixPath.encode` by reusing `JLA.getBytesNoRepl` (which > has fast-paths for common encoding) and avoiding a `toCharArray` call on the > input by refactoring the `normalizeNativePath` code to operate on `String`. > This might have a cost on files on Mac that need additional native > normalization. > > This removes another `ThreadLocal` and a source of `SoftReference`s. Together > with the UTF-8 fast-path my UTF-8 encoded file system see substantial > speed-ups in a trivial `new File(str).toPath()` microbenchmark. Claes Redestad has updated the pull request incrementally with one additional commit since the last revision: Fold ToPath into FileOpen, add root benchmarks to keep mix comparable - Changes: - all: https://git.openjdk.java.net/jdk/pull/2135/files - new: https://git.openjdk.java.net/jdk/pull/2135/files/27a55ee0..18c3105b Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=2135=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk=2135=00-01 Stats: 128 lines in 2 files changed: 50 ins; 72 del; 6 mod Patch: https://git.openjdk.java.net/jdk/pull/2135.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/2135/head:pull/2135 PR: https://git.openjdk.java.net/jdk/pull/2135