Repository navigation
Sweep: constructor sizing, hash-part keys, iterators, concat and resume - #50
Merged
Merged
Conversation
{f(), g()} sized its array for the items before the open call, so the
SETLIST that stored g's results always reallocated it. The size hint now
keeps a slot for the open list's first value: one allocation per such
table instead of two. A call that returns nothing leaves a nil slot, which
length and traversal already handle. binarytrees: -25% allocations, -8.7%
time.
constSet becomes quickSet, which SETTABLE and SETTABLEK also use for a string key or an integer key outside the array part, as t[0] in fannkuch. GETTABLE's slow path looks integer keys outside the array part up in the hash part directly, as it did string keys. fannkuch: -7.7% time.
…rray part directly clear on a few Values is a runtime call with a bulk write barrier, about 7% of the pairs script. pairs: -17% instructions, -19% time.
resume copied the caller's state into a local and then into prev.waiting; it now saves it into prev.waiting once and restores it from there. coroutine: -4.6% instructions, -2.3% time.
ebarkie
pushed a commit
to ebarkie/glua
that referenced
this pull request
Oct 21, 2026
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.
Results from profiling every suite script, looking for costs outside the interpreter loop. Each change is a separate commit.
fast.gois unchanged, and asmgate passes.{f(), g()}sized its array without the open call, so SETLIST always reallocated it. The hint now keeps a slot for the open list's first value; a call that returns nothing leaves a nil slot, which length and traversal already handle.quickSetconstSetbecomesquickSet. SETTABLE and SETTABLEK now also use it for string keys and for integer keys outside the array part, such asperm[0]. GETTABLE's slow path looks such integer keys up directly, as it already did for strings. A key one past the array still goes throughset, which appends it to the array part.clearon 2–3 Values was a runtime call with a bulk write barrier, about 7% of pairs. ipairs now reads the array part directly.table.concatresumeprev.waitingonce and restored from there, instead of going through a local copy.Fast-loop times on the suite (ms, minimum of 3 interleaved runs):
json (-6.0%), oop (-7.5%) and sort (-5.2%) also came out faster, but none of these changes clearly explains it, so treat those numbers, and the geomean they lift, as noise until a rerun confirms them. The other scripts are within ±3%. That includes fib and floatloop, which run only in the unchanged loop; their instruction counts didn't change.
New corpus cases, with expected output from C Lua:
compile.lua: constructors whose open last item gives no values.meta.lua: integer and string keys outside the array part, with and without__newindex, and appending past the end of the array.