quarkus
quarkus copied to clipboard
Replace read/write lock in JarResource to avoid virtual threads pinning
This is a proposed solution for the problem reported here.
I'm avoiding blocking on the ReadWriteLock
and emulating its behavior with a state machine + an atomic readers counter because the zipFile access may happen inside a native call (for example triggered by the RunnerClassLoader) and then it is necessary to avoid blocking on it.
Note that while avoid blocking and thus preventing pinning, I'm afraid that this solution could suffer of monopolization. I tried to mitigate the problem with the yields at lines 160 and 183 but I'm not sure if this is a good idea, especially with virtual threads. Any feedback or suggestion to improve is welcome.
/cc @franz1981 @geoand @Sanne @dmlloyd @cescoffier