Repository navigation
bench: add a host-call kernel - #320
Merged
Merged
Conversation
roadmap.md lists host calls as a P1 benchmark area, and no kernel covered it. host-call loops 1024 times over acc = mix(acc, i), where mix is a Go function every runtime calls once per iteration. registry.Spec gains Host, a plain Go func, so the fixture source stays free of runtime imports for Yaegi. minivm binds it the documented default way, Interpreter.Marshal -> Alloc -> SetGlobal(0), again after each Reset because Reset reseeds globals, outside the timed window. Tengo, GopherLua, Goja and gpython bind it as a global function; CPython runs out of process and is skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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.
Summary
docs/roadmap.mdP1 lists host calls as a benchmark area; no kernel covered it.acc = mix(acc, i)for i < 1024, wheremix(a, b) = (a*31 + b) % 1000003is a Go function each runtime calls once per iteration.registry.Spec.Host(Name,I32 func(a, b int32) int32): a plain Go func, so the fixture source needs no runtime import (Yaegi evaluates it).Interpreter.Marshal→Alloc→SetGlobal(0)(.mvmdeclares global 0 with the func type and callsglobal.get 0; call).Resetreseeds globals, so the runner re-binds after eachReset, outside both the timed and the allocation-sampling windows.UserFunction, GopherLuaNewFunction, GojaSet, gpython module global. CPython runs out of process and is skipped; Yaegi and native run the Go source.Finding (local, M4 Pro, 300 ms)
The codec's
Marshaled func costs ~13.7 allocations per call. Tracked as a follow-up in the maintainer's queue (host-call optimization).Review
Independent Opus review: approve. Fixtures identical and int32-safe, Marshal/Alloc/SetGlobal ownership balanced across Reset cycles, setup outside measurement, every other kernel's script runners still pass. Applied:
Hostdoc states how minivm binds (global 0), README CPython count. Not applied: argument checks in the gpython/Tengo bindings (diagnostics only; a wrong call cannot happen with these fixtures).Validation
go test ./...inbenchmarks/,make check,git diff --check🤖 Generated with Claude Code