cfallin opened PR #1656 from sink-constants
to master
:
We've observed that there is sometimes significant wasted work in the generated
code due to spills/reloads when constants that have been CSE'd are codegen'd
once and then used much later. Because we don't support constant
rematerialization yet (bytecodealliance/regalloc.rs#19), it seems best to clone
and sinkiconst
-and-friends to just before their uses; this should avoid many
spills/reloads.Stats on
bz2.wasm
under wasmtime on aarch64 hardware, before and
after:Before:
Performance counter stats for 'target/release/wasmtime run --disable-cache /home/cfallin/wasm-tests/bz2.wasm': 3841.058300 task-clock (msec) # 1.996 CPUs utilized 31,786 context-switches # 0.008 M/sec 503 cpu-migrations # 0.131 K/sec 23,709 page-faults # 0.006 M/sec 9,803,413,280 cycles # 2.552 GHz 9,470,301,612 instructions # 0.97 insn per cycle <not supported> branches 49,773,064 branch-misses 1.924119736 seconds time elapsed
After:
Performance counter stats for 'target/release/wasmtime run --disable-cache /home/cfallin/wasm-tests/bz2.wasm': 3390.286950 task-clock (msec) # 1.962 CPUs utilized 16,780 context-switches # 0.005 M/sec 157 cpu-migrations # 0.046 K/sec 20,398 page-faults # 0.006 M/sec 8,336,868,801 cycles # 2.459 GHz 7,867,825,316 instructions # 0.94 insn per cycle <not supported> branches 44,435,002 branch-misses 1.728082422 seconds time elapsed
Compile time, as measured by
clif-util wasm
, went up very slightly (1.02s ->
1.07s, but 2635M insns to 2628M insns), but this is more than offset by the
runtime decrease: total wallclock time decreased by ~10% and instruction count
by ~17%.<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
cfallin requested bnjbvr and julian-seward1 for a review on PR #1656.
cfallin requested bnjbvr and julian-seward1 for a review on PR #1656.
cfallin closed without merge PR #1656.
Last updated: Nov 22 2024 at 16:03 UTC