On Mon, 25 Jul 2022 06:40:49 GMT, Сергей Цыпанов <d...@openjdk.org> wrote:
>> We can use `InputStream.readAllBytes()` in `ModuleHashes` and `X509CertPath`. > > Сергей Цыпанов has updated the pull request incrementally with one additional > commit since the last revision: > > 8278461: Revert X509CertPath I've measured this with benchmark @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Fork(jvmArgsAppend = {"-Xms1g", "-Xmx1g"}) public class HashBenchmark { private final Path path = Path.of("/Users/stsypanov/Library/Java/JavaVirtualMachines/openjdk-18.0.2/Contents/Home/jmods"); private final ModuleFinder finder = ModulePath.of(Runtime.version(), true, path); @Benchmark public byte[] hash() throws Exception { return hash(finder, "java.base"); } private byte[] hash(ModuleFinder finder, String name) throws Exception { ModuleReference mref = finder.find(name).orElseThrow(RuntimeException::new); try (ModuleReader reader = mref.open()) { return ModuleHashes.computeHash(reader, "SHA-256"); } } } and indeed the change makes things slower: baseline Benchmark Mode Cnt Score Error Units HashBenchmark.hash avgt 50 174,632 ± 5,581 ms/op HashBenchmark.hash:·gc.alloc.rate avgt 50 165,848 ± 4,574 MB/sec HashBenchmark.hash:·gc.alloc.rate.norm avgt 50 31773902,052 ± 24870,662 B/op HashBenchmark.hash:·gc.churn.G1_Eden_Space avgt 50 166,357 ± 9,399 MB/sec HashBenchmark.hash:·gc.churn.G1_Eden_Space.norm avgt 50 31891221,589 ± 1725370,956 B/op HashBenchmark.hash:·gc.churn.G1_Old_Gen avgt 50 5,553 ± 0,327 MB/sec HashBenchmark.hash:·gc.churn.G1_Old_Gen.norm avgt 50 1064354,875 ± 60435,285 B/op HashBenchmark.hash:·gc.churn.G1_Survivor_Space avgt 50 0,034 ± 0,032 MB/sec HashBenchmark.hash:·gc.churn.G1_Survivor_Space.norm avgt 50 6754,365 ± 6398,008 B/op HashBenchmark.hash:·gc.count avgt 50 144,000 counts HashBenchmark.hash:·gc.time avgt 50 249,000 ms patched Benchmark Mode Cnt Score Error Units HashBenchmark.hash avgt 50 192,068 ± 8,236 ms/op HashBenchmark.hash:·gc.alloc.rate avgt 50 568,790 ± 22,912 MB/sec HashBenchmark.hash:·gc.alloc.rate.norm avgt 50 119441637,758 ± 28476,724 B/op HashBenchmark.hash:·gc.churn.G1_Eden_Space avgt 50 568,892 ± 26,936 MB/sec HashBenchmark.hash:·gc.churn.G1_Eden_Space.norm avgt 50 119444622,067 ± 2746230,425 B/op HashBenchmark.hash:·gc.churn.G1_Old_Gen avgt 50 4,964 ± 0,238 MB/sec HashBenchmark.hash:·gc.churn.G1_Old_Gen.norm avgt 50 1042019,563 ± 23557,187 B/op HashBenchmark.hash:·gc.churn.G1_Survivor_Space avgt 50 0,043 ± 0,033 MB/sec HashBenchmark.hash:·gc.churn.G1_Survivor_Space.norm avgt 50 9130,656 ± 7040,858 B/op HashBenchmark.hash:·gc.count avgt 50 492,000 counts HashBenchmark.hash:·gc.time avgt 50 738,000 ms I'll close this PR then. ------------- PR: https://git.openjdk.org/jdk/pull/9596