Skip to content

Commit 3827d2e

Browse files
feat: a run is capped by the memory it holds in MB instead of its live objects
1 parent e85e1e9 commit 3827d2e

56 files changed

Lines changed: 5693 additions & 5344 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/compiler/action.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ runs:
129129
shell: bash
130130
run: cargo test --locked -p edge-python --features coverage coverage
131131

132+
# On its own too, it recounts every slot at each collection to prove the running count.
133+
- name: Memory count
134+
shell: bash
135+
run: cargo test --locked --release -p edge-python --features memcheck --test tests vm::test::test_cases
136+
132137
# compiler.wasm ships, the speed build goes under _build/ for the CLI jobs.
133138
- name: Stage on tmp
134139
uses: ./.github/actions/upload

‎CONTRIBUTING.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ deno lint js/
5555

5656
### Engine
5757

58-
`cargo test --release` runs `tests/cases/vm.json` under `Limits::sandbox()`, so a budget, heap, or call-depth regression fails as a `MemoryError` or `RecursionError` instead of hanging. Every case must fit that budget, and two cases equal in every field fail the suite.
58+
`cargo test --release` runs `tests/cases/vm.json` under `Limits::sandbox()`, so a budget, memory, or call-depth regression fails as a `MemoryError` or `RecursionError` instead of hanging. Every case must fit that budget, and two cases equal in every field fail the suite.
59+
60+
`--features memcheck` recounts every slot at each collection and fails a case whose running memory count drifted from it, and `tests/memory.rs` checks the memory model never counts less than the allocator hands out. A change that grows a container the heap holds keeps both green.
5961

6062
### Bench
6163

‎Cargo.toml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@ doctest = false
1818
name = "tests"
1919
path = "tests/main.rs"
2020

21+
# Its own binary, since it counts every allocation through a global allocator.
22+
[[test]]
23+
name = "memory"
24+
path = "tests/memory.rs"
25+
2126
[features]
2227
default = ["std"]
2328
std = []
2429
# Records each instruction a run executes for `VM::ran`, method calls left unfused so every ip is the compiler's own.
2530
coverage = []
31+
# Recounts every slot at each collection and fails a vm.json case whose running memory count drifted.
32+
memcheck = []
2633
# The wrapper that makes compiler.wasm, its exports, host imports, allocator and panic handler.
2734
runtime = []
2835

0 commit comments

Comments
 (0)