From serb at openjdk.java.net Fri Jan 14 12:21:55 2022 From: serb at openjdk.java.net (Sergey Bylokhov) Date: Fri, 14 Jan 2022 12:21:55 GMT Subject: jmx-dev RFR: 8280010: Remove double buffering of InputStream for Properties.load In-Reply-To: References: Message-ID: On Mon, 10 Jan 2022 20:46:36 GMT, Andrey Turbanov wrote: > `Properties.load` uses `java.util.Properties.LineReader`. LineReader already buffers input stream. Hence wrapping InputStream in BufferedInputStream is redundant. The code change looks fine, but can you please check the actual performance impact, will the perf be the same after the change? ------------- PR: https://git.openjdk.java.net/jdk/pull/7021 From duke at openjdk.java.net Fri Jan 14 12:21:54 2022 From: duke at openjdk.java.net (Andrey Turbanov) Date: Fri, 14 Jan 2022 12:21:54 GMT Subject: jmx-dev RFR: 8280010: Remove double buffering of InputStream for Properties.load Message-ID: `Properties.load` uses `java.util.Properties.LineReader`. LineReader already buffers input stream. Hence wrapping InputStream in BufferedInputStream is redundant. ------------- Commit messages: - [PATCH] Remove double buffering of InputStream for Properties.load - [PATCH] Remove double buffering of InputStream for Properties.load Changes: https://git.openjdk.java.net/jdk/pull/7021/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7021&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8280010 Stats: 30 lines in 8 files changed: 0 ins; 11 del; 19 mod Patch: https://git.openjdk.java.net/jdk/pull/7021.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/7021/head:pull/7021 PR: https://git.openjdk.java.net/jdk/pull/7021 From duke at openjdk.java.net Fri Jan 14 12:21:56 2022 From: duke at openjdk.java.net (Andrey Turbanov) Date: Fri, 14 Jan 2022 12:21:56 GMT Subject: jmx-dev RFR: 8280010: Remove double buffering of InputStream for Properties.load In-Reply-To: References: Message-ID: On Mon, 10 Jan 2022 20:46:36 GMT, Andrey Turbanov wrote: > `Properties.load` uses `java.util.Properties.LineReader`. LineReader already buffers input stream. Hence wrapping InputStream in BufferedInputStream is redundant. Checked. `BufferedInputStream` add a bit of overhead. Benchmark @BenchmarkMode(value = Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 6, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @State(Scope.Benchmark) public class PropertiesLoad { Properties properties; private InputStream arrayInputStream; private InputStream fileInputStream; private Path filePath; @Setup public void setupStrings() throws IOException { properties = new Properties(); String content = """ currentVersion=IdealGraphVisualizer {0} LBL_splash_window_title=Starting IdealGraphVisualizer SPLASH_WIDTH=475 SplashProgressBarBounds=0,273,475,6 SplashProgressBarColor=0xFFFFFF SplashRunningTextBounds=10,283,460,12 SplashRunningTextColor=0xFFFFFF """; filePath = Files.createTempFile("benchmark", ".properties"); Files.writeString(filePath, content); arrayInputStream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); fileInputStream = Files.newInputStream(filePath); } @TearDown public void tearDown() throws IOException { fileInputStream.close(); Files.delete(filePath); } @Benchmark public Properties plain_ByteStream() throws IOException { properties.load(arrayInputStream); return properties; } @Benchmark public Properties plain_fileStream() throws IOException { properties.load(fileInputStream); return properties; } @Benchmark public Properties buffered_ByteStream() throws IOException { properties.load(new BufferedInputStream(arrayInputStream)); return properties; } @Benchmark public Properties buffered_fileStream() throws IOException { properties.load(new BufferedInputStream(fileInputStream)); return properties; } public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(PropertiesLoad.class.getSimpleName()) .build(); new Runner(opt).run(); } } Results: Benchmark Mode Cnt Score Error Units PropertiesLoad.buffered_ByteStream avgt 5 2416,364 ? 46,209 ns/op PropertiesLoad.buffered_fileStream avgt 5 4276,015 ? 139,094 ns/op PropertiesLoad.plain_ByteStream avgt 5 1445,864 ? 649,779 ns/op PropertiesLoad.plain_fileStream avgt 5 3183,012 ? 198,974 ns/op ------------- PR: https://git.openjdk.java.net/jdk/pull/7021 From amenkov at openjdk.java.net Fri Jan 14 13:15:22 2022 From: amenkov at openjdk.java.net (Alex Menkov) Date: Fri, 14 Jan 2022 13:15:22 GMT Subject: jmx-dev RFR: 8280010: Remove double buffering of InputStream for Properties.load In-Reply-To: References: Message-ID: On Mon, 10 Jan 2022 20:46:36 GMT, Andrey Turbanov wrote: > `Properties.load` uses `java.util.Properties.LineReader`. LineReader already buffers input stream. Hence wrapping InputStream in BufferedInputStream is redundant. Marked as reviewed by amenkov (Reviewer). ------------- PR: https://git.openjdk.java.net/jdk/pull/7021 From dfuchs at openjdk.java.net Fri Jan 14 14:51:23 2022 From: dfuchs at openjdk.java.net (Daniel Fuchs) Date: Fri, 14 Jan 2022 14:51:23 GMT Subject: jmx-dev RFR: 8280010: Remove double buffering of InputStream for Properties.load In-Reply-To: References: Message-ID: On Mon, 10 Jan 2022 20:46:36 GMT, Andrey Turbanov wrote: > `Properties.load` uses `java.util.Properties.LineReader`. LineReader already buffers input stream. Hence wrapping InputStream in BufferedInputStream is redundant. Changes to `java.util.logging` look fine. ------------- PR: https://git.openjdk.java.net/jdk/pull/7021 From sspitsyn at openjdk.java.net Fri Jan 14 17:59:29 2022 From: sspitsyn at openjdk.java.net (Serguei Spitsyn) Date: Fri, 14 Jan 2022 17:59:29 GMT Subject: jmx-dev RFR: 8280010: Remove double buffering of InputStream for Properties.load In-Reply-To: References: Message-ID: On Mon, 10 Jan 2022 20:46:36 GMT, Andrey Turbanov wrote: > `Properties.load` uses `java.util.Properties.LineReader`. LineReader already buffers input stream. Hence wrapping InputStream in BufferedInputStream is redundant. Marked as reviewed by sspitsyn (Reviewer). ------------- PR: https://git.openjdk.java.net/jdk/pull/7021 From serb at openjdk.java.net Sat Jan 15 02:32:32 2022 From: serb at openjdk.java.net (Sergey Bylokhov) Date: Sat, 15 Jan 2022 02:32:32 GMT Subject: jmx-dev RFR: 8280010: Remove double buffering of InputStream for Properties.load In-Reply-To: References: Message-ID: On Mon, 10 Jan 2022 20:46:36 GMT, Andrey Turbanov wrote: > `Properties.load` uses `java.util.Properties.LineReader`. LineReader already buffers input stream. Hence wrapping InputStream in BufferedInputStream is redundant. Marked as reviewed by serb (Reviewer). ------------- PR: https://git.openjdk.java.net/jdk/pull/7021 From aturbanov at openjdk.java.net Tue Jan 18 15:52:31 2022 From: aturbanov at openjdk.java.net (Andrey Turbanov) Date: Tue, 18 Jan 2022 15:52:31 GMT Subject: jmx-dev Integrated: 8280010: Remove double buffering of InputStream for Properties.load In-Reply-To: References: Message-ID: On Mon, 10 Jan 2022 20:46:36 GMT, Andrey Turbanov wrote: > `Properties.load` uses `java.util.Properties.LineReader`. LineReader already buffers input stream. Hence wrapping InputStream in BufferedInputStream is redundant. This pull request has now been integrated. Changeset: 9eb50a5e Author: Andrey Turbanov URL: https://git.openjdk.java.net/jdk/commit/9eb50a5ee4a069fbb248748ebee09132e2450420 Stats: 30 lines in 8 files changed: 0 ins; 11 del; 19 mod 8280010: Remove double buffering of InputStream for Properties.load Reviewed-by: amenkov, sspitsyn, serb ------------- PR: https://git.openjdk.java.net/jdk/pull/7021