Done
Pinned fields
Click on the next to a field label to start pinning.
Details
Assignee
Marco KaufmannMarco KaufmannReporter
Marco KaufmannMarco KaufmannComponents
Fix versions
Priority
Normal
Details
Details
Assignee
Marco Kaufmann
Marco KaufmannReporter
Marco Kaufmann
Marco KaufmannComponents
Fix versions
Priority

Sentry
Sentry
Sentry
Created February 7, 2024 at 2:21 PM
Updated October 16, 2024 at 2:06 PM
Resolved March 20, 2024 at 10:30 AM
The CPU usage optimization introduced with
VirtualThread
relies on the fact that these new types of threads can be “mounted” and “dismounted” from an OS thread whenever they find themselves waiting for some blocking operation ( I/O, network, etc..). When the task wrapped by the virtual thread runs some synchronized or native code, it will get pinned to its current underlying OS thread. If during this time a blocking operation occurs, the virtual thread will not be dismounted, blocking the OS thread, and defeating the purpose of using a virtual thread in the first place.This new rule should try to detect all cases where a task used to construct a new virtual thread, or passed to a
Executors.newVirtualThreadPerTaskExecutor()
includes synchronized code or native methods, and raise an issue.It could be better implemented in the architecture-plugin probably.
Note: The rule could be tricky to implement without too many FPs, as we could make wrong assumptions about the intentions behind the use of a synchronized block. In general, we will suggest avoiding VirtualThreads executing synchronized code with blocking operations within, as it defeats their purpose.