feat(vm): add the kernel natives Machine.countUp and Machine.countDown #239
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/164-retain-release-measure"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part 1 of #164: the kernel natives
Machine.countUpandMachine.countDown, plus the measurement that chose them.Measured (docs/PERFORMANCE.md 9.12, forge CI, binaries alternating, processor time, mean of three runs): a retain or release of a one-pointer value done in the interpreter's loop instead of a kernel call makes the new
benchmarks/chain-walk1.15x faster, in every pair of two runs.list-iterategains 1.06-1.14x andmap-count1.02-1.09x.fibonacci(32)(nothing counted) stays level. Two forms were measured against main: plain TorbScript overMachine.load/Machine.store, and these natives. They are equally fast, so the natives win on the rest: the header layout stays in C, and they leave every count to the kernel while a sandbox is open, so a memory stop keeps its site. Runs: https://git.torb.dev/torbscript/language/actions/runs/406 and https://git.torb.dev/torbscript/language/actions/runs/419. In run 419,tools/conformance.sh --vmpassed 279/279 with part 2 applied, and all three binaries printed the same lines.Commits
feat(vm): add the kernel natives Machine.countUp and Machine.countDown:static inlinedefinitions intorb.htorb_natives.h/machine_natives.c(CI-generated)machine_test.cstd/machinedocsdocs(performance): measure the retain and release of one pointer in 9.12:benchmarks/chain-walk.trbwith its C twin, and PERFORMANCE.md 9.11.Part 2, after a seed refresh that knows the two natives:
kernel retain/kernel releaseof a shape with exactly one non-nested counted word and no tag: head operandB= the pointer's register (register + offset ≤ 65535),C= 1 (retain) / 2 (release)..Kernelarm ofexecuteLoopcallsMachine.countUp/countDown(Machine.load(frame + 8 * b))first, and callsMachine.operateonly where it answers false.torb-bytecode-1, because old program text hasC= 0.e6468e2don the throwaway branchloop/164-measure2: about 30 lines inemit.trbandinterpret.trb.Refs #164
51fde67e7b51c3750b2f51c3750b2f5e58fd2f17Review of
5e58fd2f. CI is green for this head (bootstrap, tier A/B, same-C-on-every-host, pdisc). The change itself looks sound; one blocker keeps it from merging.Checklist
machine_test.cpin the owned/last-count/zero/shared/shared-bit/null/immortal/sandbox cases of both natives. The loop is untouched (part 2), soconformance --vmis not affected.count_uprefuses atSHARED_COUNT - 1,count_downrefuses the last count (< 2), zero and shared, and both defer to the kernel in a sandbox; null and immortal return true astorb_retaindoes.std/machine, VM.md sections 6 and 10, benchmarks README and PERFORMANCE.md are updated.torb_natives.h/machine_natives.crenumbering is the generator's, CI "every host emits the same C" passes).Findings
mainis atc2f677b0and this branch is based ona488fa3e. Ten commits landed in between, and three of them touch files this PR also changes:docs/PERFORMANCE.md,.pdisc-sidecar.yamland the neighbouring docs. Forgejo reportsmergeable: false. Please rebase onto currentmain(the repo merges by rebase), resolve the conflicts and let CI run again.mainalready has a section### 9.11 A nested write through a boxed list as List.update(PERFORMANCE.md line 1705). This PR also adds### 9.11at the end of the file, so after the rebase the file would have two sections with that number. Renumber yours to 9.12 and update every reference to it: thechain-walktext inbenchmarks/chain-walk.trb(header comment),docs/design/VM.mdsection 10 ("docs/PERFORMANCE.md 9.11"), and the PR/commit text if you want it to stay accurate. Then regenerate thebenchmarks/README.mdhash in.pdisc-sidecar.yamland re-run the pdisc stamp/index, since the sidecar changed on both sides.Non-blocking: none. Everything else is ready; once the branch is rebased and green on the new head, this is an approve.
5e58fd2f1734b00a923bReview of
34b00a92(re-review of my round on5e58fd2f). CI is green for this head (bootstrap, tier A/B, same-C-on-every-host, VS Code, playground, gates, commit messages, pdisc).Earlier blockers
mergeable: true, and the commits that landed onmainsince (images workflow, std declarations docs) touch none of this PR's files.### 9.12(after main's 9.11), and the references inbenchmarks/chain-walk.trb,docs/design/VM.mdand the code comment intorb.hsay 9.12. The pdisc sidecar hash forbenchmarks/README.mdis updated and the pdisc check is green.Checklist
machine_test.c(owned count, last count/zero, shared and shared-bit, null/immortal, sandbox) for both natives.count_uprefuses atSHARED_COUNT - 1;count_downrefuses the last count, zero and shared; both defer to the kernel in a sandbox; null/immortal return true astorb_retaindoes. Unchanged from the code I reviewed before.std/machine, VM.md, benchmarks README and PERFORMANCE.md updated with the measurement and run links.Non-blocking: none.
Windowandwindows(CONCURRENCY slice F, gap 6) #4