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

feat!: add memory limiting #391

Merged
merged 36 commits into from
Dec 13, 2023
Merged

feat!: add memory limiting #391

merged 36 commits into from
Dec 13, 2023

Conversation

ValeryAntopol
Copy link
Collaborator

@ValeryAntopol ValeryAntopol commented Nov 1, 2023

This PR adds the memory limiting feature to the Marine runtime, for now only when it runs using wasmtime backend. A user should set a limit in the service config, then the runtime will refuse to allocate more memory for modules in the service if the resulting total memory consumed exceeds the limit.

The memory limiter counts memory consumed by WebAssembly Memory and WebAssembly Table objects and nothing else.

The new config structure looks like this:

modules_dir = "artifacts/"
total_memory_limit = "128 MiB" # field for memory limit
# total_memory_limit = "Infinity" # a way to allow infinite memory growth

[[module]]
    name = "greeting"
    # max_heap_size = "10 KiB" # removed field
    logger_enabled = false

@ValeryAntopol ValeryAntopol marked this pull request as ready for review November 1, 2023 21:15
@ValeryAntopol ValeryAntopol changed the title feat!(runtime): add memory limiting feat!: add memory limiting Nov 1, 2023
marine/src/marine.rs Outdated Show resolved Hide resolved
core/src/memory_statistic.rs Show resolved Hide resolved
core/src/memory_statistic.rs Outdated Show resolved Hide resolved
marine/tests/memory_limiting.rs Outdated Show resolved Hide resolved
core/src/memory_statistic.rs Outdated Show resolved Hide resolved
crates/wasm-backend-traits/Cargo.toml Outdated Show resolved Hide resolved
crates/wasmtime-backend/Cargo.toml Outdated Show resolved Hide resolved
crates/wasmtime-backend/src/store.rs Outdated Show resolved Hide resolved
crates/wasmtime-backend/src/store.rs Show resolved Hide resolved
marine/src/config/marine_config.rs Outdated Show resolved Hide resolved
Copy link
Member

@mikevoronov mikevoronov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

marine/tests/memory_limiting.rs Outdated Show resolved Hide resolved
@fluencebot fluencebot added the e2e Run e2e workflow label Dec 12, 2023
@ValeryAntopol ValeryAntopol merged commit 662a492 into master Dec 13, 2023
20 of 24 checks passed
@ValeryAntopol ValeryAntopol deleted the feat/memory-limits branch December 13, 2023 16:52
@fluencebot fluencebot mentioned this pull request Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants