Skip to content

Support Wasm Bulk Memory Operations - #4074

Closed
luc-blaeser wants to merge 23 commits into
masterfrom
luc/bulk-memory-operations
Closed

Support Wasm Bulk Memory Operations#4074
luc-blaeser wants to merge 23 commits into
masterfrom
luc/bulk-memory-operations

Conversation

@luc-blaeser

@luc-blaeser luc-blaeser commented Jun 26, 2023

Copy link
Copy Markdown
Contributor

Use WebAssembly bulk memory operations in the runtime system and compiler.

Performance Improvement:
Although Wasm bulk memory operations are mainly beneficial for the IC execution layer, one may notice a performance improvement for the copying GC at the IC cost model.

Runtime measurements, GC benchmark, total Wasm instructions, dfx 0.14.3, with latest bump allocator optimization (only applied to non-incremental GCs):

Configuration Before With bulk-memory op Difference
Copying GC 2.02e10 1.92e10 -5%
Incremental GC 1.85e10 1.85e10 0
Generational GC 1.86e10 1.86e10 0
Compacting GC 2.16e10 2.16e10 0

Fallback: ic-ref and ic-wasm do not support Wasm bulk memory operations and thus engage classical libc memcpy with ordinary memory access instructions.

Design:

  • Bulk memory operations are implemented in the compiler backend. For all platforms, except for ic-ref and ic-wasm, the compiler generates Wasm bulk-memory operations.
  • The runtime system uses these compiler-generated memory operations.
  • If Wasm bulk memory operations are not supported (in the case of ic-ref or ic-wasm), the compiler invokes the legacy operations exposed by the RTS. For this reason, the RTS is not compiled with Wasm bulk memory flag, such that it still integrates the legacy libc implementations that do not rely on Wasm bulk memory support.

@luc-blaeser luc-blaeser self-assigned this Jun 26, 2023
@luc-blaeser luc-blaeser added the performance Affects only gas usage or code size label Jun 26, 2023
@ggreif

ggreif commented Jun 26, 2023

Copy link
Copy Markdown
Contributor

See also #3009. But that needs quite some yak-shaving before it can be made working.

@luc-blaeser

luc-blaeser commented Jun 26, 2023

Copy link
Copy Markdown
Contributor Author

See also #3009. But that needs quite some yak-shaving before it can be made working.

Thanks for pointing this out. This PR covers changes from the former PR.

@github-actions

github-actions Bot commented Jun 27, 2023

Copy link
Copy Markdown
Contributor

Comparing from 47fb734 to ff88f8e:
In terms of gas, 4 tests regressed, 1 tests improved and the mean change is -0.2%.
In terms of size, 2 tests regressed, 3 tests improved and the mean change is -0.0%.

@luc-blaeser
luc-blaeser marked this pull request as ready for review June 27, 2023 13:37
Comment thread src/codegen/compile.ml Outdated
@ggreif

ggreif commented Jul 20, 2023

Copy link
Copy Markdown
Contributor

Looks like you need some --enable-bulk-memory flags in the test/run.sh script.

@luc-blaeser
luc-blaeser requested a review from crusso July 21, 2023 11:51
@luc-blaeser

Copy link
Copy Markdown
Contributor Author

Inactive for a while. We can reopen if needed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Affects only gas usage or code size

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants