Repository navigation
feat(vm): interrupt running Lua at a host-set deadline with Lua.set_deadline/2 - #435
Open
dbernheisel wants to merge 1 commit into
Open
dbernheisel wants to merge 1 commit into
dbernheisel wants to merge 1 commit into
Conversation
Lua.set_deadline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A host that calls back into Lua from an Elixir function can't stop just that callback when it runs long.
:max_instructionsis per evaluation, and killing the process throws away the whole state.Lua.set_deadline/2gives running Lua aSystem.monotonic_time(:millisecond)deadline. Past it, Lua raises a catchable"deadline exceeded"at the next loop back-edge or call, the same places:max_instructionsis checked. It's what alua_sethookcount hook gives a host in reference Lua.pcallthat traps the error is interrupted again on its next tick, so the error reaches the hostLua.deadline/1returns the current deadline, so a host can give a nested call a shorter one and restore it afterBenchmarks
feat/vm-gc(f5d18a5) vs this branch (105bb9c),lua (chunk)median, quick mode. Base and branch ran interleaved per workload, two rounds averaged (oop five rounds). Apple M4 Max, OTP 29, Elixir 1.20.0. Other work was running on the machine (load 5–11), so a few percent either way is noise.__indexchainCost when a deadline is set, on this branch: 4M loop iterations in a compiled function, nine runs each.
max_instructions: 1_000_000_000