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
{{ message }}
Repository navigation
stdlib hot paths: string.format iolist + plain-table fast paths (B9) #273
The plan file is the source of truth for goal, scope, success criteria, and implementation notes. Comments here are for discussion; the plan is for execution.
Why now
Benchmark gaps that aren't dispatcher-shaped:
string.format is 1.77x slower than Luerl and 5.5x slower than C Lua. lib/lua/vm/stdlib/string.ex:333-350 builds the result by per-character binary concatenation (acc <> <<char>>), which reallocates on every literal byte. Iolist accumulation + a single IO.iodata_to_binary/1 at the end closes most of this gap.
table.sort is 1.76x slower than Luerl. lib/lua/vm/stdlib/table.ex:249-288 routes every read through Executor.table_index/3 and every write through Executor.table_newindex/3, even for plain integer-indexed tables with no metatable. A table.metatable == nil fast path skips ~200 Map.fetch! + branch checks per 100-element sort.
table.concat has the same per-slot Executor.table_index/3 overhead pattern.
apply_width_flags uses String.length (O(graphemes)) when byte_size would do — format output is by definition single-byte for %d/%f.
These are stdlib-side fixes, independent of dispatcher coverage. Wins stack with #271 and #272.
Out of scope
The O(n²) insertion sort path when a user-supplied Lua comparator is passed. Latent issue worth fixing but no current benchmark exercises it; defer until a comparator workload motivates it.
Activity