You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2021/01/06 16:23:18 UTC

[GitHub] [commons-io] XenoAmess opened a new pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

XenoAmess opened a new pull request #184:
URL: https://github.com/apache/commons-io/pull/184


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r554592963



##########
File path: src/test/java/org/apache/commons/io/performance/IOUtilsContentEqualsPerformanceTest.java
##########
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.performance;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.buffer.UnsynchronizedBufferedInputStream;
+import org.apache.commons.io.input.buffer.UnsynchronizedBufferedReader;
+import org.apache.commons.lang3.StringUtils;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+/**
+ * Test to show whether using BitSet for removeAll() methods is faster than using HashSet.
+ */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@State(Scope.Thread)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.SECONDS)
+@Fork(value = 1, jvmArgs = {"-server"})
+public class IOUtilsContentEqualsPerformanceTest {
+    static String[] STRINGS = new String[1];
+
+    static {
+        STRINGS[0] = StringUtils.repeat("ab", 1 << 24);
+    }
+
+    @Benchmark
+    public void testBufferedInputStream(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)
+        ) {
+            while (true) {
+                int nowI = bufferedInputStream.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedInputStream(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                UnsynchronizedBufferedInputStream bufferedInputStream = new UnsynchronizedBufferedInputStream(inputStream)
+        ) {
+            while (true) {
+                int nowI = bufferedInputStream.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testBufferedReader(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                BufferedReader bufferedReader = new BufferedReader(inputReader)
+        ) {
+            while (true) {
+                int nowI = bufferedReader.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedReader(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                UnsynchronizedBufferedReader bufferedReader = new UnsynchronizedBufferedReader(inputReader)
+        ) {
+            while (true) {
+                int nowI = bufferedReader.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    @Benchmark
+    public void testBufferedInputStream2(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)
+        ) {
+            byte[] bytes = new byte[1];
+            while (true) {
+                int nowI = bufferedInputStream.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedInputStream2(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                UnsynchronizedBufferedInputStream bufferedInputStream = new UnsynchronizedBufferedInputStream(inputStream)
+        ) {
+            byte[] bytes = new byte[1];
+            while (true) {
+                int nowI = bufferedInputStream.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testBufferedReader2(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                BufferedReader bufferedReader = new BufferedReader(inputReader)
+        ) {
+            char[] bytes = new char[1];
+            while (true) {
+                int nowI = bufferedReader.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedReader2(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                UnsynchronizedBufferedReader bufferedReader = new UnsynchronizedBufferedReader(inputReader)
+        ) {
+            char[] bytes = new char[1];
+            while (true) {
+                int nowI = bufferedReader.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+}

Review comment:
       @garydgregory done.

##########
File path: src/test/java/org/apache/commons/io/performance/IOUtilsContentEqualsPerformanceTest.java
##########
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.performance;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.buffer.UnsynchronizedBufferedInputStream;
+import org.apache.commons.io.input.buffer.UnsynchronizedBufferedReader;
+import org.apache.commons.lang3.StringUtils;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+/**
+ * Test to show whether using BitSet for removeAll() methods is faster than using HashSet.
+ */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@State(Scope.Thread)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.SECONDS)
+@Fork(value = 1, jvmArgs = {"-server"})
+public class IOUtilsContentEqualsPerformanceTest {
+    static String[] STRINGS = new String[1];
+
+    static {
+        STRINGS[0] = StringUtils.repeat("ab", 1 << 24);
+    }
+
+    @Benchmark
+    public void testBufferedInputStream(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)
+        ) {
+            while (true) {
+                int nowI = bufferedInputStream.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedInputStream(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                UnsynchronizedBufferedInputStream bufferedInputStream = new UnsynchronizedBufferedInputStream(inputStream)
+        ) {
+            while (true) {
+                int nowI = bufferedInputStream.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testBufferedReader(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                BufferedReader bufferedReader = new BufferedReader(inputReader)
+        ) {
+            while (true) {
+                int nowI = bufferedReader.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedReader(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                UnsynchronizedBufferedReader bufferedReader = new UnsynchronizedBufferedReader(inputReader)
+        ) {
+            while (true) {
+                int nowI = bufferedReader.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    @Benchmark
+    public void testBufferedInputStream2(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)
+        ) {
+            byte[] bytes = new byte[1];
+            while (true) {
+                int nowI = bufferedInputStream.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedInputStream2(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                UnsynchronizedBufferedInputStream bufferedInputStream = new UnsynchronizedBufferedInputStream(inputStream)
+        ) {
+            byte[] bytes = new byte[1];
+            while (true) {
+                int nowI = bufferedInputStream.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testBufferedReader2(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                BufferedReader bufferedReader = new BufferedReader(inputReader)
+        ) {
+            char[] bytes = new char[1];
+            while (true) {
+                int nowI = bufferedReader.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedReader2(Blackhole blackhole) throws IOException {

Review comment:
       @garydgregory done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757512557


   @garydgregory rerun performance tests:
   https://pastebin.ubuntu.com/p/njnG5x78fD/


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r552939257



##########
File path: pom.xml
##########
@@ -469,5 +482,44 @@ file comparators, endian transformation classes, and much more.
         <coveralls.skip>true</coveralls.skip>
       </properties>
     </profile>
+    <profile>
+      <id>benchmark</id>
+      <properties>
+        <skipTests>true</skipTests>
+        <benchmark>org.apache</benchmark>
+      </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>1.6.0</version>

Review comment:
       Why did you pick a seemingly random old version? Why not 3.0.0, which is the current version?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] coveralls edited a comment on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757499669


   
   [![Coverage Status](https://coveralls.io/builds/36213096/badge)](https://coveralls.io/builds/36213096)
   
   Coverage increased (+0.02%) to 88.764% when pulling **56fd776bff4f088734c896b057878dff01e05465 on xenoamess-fork:add_unsynchronized_input_stream** into **4b92e65963105eedf469ace591ae0b84aa1c3afc on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r554590597



##########
File path: src/main/java/org/apache/commons/io/input/buffer/UnsynchronizedBufferedInputStream.java
##########
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input.buffer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.apache.commons.io.IOUtils;
+import static org.apache.commons.io.IOUtils.EOF;
+
+/**
+ * A BufferedReader class who does not care about thread safety, but very much faster.
+ *
+ * Should be able to replace java.io.BufferedReader in nearly every use-cases when you
+ * need the Reader be buffered, but do not need it have thread safety.
+ */
+public class UnsynchronizedBufferedInputStream extends InputStream {
+    private final InputStream inputStream;
+    private final byte[] byteBuffer;
+
+    private int nowIndex = 0;

Review comment:
       @garydgregory done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] coveralls edited a comment on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757499669


   
   [![Coverage Status](https://coveralls.io/builds/36213538/badge)](https://coveralls.io/builds/36213538)
   
   Coverage decreased (-0.001%) to 88.742% when pulling **36749e7e9438881dafc40699540275c99a0809db on xenoamess-fork:add_unsynchronized_input_stream** into **4b92e65963105eedf469ace591ae0b84aa1c3afc on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r554584513



##########
File path: pom.xml
##########
@@ -300,6 +312,7 @@ file comparators, endian transformation classes, and much more.
     <commons.release.isDistModule>true</commons.release.isDistModule>
     <commons.releaseManagerName>Gary Gregory</commons.releaseManagerName>    
     <commons.releaseManagerKey>86fdc7e2a11262cb</commons.releaseManagerKey>
+    <jmh.version>1.21</jmh.version>

Review comment:
       @garydgregory when I add this into pom(in the former pr), there be only 1.21. this pr has been delayed for too long lol. will update now.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r552938903



##########
File path: pom.xml
##########
@@ -300,6 +312,7 @@ file comparators, endian transformation classes, and much more.
     <commons.release.isDistModule>true</commons.release.isDistModule>
     <commons.releaseManagerName>Gary Gregory</commons.releaseManagerName>    
     <commons.releaseManagerKey>86fdc7e2a11262cb</commons.releaseManagerKey>
+    <jmh.version>1.21</jmh.version>

Review comment:
       Why did you pick a seemingly random old version? Why not 1.27, which is the current version?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory edited a comment on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory edited a comment on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-755618217


   Something is not quite right with this set up because the output starts with:
   ```
   Building Apache Commons IO 2.7.1-SNAPSHOT
   ```
   instead of `2.9.0-SNAPSHOT`.
   
   Am I reading these results right? `IOUtilsContentEqualsPerformanceTest.testBufferedInputStream2` is 0.001% faster than `IOUtilsContentEqualsPerformanceTest.testBufferedInputStream` which is within the margin of error? If so, it's not worth it especially since the highest "2" score is higher than the highest normal score (using the error margin).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory commented on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757553373


   > > > @garydgregory rerun performance tests:
   > > > https://pastebin.ubuntu.com/p/njnG5x78fD/
   > > > seems no significant performance improvement in this two classes (comparing with sync ones in original jdk).
   > > > so maybe I should close this pr and migrate [IO-670] to use the version in jdk.
   > > > What is your opinion?
   > > 
   > > 
   > > @arturobernalg
   > > Am I reading the summary correctly in that the average times of some tests for the new code is slight _slower_?
   > 
   > @garydgregory seems so.
   > wondering why, but have no very good ideas.
   
   @arturobernalg 
   So... if it's only a tiny bit better on average (<0.01%) but can be worse in some cases, and also worse if you take into account the error measurement, then...?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r554590743



##########
File path: src/main/java/org/apache/commons/io/input/buffer/UnsynchronizedBufferedReader.java
##########
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input.buffer;
+
+import java.io.IOException;
+import java.io.Reader;
+import org.apache.commons.io.IOUtils;
+import static org.apache.commons.io.IOUtils.EOF;
+
+/**
+ * A BufferedReader class who does not care about thread safety, but very much faster.
+ *
+ * Should be able to replace java.io.BufferedReader in nearly every use-cases when you
+ * need the Reader be buffered, but do not need it have thread safety.
+ */
+public class UnsynchronizedBufferedReader extends Reader {
+    private final Reader reader;
+    private final char[] charBuffer;
+
+    private int nowIndex = 0;
+    private int nowLimit = 0;
+

Review comment:
       @garydgregory done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r552944750



##########
File path: src/test/java/org/apache/commons/io/performance/IOUtilsContentEqualsPerformanceTest.java
##########
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.performance;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.buffer.UnsynchronizedBufferedInputStream;
+import org.apache.commons.io.input.buffer.UnsynchronizedBufferedReader;
+import org.apache.commons.lang3.StringUtils;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+/**
+ * Test to show whether using BitSet for removeAll() methods is faster than using HashSet.
+ */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@State(Scope.Thread)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.SECONDS)
+@Fork(value = 1, jvmArgs = {"-server"})
+public class IOUtilsContentEqualsPerformanceTest {
+    static String[] STRINGS = new String[1];
+
+    static {
+        STRINGS[0] = StringUtils.repeat("ab", 1 << 24);
+    }
+
+    @Benchmark
+    public void testBufferedInputStream(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)
+        ) {
+            while (true) {
+                int nowI = bufferedInputStream.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedInputStream(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                UnsynchronizedBufferedInputStream bufferedInputStream = new UnsynchronizedBufferedInputStream(inputStream)
+        ) {
+            while (true) {
+                int nowI = bufferedInputStream.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testBufferedReader(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                BufferedReader bufferedReader = new BufferedReader(inputReader)
+        ) {
+            while (true) {
+                int nowI = bufferedReader.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedReader(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                UnsynchronizedBufferedReader bufferedReader = new UnsynchronizedBufferedReader(inputReader)
+        ) {
+            while (true) {
+                int nowI = bufferedReader.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    @Benchmark
+    public void testBufferedInputStream2(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)
+        ) {
+            byte[] bytes = new byte[1];
+            while (true) {
+                int nowI = bufferedInputStream.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedInputStream2(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                UnsynchronizedBufferedInputStream bufferedInputStream = new UnsynchronizedBufferedInputStream(inputStream)
+        ) {
+            byte[] bytes = new byte[1];
+            while (true) {
+                int nowI = bufferedInputStream.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testBufferedReader2(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                BufferedReader bufferedReader = new BufferedReader(inputReader)
+        ) {
+            char[] bytes = new char[1];
+            while (true) {
+                int nowI = bufferedReader.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedReader2(Blackhole blackhole) throws IOException {

Review comment:
       A "2" postfix for a method name says nothing about why its different from the plain method name. Please give it a name that better describes what you are testing.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-755419454


   Detailed performance tests results: https://pastebin.ubuntu.com/p/TtDxYw4WVG/


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess edited a comment on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess edited a comment on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757512557


   @garydgregory rerun performance tests:
   https://pastebin.ubuntu.com/p/njnG5x78fD/
   
   seems no significant performance improvement in this two classes (comparing with sync ones in original jdk).
   so maybe I should close this pr and migrate [IO-670] to use the version in jdk.
   What is your opinion?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757506756


   > Something is not quite right with this set up because the output starts with:
   > 
   > ```
   > Building Apache Commons IO 2.7.1-SNAPSHOT
   > ```
   > 
   > instead of `2.9.0-SNAPSHOT`.
   
   because the original pr is done when 2.7.0-SNAPSHOT, and delayed to now :)
   Alright, I've already rebased it, so it is with latest master now.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r552943274



##########
File path: src/test/java/org/apache/commons/io/performance/IOUtilsContentEqualsPerformanceTest.java
##########
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.performance;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.buffer.UnsynchronizedBufferedInputStream;
+import org.apache.commons.io.input.buffer.UnsynchronizedBufferedReader;
+import org.apache.commons.lang3.StringUtils;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+/**
+ * Test to show whether using BitSet for removeAll() methods is faster than using HashSet.
+ */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@State(Scope.Thread)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.SECONDS)
+@Fork(value = 1, jvmArgs = {"-server"})
+public class IOUtilsContentEqualsPerformanceTest {
+    static String[] STRINGS = new String[1];
+
+    static {
+        STRINGS[0] = StringUtils.repeat("ab", 1 << 24);
+    }
+
+    @Benchmark
+    public void testBufferedInputStream(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)
+        ) {
+            while (true) {
+                int nowI = bufferedInputStream.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedInputStream(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                UnsynchronizedBufferedInputStream bufferedInputStream = new UnsynchronizedBufferedInputStream(inputStream)
+        ) {
+            while (true) {
+                int nowI = bufferedInputStream.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testBufferedReader(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                BufferedReader bufferedReader = new BufferedReader(inputReader)
+        ) {
+            while (true) {
+                int nowI = bufferedReader.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedReader(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                UnsynchronizedBufferedReader bufferedReader = new UnsynchronizedBufferedReader(inputReader)
+        ) {
+            while (true) {
+                int nowI = bufferedReader.read();
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    @Benchmark
+    public void testBufferedInputStream2(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)
+        ) {
+            byte[] bytes = new byte[1];
+            while (true) {
+                int nowI = bufferedInputStream.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedInputStream2(Blackhole blackhole) throws IOException {
+        try (
+                InputStream inputStream = IOUtils.toInputStream(STRINGS[0]);
+                UnsynchronizedBufferedInputStream bufferedInputStream = new UnsynchronizedBufferedInputStream(inputStream)
+        ) {
+            byte[] bytes = new byte[1];
+            while (true) {
+                int nowI = bufferedInputStream.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testBufferedReader2(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                BufferedReader bufferedReader = new BufferedReader(inputReader)
+        ) {
+            char[] bytes = new char[1];
+            while (true) {
+                int nowI = bufferedReader.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void testUnsynchronizedBufferedReader2(Blackhole blackhole) throws IOException {
+        try (
+                StringReader inputReader = new StringReader(STRINGS[0]);
+                UnsynchronizedBufferedReader bufferedReader = new UnsynchronizedBufferedReader(inputReader)
+        ) {
+            char[] bytes = new char[1];
+            while (true) {
+                int nowI = bufferedReader.read(bytes , 0,  1);
+                // do nothing
+                blackhole.consume(nowI);
+                if (nowI != -1) {
+                    break;
+                }
+            }
+        }
+    }
+
+}

Review comment:
       It would simpler to validate this test if it was factored in such a way that a worker method was given a stream such that its called can call it with a constructed object, once for the JRE stream, another with the custom stream.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] coveralls edited a comment on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757499669


   
   [![Coverage Status](https://coveralls.io/builds/36213327/badge)](https://coveralls.io/builds/36213327)
   
   Coverage decreased (-0.04%) to 88.698% when pulling **3fd277491aeb998670ff9d7e9582ae3c597a387a on xenoamess-fork:add_unsynchronized_input_stream** into **4b92e65963105eedf469ace591ae0b84aa1c3afc on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess closed pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess closed pull request #184:
URL: https://github.com/apache/commons-io/pull/184


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-758755089


   > > > > @garydgregory rerun performance tests:
   > > > > https://pastebin.ubuntu.com/p/njnG5x78fD/
   > > > > seems no significant performance improvement in this two classes (comparing with sync ones in original jdk).
   > > > > so maybe I should close this pr and migrate [IO-670] to use the version in jdk.
   > > > > What is your opinion?
   > > > 
   > > > 
   > > > @arturobernalg
   > > > Am I reading the summary correctly in that the average times of some tests for the new code is slight _slower_?
   > > 
   > > 
   > > @garydgregory seems so.
   > > wondering why, but have no very good ideas.
   > 
   > @arturobernalg
   > So... if it's only a tiny bit better on average (<0.01%) but can be worse in some cases, and also worse if you take into account the error measurement, then...?
   
   @garydgregory Yep, so maybe I should close this pr and migrate [IO-670] to use the version in jdk.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] coveralls edited a comment on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757499669


   
   [![Coverage Status](https://coveralls.io/builds/36212872/badge)](https://coveralls.io/builds/36212872)
   
   Coverage increased (+0.006%) to 88.749% when pulling **3cf77f06fdc44c26d11dd332ca3780813d1ad706 on xenoamess-fork:add_unsynchronized_input_stream** into **4b92e65963105eedf469ace591ae0b84aa1c3afc on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] coveralls commented on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757499669


   
   [![Coverage Status](https://coveralls.io/builds/36212466/badge)](https://coveralls.io/builds/36212466)
   
   Coverage decreased (-0.05%) to 88.69% when pulling **7b61fb23d92d66ebeff0f845bf9bf513fa92f165 on xenoamess-fork:add_unsynchronized_input_stream** into **4b92e65963105eedf469ace591ae0b84aa1c3afc on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory edited a comment on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory edited a comment on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-755618217


   Something is not quite right with this set up because the output starts with:
   ```
   Building Apache Commons IO 2.7.1-SNAPSHOT
   ```
   instead of `2.9.0-SNAPSHOT`.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757525936


   > > @garydgregory rerun performance tests:
   > > https://pastebin.ubuntu.com/p/njnG5x78fD/
   > > seems no significant performance improvement in this two classes (comparing with sync ones in original jdk).
   > > so maybe I should close this pr and migrate [IO-670] to use the version in jdk.
   > > What is your opinion?
   > 
   > @arturobernalg
   > Am I reading the summary correctly in that the average times of some tests for the new code is slight _slower_?
   
   @garydgregory seems so.
   wondering why, but have no very good ideas.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r554590281



##########
File path: pom.xml
##########
@@ -469,5 +482,44 @@ file comparators, endian transformation classes, and much more.
         <coveralls.skip>true</coveralls.skip>
       </properties>
     </profile>
+    <profile>
+      <id>benchmark</id>
+      <properties>
+        <skipTests>true</skipTests>
+        <benchmark>org.apache</benchmark>
+      </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>1.6.0</version>

Review comment:
       @garydgregory mybad. changed to 3.0.0 now.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r554588514



##########
File path: pom.xml
##########
@@ -300,6 +312,7 @@ file comparators, endian transformation classes, and much more.
     <commons.release.isDistModule>true</commons.release.isDistModule>
     <commons.releaseManagerName>Gary Gregory</commons.releaseManagerName>    
     <commons.releaseManagerKey>86fdc7e2a11262cb</commons.releaseManagerKey>
+    <jmh.version>1.21</jmh.version>

Review comment:
       @garydgregory done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r552939523



##########
File path: src/main/java/org/apache/commons/io/input/buffer/UnsynchronizedBufferedInputStream.java
##########
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input.buffer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.apache.commons.io.IOUtils;
+import static org.apache.commons.io.IOUtils.EOF;
+
+/**
+ * A BufferedReader class who does not care about thread safety, but very much faster.
+ *
+ * Should be able to replace java.io.BufferedReader in nearly every use-cases when you
+ * need the Reader be buffered, but do not need it have thread safety.
+ */
+public class UnsynchronizedBufferedInputStream extends InputStream {
+    private final InputStream inputStream;
+    private final byte[] byteBuffer;
+
+    private int nowIndex = 0;

Review comment:
       Don't initialize values to their defaults.

##########
File path: src/main/java/org/apache/commons/io/input/buffer/UnsynchronizedBufferedInputStream.java
##########
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input.buffer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.apache.commons.io.IOUtils;
+import static org.apache.commons.io.IOUtils.EOF;
+
+/**
+ * A BufferedReader class who does not care about thread safety, but very much faster.
+ *
+ * Should be able to replace java.io.BufferedReader in nearly every use-cases when you
+ * need the Reader be buffered, but do not need it have thread safety.
+ */
+public class UnsynchronizedBufferedInputStream extends InputStream {
+    private final InputStream inputStream;
+    private final byte[] byteBuffer;
+
+    private int nowIndex = 0;
+    private int nowLimit = 0;

Review comment:
       Don't initialize values to their defaults.
   

##########
File path: src/main/java/org/apache/commons/io/input/buffer/UnsynchronizedBufferedReader.java
##########
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input.buffer;
+
+import java.io.IOException;
+import java.io.Reader;
+import org.apache.commons.io.IOUtils;
+import static org.apache.commons.io.IOUtils.EOF;
+
+/**
+ * A BufferedReader class who does not care about thread safety, but very much faster.
+ *
+ * Should be able to replace java.io.BufferedReader in nearly every use-cases when you
+ * need the Reader be buffered, but do not need it have thread safety.
+ */
+public class UnsynchronizedBufferedReader extends Reader {
+    private final Reader reader;
+    private final char[] charBuffer;
+
+    private int nowIndex = 0;
+    private int nowLimit = 0;
+

Review comment:
       Don't initialize values to their defaults.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory commented on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-755618217


   Something is not quite right with this set up because the output starts with:
   ```
   Building Apache Commons IO 2.7.1-SNAPSHOT" 
   ```
   instead of `2.9.0-SNAPSHOT`.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] garydgregory commented on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
garydgregory commented on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757525456


   > @garydgregory rerun performance tests:
   > https://pastebin.ubuntu.com/p/njnG5x78fD/
   > 
   > seems no significant performance improvement in this two classes (comparing with sync ones in original jdk).
   > so maybe I should close this pr and migrate [IO-670] to use the version in jdk.
   > What is your opinion?
   
   @arturobernalg 
   Am I reading the summary correctly in that the average times of some tests for the new code is slight _slower_?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r554584513



##########
File path: pom.xml
##########
@@ -300,6 +312,7 @@ file comparators, endian transformation classes, and much more.
     <commons.release.isDistModule>true</commons.release.isDistModule>
     <commons.releaseManagerName>Gary Gregory</commons.releaseManagerName>    
     <commons.releaseManagerKey>86fdc7e2a11262cb</commons.releaseManagerKey>
+    <jmh.version>1.21</jmh.version>

Review comment:
       @garydgregory when I add this into pom(in the former pr), there be only 1.21. this pr has been delayed for too long lol.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] XenoAmess commented on a change in pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
XenoAmess commented on a change in pull request #184:
URL: https://github.com/apache/commons-io/pull/184#discussion_r554590684



##########
File path: src/main/java/org/apache/commons/io/input/buffer/UnsynchronizedBufferedInputStream.java
##########
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input.buffer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.apache.commons.io.IOUtils;
+import static org.apache.commons.io.IOUtils.EOF;
+
+/**
+ * A BufferedReader class who does not care about thread safety, but very much faster.
+ *
+ * Should be able to replace java.io.BufferedReader in nearly every use-cases when you
+ * need the Reader be buffered, but do not need it have thread safety.
+ */
+public class UnsynchronizedBufferedInputStream extends InputStream {
+    private final InputStream inputStream;
+    private final byte[] byteBuffer;
+
+    private int nowIndex = 0;
+    private int nowLimit = 0;

Review comment:
       @garydgregory done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-io] coveralls edited a comment on pull request #184: [IO-698] add Unsynchronized version of UnsynchronizedBufferedInputStream and UnsynchronizedBufferedInputStream, and performance tests.

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #184:
URL: https://github.com/apache/commons-io/pull/184#issuecomment-757499669


   
   [![Coverage Status](https://coveralls.io/builds/36213142/badge)](https://coveralls.io/builds/36213142)
   
   Coverage decreased (-0.001%) to 88.742% when pulling **3fd277491aeb998670ff9d7e9582ae3c597a387a on xenoamess-fork:add_unsynchronized_input_stream** into **4b92e65963105eedf469ace591ae0b84aa1c3afc on apache:master**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org