Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Add CLI configuration for memory limits and improve performance for large initial heaps #77

Merged
4 commits merged into from
Mar 29, 2019

Conversation

ghost
Copy link

@ghost ghost commented Mar 29, 2019

This adds command-line parameters to lucet-wasi to control the memory limits, and raises the default values of those limits substantially. Most users will only ever need to turn them down, not up.

Also, this reworks the way reserved size is set in lucetc to provide fewer surprises; see b563370.

Finally, this switches to relying on madvise to zero the instance heap when an instance is reset or created, substantially improving performance for programs with large initial heaps.

Closes #74 and #76

@ghost ghost self-assigned this Mar 29, 2019
@ghost ghost requested a review from jedisct1 March 29, 2019 16:51
jedisct1
jedisct1 previously approved these changes Mar 29, 2019
@ghost ghost changed the title Add CLI configuration for memory limits Add CLI configuration for memory limits and improve performance for large initial heaps Mar 29, 2019
@jedisct1
Copy link
Contributor

Hey Adam,

Can you fix the conflicts, so this can be merged? That would be great :)

Rather than explicitly zeroing, use `madvise` and `mprotect` to zero the heap.

We also now make sure the heap address space is at least as big as the memory size when validating
`Limits`.
- Heap limits are set to maximum for a 32-bit address space + 32-bit guard size
- Stack size is set to 8MiB to match Linux's default
- Globals size is calculated from the module
@ghost ghost force-pushed the acf/lucet-wasi-memory-cli branch from d68f8f3 to 0958c18 Compare March 29, 2019 20:15
jedisct1
jedisct1 previously approved these changes Mar 29, 2019
Instead of a single `reserved-size` argument, `lucetc` now optionally takes `--min-reserved-size`
and `--max-reserved-size`. By default, the minimum is 4 KiB, and the maximum is 6 GiB (the entire
possible wasm address space, plus extra room for bounds check elision).

In the case that the module's initial heap size is larger than the minimum, we use the initial heap
size as the reserved size.

In the case that the initial size is larger than the maximum, compilation fails.
@ghost ghost force-pushed the acf/lucet-wasi-memory-cli branch from 0958c18 to b563370 Compare March 29, 2019 20:20
@ghost ghost merged commit 14d1c14 into master Mar 29, 2019
@ghost ghost deleted the acf/lucet-wasi-memory-cli branch March 29, 2019 20:45
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants