Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pulley: Is the best interpreter loop a "match" loop or a "tail call" loop? #9995

Open
alexcrichton opened this issue Jan 13, 2025 · 1 comment
Labels
pulley Issues related to the Pulley interpreter

Comments

@alexcrichton
Copy link
Member

Pulley currently has two methods of dispatch in the interpreter loop, namely one morally using a giant match statement and the other using tail-calls between opcodes. The latter is currently only evaluatable on some architectures (e.g. x64) when optimizations are turned on and LLVM optimizes things right. Rust's become keyword does not currently work in Nightly.

I just did a Sightglass run of these two methods of dispatch in the interpreter and I got:

execution :: cycles :: benchmarks/pulldown-cmark/benchmark.wasm

  Δ = 14835771.96 ± 525589.74 (confidence = 99%)

  match.so is 1.17x to 1.19x faster than tail.so!

  [81442196 82553273.83 87049480] match.so
  [96420118 97389045.79 102479551] tail.so

execution :: cycles :: benchmarks/bz2/benchmark.wasm

  Δ = 104438181.93 ± 1644379.63 (confidence = 99%)

  match.so is 1.13x to 1.13x faster than tail.so!

  [782662505 787350365.15 795150499] match.so
  [888116768 891788547.08 916663514] tail.so

execution :: cycles :: benchmarks/spidermonkey/benchmark.wasm

  Δ = 674804802.30 ± 21521230.61 (confidence = 99%)

  tail.so is 1.03x to 1.04x faster than match.so!

  [19395106358 19464509629.23 19638165876] match.so
  [18716347537 18789704826.93 18999413981] tail.so

which I found surprising. The "match" loop was 10-20% faster for bz2/pulldown-cmark where the "tail" loop was only 3-4% faster for spidermonkey. This goes against what I've been measuring on a "fib" micro-benchmark where the "tail" loop is about 20% faster.

This leads me to the conclusion of "I don't know what's going on here" and I wanted to open an issue on this. It's not a maintenance burden at this time to have both implementations, but ideally we wouldn't have two indefinitely.

@alexcrichton alexcrichton added the pulley Issues related to the Pulley interpreter label Jan 13, 2025
Copy link

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "pulley"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: pulley

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pulley Issues related to the Pulley interpreter
Projects
None yet
Development

No branches or pull requests

1 participant