RFR: 8301578: Perform output outside synchronization in Module.class
Per Minborg
pminborg at openjdk.org
Wed Feb 1 08:37:47 UTC 2023
On Wed, 25 Jan 2023 12:26:26 GMT, Per Minborg <pminborg at openjdk.org> wrote:
> This PR proposed to reduce contention in synchronized methods mainly by doing I/O operations outside synch blocks.
Let me take a step back here and explain the reason why I think this PR is worth looking at. Firstly, I think the argument that this might not solve https://bugs.openjdk.org/browse/JDK-8300917 is perfectly valid. Therefore, I have filed a separate issue and linked this PR to this. Thanks for pointing this out. This PR is more like a drive-by cleanup as mentioned.
Back to the contents of the PR. My fear (which may or may not be substantiated) is that if we perform operations via the relatively slow `System.err.printf,` while being in a synchronization block, we are exposed to a number of potential problems:
* Another thread might be performing `System.err` operations which will be under a separate lock/sync
* Other threads are calling `ensureNativeAccess` for the same module
* A "storm of calls" during bootstrap
* Combinations of any of the above
Again, this might not be the case in reality but I think removing the risk is worthwhile.
-------------
PR: https://git.openjdk.org/jdk/pull/12193
More information about the core-libs-dev
mailing list