Skip to content

bench: add map-ops and coroutine-gen kernels - #318

Merged
siyul-park merged 2 commits into
mainfrom
bench/map-coroutine
Nov 10, 2026
Merged

siyul-park merged 2 commits into
mainfrom
bench/map-coroutine

Conversation

@siyul-park

Copy link
Copy Markdown
Owner

Summary

docs/roadmap.md P1 lists maps and coroutines as benchmark areas; none of the 26 kernels covered either.

  • map-ops: i32->i32 map, N=256. Insert key(k) = (1<<27) + k*7919 % 65521, look up (odd k probe key(k)+65521, always a miss), update even k, delete k%4==0, final sum; result sum*1024 + len = 58785984. The 1<<27 offset keeps GopherLua on its hash part (it stores integer keys up to 2^26 in the array part, which measured array growth: 5.58 MB/op before, 114 KB after).
  • coroutine-gen: a generator yields (i*i + 7*i) % 1009 for i < 512; the consumer resumes until done and sums mod 65521. Go uses iter.Pull; Lua coroutines, JS generator, Python generator; .mvm uses yield/resume/coro.done/coro.value.
  • Not measured: Tengo (string-keyed maps, no coroutines), gpython map-ops (string keys only), Yaegi coroutine-gen (no iter package). Recorded in benchmarks/README.md with the existing skip style.

Observations (local, M4 Pro, 300 ms x3)

kernel threaded jit native Go
map-ops 43.3 µs 43.4 µs 6.0 µs
coroutine-gen 46 µs 45 µs 19 µs

JIT gains nothing on either: map operations bridge to the interpreter, and yield/resume make the translator decline the unit. Follow-up issues will track these.

Review

Independent Opus review: algorithms identical across runtimes, int32-safe, .mvm stack/ref handling sound. Its MEDIUM (GopherLua array part) and two LOWs (single lookup in JS/Python, README sentence) are applied.

Validation

  • go test ./... in benchmarks/ (TestKernels threaded+jit, runtime checks for every registered runtime)
  • make check, git diff --check (pre-commit)

docs/benchmarks.md is regenerated by CI.

🤖 Generated with Claude Code

roadmap.md lists maps and coroutines as P1 benchmark areas, and no
kernel covered either.

map-ops: an i32->i32 map of 256 entries; insert, look up (half miss),
update, delete, sum. Keys are offset by 1<<27 so GopherLua hashes them
instead of growing its array part. coroutine-gen: a generator yields
512 values that the consumer resumes and sums; Go uses iter.Pull.

Tengo has neither integer-keyed maps nor coroutines; gpython dicts take
only string keys (map-ops); Yaegi has no iter package (coroutine-gen).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7135a10-894e-427f-93fd-830f0a042f2c
Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@siyul-park
siyul-park merged commit 46b7a6c into main Nov 10, 2026
2 checks passed
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