kwik
kwik copied to clipboard
Project Loom / Virtual Threads support
How does Kwik play with virtual threads?
I see many usages of synchronized
keyword in current implementation methods (easy reference is Kwik log impl), perhaps ReentrantLock
is extremely easy to completely migrate to, to prevent pinning.
Use of synchronized
is hardly an issue at all, if the pinning does not occur frequently, but we can squeeze out some more performance when virtual threads are used, with supported synchronization technique.
I have a feeling that Kwik would already play very well and see major performance gain with virtual threads, due to its nature being written entirely in 100% Java with no dependency on JNI as far as it appears.
If we can support choosing the use of it, for underlying concurrency systems, with a configuration option, that would be ideal, if Kwik currently builds with a version of Java that supports this feature, or we can provide support with it potentially e.g. accepting an ExecutorService
, ThreadFactory
etc with builders/arguments, etc.
For official guidance on adopting virtual threads - https://docs.oracle.com/en/java/javase/21/core/virtual-threads.html - "Virtual Threads: An Adoption Guide" section. One can also refer to the case studies from those who have good support, in similar libraries.
There may be more optimizations we can make. If it is of motive to optimize Kwik for this, this issue could serve to track these.