RFR: 8306308: (ch) Writer created by Channels::newWriter may lose data
Brian Burkhalter
bpb at openjdk.org
Wed Oct 18 19:14:46 UTC 2023
On Tue, 17 Oct 2023 05:57:37 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> [...] I think you'll need to create to some benchmarks to demonstrate that the channel handling in StreamEncoder can be removed.
I don't know whether this was the intended sort of benchmark,
@Param({"4096", "8192", "16384", "32768"})
public int capacity;
@Setup
public void create() throws IOException {
cbuf = new char[capacity];
Arrays.fill(cbuf, (char)42);
fc = FileChannel.open(path, CREATE, TRUNCATE_EXISTING,
WRITE, DSYNC);
writer = Channels.newWriter(fc, "UTF-8");
}
@Benchmark
public char[] testMethod() throws IOException {
writer.write(cbuf);
return cbuf;
}
but I see little difference between the master code results:
Benchmark (capacity) Mode Cnt Score Error Units
MyBenchmark.testMethod 4096 thrpt 5 46120.101 ± 3514.975 ops/s
MyBenchmark.testMethod 8192 thrpt 5 23014.621 ± 703.382 ops/s
MyBenchmark.testMethod 16384 thrpt 5 11355.081 ± 357.569 ops/s
MyBenchmark.testMethod 32768 thrpt 5 5669.087 ± 401.619 ops/s
and those with `WritableByteChannel` support removed from `StreamEncoder`:
Benchmark (capacity) Mode Cnt Score Error Units
MyBenchmark.testMethod 4096 thrpt 5 46431.382 ± 1641.437 ops/s
MyBenchmark.testMethod 8192 thrpt 5 23079.163 ± 1333.578 ops/s
MyBenchmark.testMethod 16384 thrpt 5 11594.550 ± 793.716 ops/s
MyBenchmark.testMethod 32768 thrpt 5 5619.294 ± 1252.580 ops/s
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16207#issuecomment-1769164290
More information about the nio-dev
mailing list