On 2021-02-03 Brett Okken wrote:
> I have not done any testing of xz specifically, but was motivated by
> https://github.com/openjdk/jdk/pull/542, which showed pretty
> noticeable slowdown when biased locking is removed. The specific
> example there was writing 1 byte at a time being transitioned to
> writing the 2-8 bytes to a byte[] first, then writing that buffer to
> the OutputStream. I suspect that reading would have similar impact.

I don't doubt that. However, in XZ the uses of ByteArrayInputStream and
ByteArrayOutputStream are in places where the performance could be
absolutely horrible and it would still make little difference in
overall speed. The amounts of data being read or written are so small.

LZMAInputStream reads the whole file one byte at a time (via
RangeDecoderFromStream.normalize()) and performance suffers compared to
XZInputStream even if one uses BufferedInputStream. BufferedInputStream
has synchronized read(). I don't know how much locking matters in this
case. I'm not curious enough to try with a non-synchronized buffered
input stream now.

There are related comments in the "java buffer writes" thread.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

Reply via email to