-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Thread not killable when in 300_000_000.times { |i| var = i } loop #5199
Comments
Personally I think it should not be possible to write a code in Ruby which would be un-killable. I originally found out by not being able to terminate https://github.com/ruby-concurrency/concurrent-ruby/blob/master/spec/concurrent/synchronization_spec.rb#L15-L20 which less minimal. |
@headius, There is a back-edge ... except it is in the jruby library code. That indicates that the library code is missing the checkpoint maybe? |
Shouldn't the times have a threadpoll instr right before jump? (Not convenient for me to check right now). |
@enebo It would if it were implemented in Ruby. In Java we have to manually add polling to backedges. |
@enebo I guess I'm saying yes, it probably should :-) |
@pitr-ch I think we agree. I just wanted to point out this is a rather unlikely scenario. Nearly all code will have at least one call, which will trigger the polling. |
ah yeah times is native. No call here so times is missing the magic itself. Not an IR bug at least. |
The following patch fixes this with a minimum of overhead (only checking thread events every N calls):
However it does reduce performance to use even the "call" version of polling:
Note that the performance of a pure-Ruby version, when the stars align (this is on GraalVM), both works and performs well (since the thread interrupt is handled as a safepoint):
|
Environment
in a snippet
Expected Behavior
the thread is killed immediately
Actual Behavior
however It runs until the loop finishes
The text was updated successfully, but these errors were encountered: