Insert locations at the end of a FOR loop.#140
Merged
vext01 merged 1 commit intoykjit:mainfrom Mar 13, 2026
Merged
Conversation
The intuition here is that if we've gone around one iteration of a for loop, we're more likely to close a "full, proper" iteration, whereas if we have the location on entry, we're likely to hit the "nothing to do" case. This is -- from memory! -- the same thing that PyPy does. There is a trade-off here: it means every time we execute a loop we do one iteration in the interpreter. Probably because of that, benchmarks are mixed, but IMHO show a small improvement. b15: ``` storage/lua/1000 4.95% faster richards/lua/100 4.27% faster sieve/lua/3000 2.12% faster cd/lua/250 1.19% faster bounce/lua/1500 1.84% slower knucleotide/lua/ 3.97% slower permute/lua/1000 4.30% slower ``` b16: ``` binarytrees/lua/15 4.93% faster storage/lua/1000 3.98% faster queens/lua/1000 3.44% faster cd/lua/250 2.24% faster spectralnorm/lua/1000 1.54% faster json/lua/100 3.04% slower knucleotide/lua/ 5.87% slower HashIds/lua/6000 6.13% slower nbody/lua/250000 13.60% slower ``` nbody is very nondeterministic so it can be hard to draw conclusions; that said, it does seem on b16 to have meaningfully slowed down. On b15, the slowdown is within the margin of noise, though on the edge of it: I think it may well have slowed down, but by perhaps 5-8%. So whether this holds on other machines is a bit unclear.
Contributor
|
Happy to follow your lead on this one. |
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.
The intuition here is that if we've gone around one iteration of a for loop, we're more likely to close a "full, proper" iteration, whereas if we have the location on entry, we're likely to hit the "nothing to do" case. This is -- from memory! -- the same thing that PyPy does.
There is a trade-off here: it means every time we execute a loop we do one iteration in the interpreter. Probably because of that, benchmarks are mixed, but IMHO show a small improvement. b15:
b16:
nbody is very nondeterministic so it can be hard to draw conclusions; that said, it does seem on b16 to have meaningfully slowed down. On b15, the slowdown is within the margin of noise, though on the edge of it: I think it may well have slowed down, but by perhaps 5-8%. So whether this holds on other machines is a bit unclear.