Skip to content

Keep Lua registers and code in separate halves of a page - #18

Merged
acneism merged 2 commits into
mainfrom
separate-stack-code
Nov 5, 2026
Merged

acneism merged 2 commits into
mainfrom
separate-stack-code

Conversation

@acneism

@acneism acneism commented Nov 5, 2026

Copy link
Copy Markdown
Owner

ArithConst was bimodal between processes because a Lua register and a code word shared their low 12 address bits, and the physical pages decided the rest. Registers now stay in the lower half of a page and code in the upper half, using Go's size classes, without unsafe or reflect.

ArithConst over 24 runners and 288 fresh processes of each version: 21 over 1.3 before, none after. Worst value per processor went from 1.67-1.88 to 0.82-1.07.

Other scenarios: within 1% when only the placement is switched inside one binary. Comparing two binaries moves StructRoundTrip by 1.13 and RedisCall by 0.91 on EPYC 7763, which is code layout.

Costs: a small compiled script retains about 4 KB more, and creating and finishing a coroutine takes 5.9 us instead of 4.4 us.

Deep recursion past R84, functions over 256 words and other pairs of loads and stores are not covered. Details are in docs/adr/0013-register-and-code-placement.md.

@acneism
acneism merged commit 4efd6e0 into main Nov 5, 2026
26 of 27 checks passed
@acneism
acneism deleted the separate-stack-code branch November 5, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant