RFR: 8254078: DataOutputStream is very slow post-disabling of Biased Locking
Roger Riggs
rriggs at openjdk.java.net
Wed Oct 7 15:30:07 UTC 2020
On Wed, 7 Oct 2020 14:31:45 GMT, Andrew Haley <aph at openjdk.org> wrote:
>> DataOutputStream is a JDK 1.0 era class that doesn't specify whether it is safe for use by multiple threads or not.
>> Some methods are synchronized, some are not. The writeBuffer used by writeLong means it is not thread safe. The
>> writeShort and writeInt methods aren't thread safe so changing them to use the writeBuffer doesn't make things any
>> worse. Other examples are the "bytearr" used by writeUTF, the writeChars and writeBytes methods, and the protected
>> "written" field that sub-classes can use to monitor the number of bytes written. It might be helpful to add a
>> statement to the DataOutputStream class description to say that it not safe for by concurrent threads and it needs
>> appropriate synchronization to coordinate multiple writers. This issue or another issue doesn't matter. Can the
>> benchmark be turned into a microbenchmark for test/micro?
>
>> It might be helpful to add a statement to the DataOutputStream class description to say that it not safe for by
>> concurrent threads and it needs appropriate synchronization to coordinate multiple writers. This issue or another issue
>> doesn't matter.
>
> I see.
>
>> Can the benchmark be turned into a microbenchmark for test/micro?
>
> Now there's an interesting question. I can tweak the benchmark (which at present contains a modified version of
> DataOutputSteam, so can compare and contrast) so that it measures only the performance of the core library's
> implementation. Does that make sense? If so, I can add it to this PR.
The benchmark can be run with different JDKs, so the modified DOS can be omitted.
-------------
PR: https://git.openjdk.java.net/jdk/pull/542
More information about the core-libs-dev
mailing list