RFR: 8294696 - BufferedInputStream.transferTo should drain buffer when mark set [v2]
Alan Bateman
alanb at openjdk.org
Wed Oct 19 07:42:59 UTC 2022
On Mon, 3 Oct 2022 05:54:31 GMT, Markus KARG <duke at openjdk.org> wrote:
>> This PR implements JDK-8294696.
>
> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
>
> Checking explicitly -1 instead of < 0
> Thank you. So far I have not measured the actual performance drop, as I thought it would be common sense to not drop performance _at all_, unless actually _needed_. Given the fact that the buffer could be huge depending on the caller's settings, it is hard to give a single number. For small buffers (like some KB) it is obviously neglectible, but for huge buffers (like GB) it might be drastic, and might lead to OOME in some border cases. That is why I would prefer to abstain from a defensive copy unless _needed_. :-)
I assume you can do some experiments to see if there is a useful threshold to use. If the number of buffered bytes is larger then just delegate to the super's transferTo as before. If there isn't profitable then we may have to think about closing the PR, it's okay to have tried.
-------------
PR: https://git.openjdk.org/jdk/pull/10525
More information about the core-libs-dev
mailing list