Skip to content

Reworking VM stack ABI to use host stack storage in most cases - #2076

Closed
benvanik wants to merge 10 commits into
masterfrom
benvanik-regs
Closed

benvanik wants to merge 10 commits into
masterfrom
benvanik-regs

Conversation

@benvanik

@benvanik benvanik commented May 31, 2020 •

Copy link
Copy Markdown
Collaborator

Reduces the default stack to be small enough to fit on the host stack and
dynamically growable if needed. This dramatically reduces our memory
footprint and speeds up almost everything VM-related (invocation from C
to bytecode, bytecode to C, and bytecode to bytecode). It also has the
effect of properly guarding register array accesses via valid bit masks
that avoids expensive logic in the actual bytecode op implementations.

Fixes #1172.

Before/after (of just one function type):
image

@benvanik benvanik changed the title Benvanik regs Reworking VM stack ABI to use host stack storage in most cases May 31, 2020
@benvanik
benvanik force-pushed the benvanik-regs branch 5 times, most recently from 4aac3a5 to 60ef8c5 Compare June 5, 2020 06:12
@benvanik
benvanik marked this pull request as ready for review June 5, 2020 06:24
@benvanik
benvanik requested a review from ScottTodd June 5, 2020 06:24
@benvanik benvanik added enhancement ➕ New feature or request runtime Relating to the IREE runtime library labels Jun 5, 2020
@benvanik benvanik added this to the 2020Q2 Core milestone Jun 5, 2020
@benvanik benvanik added the performance ⚡ Performance/optimization related work across the compiler and runtime label Jun 5, 2020
Comment thread iree/vm/stack.c Resolved
Comment thread iree/vm/stack.c Resolved
Comment thread iree/vm/context.c Resolved
@phoenix-meadowlark

Copy link
Copy Markdown
Contributor

I'm restructuring some parts of the CI, and all open PRs behind this commit will be affected. This only affects PRs that are seven days old or older. Expect presubmit failures for linux_bazel_core and eventually linux_bazel on future pushes until this PR is synced.

@benvanik
benvanik force-pushed the benvanik-regs branch 4 times, most recently from 4bdb603 to 37c7b9b Compare June 16, 2020 00:16
@benvanik
benvanik force-pushed the benvanik-regs branch 3 times, most recently from a2df4e5 to 8419564 Compare June 16, 2020 02:45
benvanik added 6 commits June 16, 2020 09:43
Reduces the default stack to be small enough to fit on the host stack and
dynamically growable if needed. This dramatically reduces our memory
footprint and speeds up almost everything VM-related (invocation from C
to bytecode, bytecode to C, and bytecode to bytecode). It also has the
effect of properly guarding register array accesses via valid bit masks
that expensive logic in the actual bytecode op implementations.

Latest VM bytecode benchmark numbers for desktop:
-----------------------------------------------------------------------
Benchmark                             Time             CPU   Iterations
-----------------------------------------------------------------------
BM_ModuleCreate                     176 ns          176 ns      3733333
BM_ModuleCreateState               72.4 ns         71.5 ns      8960000
BM_FullModuleInit                   236 ns          235 ns      2986667
BM_EmptyFuncReference              2.57 ns         2.55 ns    263529412
BM_EmptyFuncBytecode               76.4 ns         76.7 ns     11200000
BM_CallInternalFuncReference       2.27 ns         2.29 ns    320000000
BM_CallInternalFuncBytecode        22.4 ns         22.5 ns     29866680
BM_CallImportedFuncBytecode        20.7 ns         20.5 ns     32000000
BM_LoopSumReference/100000         1.17 ns         1.17 ns    640000000
BM_LoopSumBytecode/1000000         7.73 ns         7.64 ns     90000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ➕ New feature or request performance ⚡ Performance/optimization related work across the compiler and runtime runtime Relating to the IREE runtime library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make VM stack frame allocation dynamic to reduce fixed overhead

4 participants