You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking at the disassembly and saw we're doing a lot of RUBY_VM_CHECK_INTS(ec) all over the place. We need to check for interrupts semi-regularly, but presumably we could skip some, gain some performance, reduce code size a bit, and still be fine.
There's already one small optimization for this in YJIT: forward branches don't check for interrupts, because we know we're making forward progress in an ISEQ, while backwards branches do, because they could be loops.
I'm wondering what other heuristics we could come up with. Some possibilities:
Could we skip the check for some C calls? If so, which ones?
Could we skip the return check if we know we just returned from a call?
It has to happen often that we have multiple returns in a row
The main problem that I see is that it seems tricky to come up with a good heuristic. I think we could probably skip the check for most C calls, but are there some C calls where this wouldn't be safe?
Potentially, we could also skip the check for all returns or for all calls, simply because, every return has to match up with a call and we can't have infinite recursion. However, if we want to skip the check for some calls/returns but not all, it becomes trickier to find a robust heuristic.
For instance, if we want to skip the check when there is a send preceding a return, we have the issue that we don't necessarily know if there is always a send preceding said return, because there may be a branch that hasn't been compiled yet. We would need a little ISEQ-level analysis to be completely sure that control-flow can't come to the return without first passing through a send.
I was looking at the disassembly and saw we're doing a lot of
RUBY_VM_CHECK_INTS(ec)
all over the place. We need to check for interrupts semi-regularly, but presumably we could skip some, gain some performance, reduce code size a bit, and still be fine.There's already one small optimization for this in YJIT: forward branches don't check for interrupts, because we know we're making forward progress in an ISEQ, while backwards branches do, because they could be loops.
I'm wondering what other heuristics we could come up with. Some possibilities:
The main problem that I see is that it seems tricky to come up with a good heuristic. I think we could probably skip the check for most C calls, but are there some C calls where this wouldn't be safe?
Potentially, we could also skip the check for all returns or for all calls, simply because, every return has to match up with a call and we can't have infinite recursion. However, if we want to skip the check for some calls/returns but not all, it becomes trickier to find a robust heuristic.
For instance, if we want to skip the check when there is a send preceding a return, we have the issue that we don't necessarily know if there is always a send preceding said return, because there may be a branch that hasn't been compiled yet. We would need a little ISEQ-level analysis to be completely sure that control-flow can't come to the return without first passing through a send.
Tagging @jhawthorn @k0kubun and @XrXr to start the discussion.
The text was updated successfully, but these errors were encountered: