-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement the monitor stdlib in Java #2375
Comments
I see this everywhere
Doesn't seem like it takes up a lot of Used in key operations like |
This seems doable. We already have a Java implementation of |
Fixed in 00b825c |
How much faster did this make it? |
I added a monitor/synchronize microbenchmark as part of this work. Without the change the peak performance was 4221084 iterations per second, and with the change it is 20322560 iterations per second, so about a 5x speed increase. |
Currently we use monitor.rb: https://github.com/oracle/truffleruby/blob/d2532c21cd85663329e083de1870a6466f258766/lib/mri/monitor.rb
That's quite inefficient, notably because it uses a lot of
Thread.handle_interrupt
which seems quite expensive.By moving it to Java code we can avoid the need for changing the interrupt mode, because we have better control where guest safepoints can happen (i.e., no risk for a Thread#raise in the middle of ensure with Java
finally
, which is what thoseThread.handle_interrupt
prevent).Probably using a ReetrantLock + Condition and reusing Mutex code is the way to go.
CRuby rewrote monitor to a C extension in ruby/ruby#2576 https://bugs.ruby-lang.org/issues/16255.
The text was updated successfully, but these errors were encountered: