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

Incremental GC #3837

Merged
merged 796 commits into from May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
796 commits
Select commit Hold shift + click to select a range
4c89aee
Adjust comment
luc-blaeser Feb 22, 2023
a22018a
Code refactoring
luc-blaeser Feb 22, 2023
54d0334
Barrier optimization
luc-blaeser Feb 22, 2023
075e579
Bug fix
luc-blaeser Feb 22, 2023
a1dfb7e
Pause tuning
luc-blaeser Feb 22, 2023
6dbaf33
GC tuning
luc-blaeser Feb 22, 2023
5f9b48a
Adjust comment
luc-blaeser Feb 23, 2023
fef39be
Update benchmark
luc-blaeser Feb 23, 2023
fb4fcc0
Adjust test for different stack frame sizes
luc-blaeser Feb 23, 2023
96b1ecb
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Feb 23, 2023
a5eaaf6
Remove forwarding pointer test logic
luc-blaeser Feb 23, 2023
c7caef6
Adjust merge
luc-blaeser Feb 23, 2023
77b9277
Adjust merge with generational GC
luc-blaeser Feb 23, 2023
2d4af15
Remove forwarding pointer sanity check logic
luc-blaeser Feb 23, 2023
b5207df
Merge branch 'luc/forwarding_pointer' into luc/incremental-mark-bitmap
luc-blaeser Feb 23, 2023
7e4c852
Add more forwarding pointer changes
luc-blaeser Feb 23, 2023
7e09745
Merge branch 'luc/forwarding_pointer' into luc/incremental-mark-bitmap
luc-blaeser Feb 23, 2023
ca39a4b
More forwarding pointer changes
luc-blaeser Feb 23, 2023
fac4442
Merge branch 'luc/forwarding_pointer' into luc/incremental-mark-bitmap
luc-blaeser Feb 23, 2023
ec820cc
Adjust format and tests
luc-blaeser Feb 23, 2023
37ceebd
Merge branch 'luc/forwarding_pointer' into luc/incremental-mark-bitmap
luc-blaeser Feb 23, 2023
2e53539
Adjust test result
luc-blaeser Feb 23, 2023
9c86583
Revert unnecessary changes
luc-blaeser Feb 23, 2023
09c81e4
Adjust format
luc-blaeser Feb 23, 2023
19fe816
Reformat
luc-blaeser Feb 23, 2023
f6e31da
Merge branch 'luc/forwarding_pointer' into luc/incremental-mark-bitmap
luc-blaeser Feb 23, 2023
a16f449
Also use memory check mode for generational GC
luc-blaeser Feb 23, 2023
a2bb7c4
Revert change in run
luc-blaeser Feb 23, 2023
d2c18fe
Adjust comments
luc-blaeser Feb 23, 2023
15102e1
Merge branch 'luc/forwarding_pointer' into luc/incremental-mark-bitmap
luc-blaeser Feb 23, 2023
b40f1df
Adjust benchmark results
luc-blaeser Feb 23, 2023
3d6c0f6
Merge branch 'luc/forwarding_pointer' into luc/incremental-mark-bitmap
luc-blaeser Feb 23, 2023
0955b9b
Add missing generational GC ic-ref build
luc-blaeser Feb 23, 2023
831174b
Reenable base test
luc-blaeser Feb 23, 2023
7ec2686
Revert unnecessary changes
luc-blaeser Feb 23, 2023
cb6bb3a
Merge branch 'luc/forwarding_pointer' into luc/incremental-mark-bitmap
luc-blaeser Feb 23, 2023
196686b
Remove incremental GC implementation
luc-blaeser Feb 23, 2023
40ca7ec
Undo unnecessary changes
luc-blaeser Feb 23, 2023
4dba687
Merge branch 'luc/forwarding_pointer' into luc/incremental-mark-bitmap
luc-blaeser Feb 23, 2023
41d5ad4
Merge branch 'luc/incremental-mark-bitmap' into luc/incremental-prepa…
luc-blaeser Feb 23, 2023
536409e
Remove unnecessary changes
luc-blaeser Feb 23, 2023
268db3e
Adjust test results
luc-blaeser Feb 23, 2023
eb412c3
Revert "Remove incremental GC implementation"
luc-blaeser Feb 23, 2023
aede99c
Revert "Remove unnecessary changes"
luc-blaeser Feb 23, 2023
aa68176
Revert "Adjust test results"
luc-blaeser Feb 23, 2023
003bd6b
Temporarily disable base test
luc-blaeser Feb 23, 2023
0f702d3
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Feb 23, 2023
882dfd8
Merge branch 'luc/incremental-preparation' into luc/incremental-mark-…
luc-blaeser Feb 23, 2023
8b4cb08
Reformat
luc-blaeser Feb 23, 2023
cb29278
Merge branch 'luc/incremental-preparation' into luc/incremental-mark-…
luc-blaeser Feb 23, 2023
d5b8d2b
Adjust test result
luc-blaeser Feb 23, 2023
5298a6a
Adjust test result
luc-blaeser Feb 23, 2023
24e5d8c
Adjust test result
luc-blaeser Feb 23, 2023
255065b
Adjust timer tests for slower incremental GC (in `force-gc` mode)
luc-blaeser Feb 24, 2023
c9a5651
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Feb 24, 2023
c4f7be0
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Feb 24, 2023
5e22983
Merge branch 'luc/incremental-preparation' into luc/incremental-mark-…
luc-blaeser Feb 24, 2023
088767c
Make test more stable for generational GC, especially `ic-ref-run`
luc-blaeser Feb 24, 2023
8ab5ee8
Unstable test results for `ic-ref-run` and incremental GC
luc-blaeser Feb 24, 2023
dca97e0
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Feb 24, 2023
39c1b9d
Skip ic-ref-run in timer test
luc-blaeser Feb 24, 2023
f75cce1
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Feb 28, 2023
736be28
Reenable base tests
luc-blaeser Feb 28, 2023
593f4aa
Update rts/motoko-rts/src/stream.rs
luc-blaeser Feb 28, 2023
9b4fe19
Improve comment
luc-blaeser Feb 28, 2023
2f96966
Unify heap base alignment
luc-blaeser Feb 28, 2023
e21907c
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Feb 28, 2023
70f92a4
Resolve merge conflicts
luc-blaeser Feb 28, 2023
e1d1152
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 1, 2023
4655ced
Adjust merge
luc-blaeser Mar 1, 2023
2ed4a94
Adjust test for uniform heap alignment
luc-blaeser Mar 1, 2023
7fd7e97
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Mar 1, 2023
1ac0792
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 1, 2023
3a9520f
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 1, 2023
d30d9c6
Improving code comment
luc-blaeser Mar 1, 2023
88c9972
Adjust comment
luc-blaeser Mar 1, 2023
e63a76d
Merge branch 'luc/forwarding_pointer' of https://github.com/dfinity/m…
luc-blaeser Mar 1, 2023
a0851d7
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 1, 2023
b3c71e3
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 1, 2023
2f88dff
Improve comment and format
luc-blaeser Mar 2, 2023
e7d6d68
Optimization: Progress update on non-sliced array
luc-blaeser Mar 6, 2023
fa4bb32
Bug fix: Consider object moving during allocation increments
luc-blaeser Mar 7, 2023
ebb4bb7
Update benchmark result
luc-blaeser Mar 7, 2023
db9a14e
Switch for disabling force GC in certain tests
luc-blaeser Mar 7, 2023
eec88df
Bug fix: Consider object moving during allocation increments
luc-blaeser Mar 7, 2023
3586dea
Adjust benchmark results
luc-blaeser Mar 7, 2023
a5058ed
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Mar 7, 2023
cf295f4
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 7, 2023
60fdc91
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 7, 2023
d2f5d94
Extra forwarding sanity checks for field accesses
luc-blaeser Mar 7, 2023
7e43553
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 7, 2023
f298706
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 7, 2023
80adc3c
ic-ref-run too slow for some timer tests with incremental GC
luc-blaeser Mar 7, 2023
d91c28c
Correct comment
luc-blaeser Mar 7, 2023
ce0016a
Stricter forward check (to be relaxed on higher PR)
luc-blaeser Mar 7, 2023
27c946c
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 7, 2023
2bf11ce
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 7, 2023
ca7889e
Revert "Stricter forward check (to be relaxed on higher PR)"
luc-blaeser Mar 7, 2023
1b67786
Bug fix in tabulate - and code comments
luc-blaeser Mar 8, 2023
f7f07e5
Rename iterate function
luc-blaeser Mar 8, 2023
e4deedc
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 8, 2023
2d8d787
Update benchmark result
luc-blaeser Mar 8, 2023
ca21038
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 8, 2023
c451d14
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Mar 8, 2023
487a9a3
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 8, 2023
88a41d4
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 8, 2023
0a9e90c
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Mar 10, 2023
96613d2
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 10, 2023
f0317f6
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 10, 2023
1b472d6
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Mar 15, 2023
52fb919
Merge variant optimization for forwarding pointers
luc-blaeser Mar 15, 2023
b57e1b5
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 15, 2023
ec59c3a
Adjust mutbox write for allocation increments
luc-blaeser Mar 15, 2023
b5e8afc
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 15, 2023
fbc98d1
Improve comment
luc-blaeser Mar 17, 2023
fd2c35a
Refactor static write barrier elimination
luc-blaeser Mar 17, 2023
2c0f3e5
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Mar 22, 2023
b176e9c
Squashed commit of the following:
luc-blaeser Mar 22, 2023
8c1a44a
Squashed commit of the following:
luc-blaeser Mar 22, 2023
0e83545
Adjust test run script
luc-blaeser Mar 23, 2023
f830c98
Postpone allocation increment
luc-blaeser Mar 23, 2023
a2465c2
Update benchmark results
luc-blaeser Mar 23, 2023
96995f9
Use the specific GC for drun tests
luc-blaeser Mar 23, 2023
f43b897
Tune the allocation increment factor
luc-blaeser Mar 23, 2023
017b10f
Postpone allocation increments
luc-blaeser Mar 23, 2023
0625fc0
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 23, 2023
9049280
Update benchmark results
luc-blaeser Mar 23, 2023
974b45d
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 23, 2023
d62ea71
Adjust benchmark results
luc-blaeser Mar 23, 2023
4383bff
Squashed commit of the following:
luc-blaeser Mar 23, 2023
12fa14d
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 23, 2023
301b8fe
Adjust benchmark results
luc-blaeser Mar 23, 2023
ed9b1c5
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Mar 28, 2023
8600573
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 28, 2023
ad1fd57
Additional merge changes: Array index refactoring
luc-blaeser Mar 28, 2023
f4a7457
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 28, 2023
52935f0
Use two WASM functions for the forwarding check
luc-blaeser Mar 28, 2023
f037531
Prevent time overflow on large GC increments
luc-blaeser Mar 28, 2023
dd5782b
Refactor allocation barrier
luc-blaeser Mar 28, 2023
7e2d1cc
Refactor allocation barrier
luc-blaeser Mar 28, 2023
22289a7
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 28, 2023
040e909
Reformat
luc-blaeser Mar 28, 2023
1a68b8e
Use two WASM functions for the forwarding check
luc-blaeser Mar 28, 2023
4c9aec3
Update benchmark results
luc-blaeser Mar 28, 2023
4e8e363
Family of shared functions for heap allocation
luc-blaeser Mar 28, 2023
cafb090
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 28, 2023
9497da8
Update benchmark results
luc-blaeser Mar 28, 2023
2c0dcf6
Update benchmark results
luc-blaeser Mar 28, 2023
ff67a78
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 28, 2023
2235319
Protect against an accidental restart of a stopped GC
luc-blaeser Mar 28, 2023
f15dc6d
Add an assertion that the GC is not stopped
luc-blaeser Mar 28, 2023
294db87
Refactor memory initialization
luc-blaeser Mar 28, 2023
f98d3a9
Simplify pre-write barrier
luc-blaeser Mar 29, 2023
d9201cd
Improve mark bitmap iterator
luc-blaeser Mar 29, 2023
a17a170
Adjust comment
luc-blaeser Mar 29, 2023
55b896c
Provide rationale for partition size
luc-blaeser Mar 29, 2023
c710a9e
Provide rationale for survival rate threshold
luc-blaeser Mar 29, 2023
26d0172
Introduce constant for max memory size
luc-blaeser Mar 29, 2023
1e919de
Fix typo
luc-blaeser Mar 30, 2023
c1e54ec
Performance optimization
luc-blaeser Mar 31, 2023
e892f2f
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Mar 31, 2023
b677559
Update benchmark results
luc-blaeser Mar 31, 2023
71a1fc1
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Mar 31, 2023
f83aa3e
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Mar 31, 2023
a3e954d
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Apr 5, 2023
9cfef91
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Apr 5, 2023
a2d849f
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Apr 5, 2023
d39bcd6
Adjust comment
luc-blaeser Apr 5, 2023
0b05f6e
Guarantee progress on time advance
luc-blaeser Apr 5, 2023
5164da3
Improve debug assertion for mark stack
luc-blaeser Apr 5, 2023
d52662c
Simplify large partition lookup
luc-blaeser Apr 5, 2023
2b054c2
Add debug assertion
luc-blaeser Apr 5, 2023
1e05c58
Explain the allocation partition switch
luc-blaeser Apr 5, 2023
b573e01
Simplify collection heuristics
luc-blaeser Apr 5, 2023
51f2a76
Rename the allocation pointer for bitmap
luc-blaeser Apr 5, 2023
b3977d3
Refactoring: Remove superfluous condition
luc-blaeser Apr 5, 2023
15b5c57
Adjust test case
luc-blaeser Apr 5, 2023
6ce31fa
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Apr 6, 2023
5b8683c
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Apr 6, 2023
9899479
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Apr 6, 2023
cec6db1
Correct the variable declaration type
luc-blaeser Apr 6, 2023
564d0d7
Refactoring: Reduce double map into a single map
luc-blaeser Apr 6, 2023
e0cd563
Code refactoring
luc-blaeser Apr 6, 2023
41161eb
Code refactoring
luc-blaeser Apr 6, 2023
eee41e9
Code refactoring
luc-blaeser Apr 6, 2023
15aa49b
Code refactoring
luc-blaeser Apr 6, 2023
9de640f
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Apr 6, 2023
d5549f8
Adjust tests for forwarding pointer
luc-blaeser Apr 6, 2023
4395b48
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Apr 6, 2023
1925d03
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Apr 6, 2023
5bd4da2
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Apr 11, 2023
497baa8
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Apr 11, 2023
d070ab2
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Apr 11, 2023
2937ce3
Fix typo in comment
luc-blaeser Apr 11, 2023
65297d6
Improve comment
luc-blaeser Apr 11, 2023
921c9cb
Improve comment
luc-blaeser Apr 11, 2023
e5cf26a
Improve comment
luc-blaeser Apr 11, 2023
61bab8d
Improve comment
luc-blaeser Apr 11, 2023
f4e7ed6
Fix typo in comment
luc-blaeser Apr 11, 2023
04b0158
Use --force-gc in tests explicitly
luc-blaeser Apr 11, 2023
2f035b7
One more case with `--force-gc`
luc-blaeser Apr 11, 2023
9228bc1
Using a sentinel for empty mark stack
luc-blaeser Apr 11, 2023
80c9a5e
Limit evacuations to available free space
luc-blaeser Apr 12, 2023
59449d5
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Apr 12, 2023
dff7277
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Apr 12, 2023
242b2e4
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Apr 12, 2023
3e6fb1c
review: incremental gc suggestions (#3927)
crusso Apr 12, 2023
20a2dba
Reformat
luc-blaeser Apr 12, 2023
a347d5d
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Apr 12, 2023
9fe83ae
Reformat
luc-blaeser Apr 12, 2023
6cfa3fb
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Apr 12, 2023
cf10be8
Improve comment
luc-blaeser Apr 12, 2023
a6d4c72
Fix units in bitmap iterator
luc-blaeser Apr 12, 2023
72af011
Revert unnecessary changes
luc-blaeser Apr 12, 2023
033c263
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Apr 12, 2023
fd5bc9e
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Apr 12, 2023
58d733c
Reformat
luc-blaeser Apr 12, 2023
6f915ff
Adjust memory check to new mark stack sentinel
luc-blaeser Apr 12, 2023
e1e82d3
Memory check: Invalidate tag in original object
luc-blaeser Apr 12, 2023
687b843
Refactor main incremental GC run function
luc-blaeser Apr 13, 2023
0513c82
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser Apr 13, 2023
47d20ee
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser Apr 13, 2023
e5e2d2f
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser Apr 13, 2023
2a7c11d
Bug fix in RTS test
luc-blaeser Apr 14, 2023
2159789
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser May 1, 2023
910eb1a
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser May 1, 2023
43b2dfa
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser May 1, 2023
01c0f8f
Updating nix hashes
github-actions[bot] May 1, 2023
2e7d7f3
Refactoring: Improve quicksort
luc-blaeser May 1, 2023
442eb15
Adjust tests for different stack size
luc-blaeser May 1, 2023
98dce2c
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser May 1, 2023
c7ba335
Refactoring: Stack size test cases
luc-blaeser May 1, 2023
b680ecc
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser May 1, 2023
e52ae23
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser May 1, 2023
fcb4e94
Revert "Updating nix hashes"
luc-blaeser May 1, 2023
33c14d7
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser May 1, 2023
83cc04e
Use `--force-gc` again by default in tests
luc-blaeser May 4, 2023
09510f7
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser May 4, 2023
ed82364
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser May 4, 2023
4ba783a
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser May 4, 2023
ffb137e
Tuning the GC for the critical heap limit
luc-blaeser May 10, 2023
8d65545
More tuning of the critical GC memory limit
luc-blaeser May 10, 2023
647d517
Merge branch 'master' into luc/forwarding_pointer
luc-blaeser May 10, 2023
0bba417
Merge branch 'luc/forwarding_pointer' into luc/incremental-preparation
luc-blaeser May 10, 2023
97afe73
Merge branch 'luc/incremental-preparation' into luc/incremental-gc
luc-blaeser May 10, 2023
bb76ecf
Use structural equality in OCaml
luc-blaeser May 11, 2023
0457f54
Add GC random test
luc-blaeser May 11, 2023
ce3d393
Prepare `Changelog.md`
luc-blaeser May 11, 2023
cf2f0e0
Document the incremental GC option as beta testing
luc-blaeser May 12, 2023
b1b1e7f
Merge branch 'master' into luc/incremental-gc
luc-blaeser May 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions Changelog.md
@@ -1,5 +1,34 @@
# Motoko compiler changelog

* motoko (`moc`)

* **For beta testing:** Add a new _incremental_ GC, enabled with new moc flag `--incremental-gc` (#3837).
The incremental garbage collector is designed to scale for large program heap sizes.

The GC distributes its workload across multiple steps, called increments, that each pause the mutator
(user's program) for only a limited amount of time. As a result, the GC work can fit within the instruction-limited
IC messages, regardless of the heap size and the object structures.

According to GC benchmark measurements, the incremental GC is more efficient than the existing copying, compacting,
and generational GC in the following regards:
* Scalability: Able to use the full heap space, 3x more object allocations on average.
* Shorter interruptions: The GC pause has a maximum limit that is up to 10x shorter.
* Lower runtimes: The number of executed instructions is reduced by 10% on average (compared to the copying GC).
* Less GC overhead: The amount of GC work in proportion to the user's program work drops by 10-16%.

The GC incurs a moderate memory overhead: The allocated WASM memory has been measured to be 9% higher
on average compared to the copying GC, which is the current default GC.

To activate the incremental GC under `dfx`, the following command-line argument needs to be specified in `dfx.json`:

```
...
"type" : "motoko"
...
"args" : "--incremental-gc"
...
```

## 0.8.8 (2023-05-02)

* motoko (`moc`)
Expand Down
13 changes: 7 additions & 6 deletions default.nix
Expand Up @@ -361,12 +361,7 @@ rec {
(test_subdir dir deps).overrideAttrs (args: {
EXTRA_MOC_ARGS = "--sanity-checks";
});

compacting_gc_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs (args: {
EXTRA_MOC_ARGS = "--compacting-gc";
});


generational_gc_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs (args: {
EXTRA_MOC_ARGS = "--generational-gc";
Expand All @@ -382,6 +377,11 @@ rec {
EXTRA_MOC_ARGS = "--sanity-checks --generational-gc";
});

snty_incremental_gc_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs (args: {
EXTRA_MOC_ARGS = "--sanity-checks --incremental-gc";
});

perf_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs (args: {
checkPhase = ''
Expand Down Expand Up @@ -497,6 +497,7 @@ rec {
drun-dbg = snty_subdir "run-drun" [ moc nixpkgs.drun ];
drun-compacting-gc = snty_compacting_gc_subdir "run-drun" [ moc nixpkgs.drun ] ;
drun-generational-gc = snty_generational_gc_subdir "run-drun" [ moc nixpkgs.drun ] ;
drun-incremental-gc = snty_incremental_gc_subdir "run-drun" [ moc nixpkgs.drun ] ;
fail = test_subdir "fail" [ moc ];
repl = test_subdir "repl" [ moc ];
ld = test_subdir "ld" ([ mo-ld ] ++ ldTestDeps);
Expand Down
1 change: 1 addition & 0 deletions doc/md/compiler-ref.md
Expand Up @@ -34,6 +34,7 @@ You can use the following options with the `moc` command.
| `-help`,`--help` | Displays usage information. |
| `--hide-warnings` | Hides compiler warnings. |
| `-Werror` | Treat warnings as errors. |
| `--incremental-gc` | Use incremental GC (only for beta-testing) |
| `--idl` | Compile binary and emit Candid IDL specification to `.did` file. |
| `-i` | Runs the compiler in an interactive read–eval–print loop (REPL) shell so you can evaluate program execution (implies -r). |
| `--map` | Outputs a JavaScript source map. |
Expand Down
187 changes: 138 additions & 49 deletions rts/motoko-rts-tests/src/gc.rs
Expand Up @@ -8,24 +8,32 @@
mod compacting;
mod generational;
mod heap;
mod incremental;
mod random;
mod utils;

use heap::MotokoHeap;
use motoko_rts::gc::generational::remembered_set::RememberedSet;
use motoko_rts::gc::generational::write_barrier::{LAST_HP, REMEMBERED_SET};
use utils::{get_scalar_value, read_word, unskew_pointer, ObjectIdx, GC, GC_IMPLS, WORD_SIZE};
use motoko_rts::gc::incremental::partitioned_heap::PARTITION_SIZE;
use motoko_rts::gc::incremental::{
get_partitioned_heap, incremental_gc_state, reset_partitioned_heap,
};
use utils::{
get_scalar_value, make_pointer, read_word, unskew_pointer, ObjectIdx, GC, GC_IMPLS, WORD_SIZE,
};

use motoko_rts::gc::copying::copying_gc_internal;
use motoko_rts::gc::generational::{GenerationalGC, Limits, Roots, Strategy};
use motoko_rts::gc::generational::{GenerationalGC, Strategy};
use motoko_rts::gc::incremental::IncrementalGC;
use motoko_rts::gc::mark_compact::compacting_gc_internal;
use motoko_rts::types::*;

use std::fmt::Write;

use fxhash::{FxHashMap, FxHashSet};

use crate::gc::utils::make_pointer;
use crate::memory::TestMemory;

pub fn test() {
println!("Testing garbage collection ...");
Expand All @@ -46,6 +54,7 @@ pub fn test() {

compacting::test();
generational::test();
incremental::test();
}

fn test_heaps() -> Vec<TestHeap> {
Expand Down Expand Up @@ -107,6 +116,7 @@ fn test_gcs(heap_descr: &TestHeap) {
&heap_descr.continuation_table,
);
}
reset_incremental_gc();
}

fn test_gc(
Expand All @@ -116,7 +126,7 @@ fn test_gc(
continuation_table: &[ObjectIdx],
) {
let mut heap = MotokoHeap::new(refs, roots, continuation_table, gc);

initialize_gc_state(&mut heap, gc);
// Check `create_dynamic_heap` sanity
check_dynamic_heap(
false, // before gc
Expand All @@ -127,6 +137,7 @@ fn test_gc(
heap.heap_base_offset(),
heap.heap_ptr_offset(),
heap.continuation_table_ptr_offset(),
false,
);

for round in 0..3 {
Expand All @@ -136,18 +147,46 @@ fn test_gc(
let heap_ptr_offset = heap.heap_ptr_offset();
let continuation_table_ptr_offset = heap.continuation_table_ptr_offset();
check_dynamic_heap(
check_all_reclaimed, // after gc
check_all_reclaimed, // check for unreachable objects
refs,
roots,
continuation_table,
&**heap.heap(),
heap_base_offset,
heap_ptr_offset,
continuation_table_ptr_offset,
gc == GC::Incremental,
);
}
}

fn initialize_gc_state(heap: &mut MotokoHeap, gc: GC) {
unsafe {
match gc {
GC::Incremental => initialize_incremental_gc(heap),
_ => reset_partitioned_heap(),
}
}
}

unsafe fn initialize_incremental_gc(heap: &mut MotokoHeap) {
IncrementalGC::initialize(heap, heap.heap_base_address());
let allocation_size = heap.heap_ptr_address() - heap.heap_base_address();

// Synchronize the partitioned heap with one big combined allocation by starting from the base pointer as the heap pointer.
let result = get_partitioned_heap().allocate(heap, Bytes(allocation_size as u32).to_words());
// Check that the heap pointer (here equals base pointer) is unchanged, i.e. no partition switch has happened.
// This is a restriction in the unit test where `MotokoHeap` only supports contiguous bump allocation during initialization.
assert_eq!(result.get_ptr(), heap.heap_base_address());
}

fn reset_incremental_gc() {
let mut memory = TestMemory::new(Words(PARTITION_SIZE as u32));
unsafe {
IncrementalGC::initialize(&mut memory, 0);
}
}

/// Check the dynamic heap:
///
/// - All (and in post-gc mode, only) reachable objects should be in the heap. Reachable objects
Expand All @@ -166,6 +205,7 @@ fn check_dynamic_heap(
heap_base_offset: usize,
heap_ptr_offset: usize,
continuation_table_ptr_offset: usize,
incremental: bool,
) {
let objects_map: FxHashMap<ObjectIdx, &[ObjectIdx]> = objects
.iter()
Expand Down Expand Up @@ -198,52 +238,88 @@ fn check_dynamic_heap(
let tag = read_word(heap, offset);
offset += WORD_SIZE;

assert_eq!(tag, TAG_ARRAY);

let forward = read_word(heap, offset);
offset += WORD_SIZE;

assert_eq!(forward, make_pointer(address as u32));

let n_fields = read_word(heap, offset);
offset += WORD_SIZE;
if tag == TAG_ONE_WORD_FILLER {
assert!(incremental);
} else if tag == TAG_FREE_SPACE {
assert!(incremental);
let words = read_word(heap, offset) as usize;
offset += WORD_SIZE;
offset += words * WORD_SIZE;
} else {
let forward = read_word(heap, offset);
offset += WORD_SIZE;

// There should be at least one field for the index
assert!(n_fields >= 1);
let is_forwarded = forward != make_pointer(address as u32);

if incremental && tag == TAG_BLOB {
assert!(!is_forwarded);
// in-heap mark stack blobs
let length = read_word(heap, offset);
offset += WORD_SIZE + length as usize;
} else {
if incremental {
assert!(tag == TAG_ARRAY || tag >= TAG_ARRAY_SLICE_MIN);
} else {
assert_eq!(tag, TAG_ARRAY);
}

let object_idx = get_scalar_value(read_word(heap, offset));
offset += WORD_SIZE;
let old = seen.insert(object_idx, address);
if let Some(old) = old {
panic!(
"Object with index {} seen multiple times: {:#x}, {:#x}",
object_idx, old, address
);
}
if is_forwarded {
assert!(incremental);

let object_expected_pointees = objects_map.get(&object_idx).unwrap_or_else(|| {
panic!("Object with index {} is not in the objects map", object_idx)
});
let forward_offset = forward as usize - heap.as_ptr() as usize;
let length = read_word(
heap,
forward_offset + size_of::<Obj>().to_bytes().as_usize(),
);

for field_idx in 1..n_fields {
let field = read_word(heap, offset);
offset += WORD_SIZE;
// Get index of the object pointed by the field
let pointee_address = field.wrapping_add(1); // unskew
let pointee_offset = (pointee_address as usize) - (heap.as_ptr() as usize);
let pointee_idx_offset =
pointee_offset as usize + size_of::<Array>().to_bytes().as_usize(); // skip array header (incl. length)
let pointee_idx = get_scalar_value(read_word(heap, pointee_idx_offset));
let expected_pointee_idx = object_expected_pointees[(field_idx - 1) as usize];
assert_eq!(
pointee_idx,
expected_pointee_idx,
"Object with index {} points to {} in field {}, but expected to point to {}",
object_idx,
pointee_idx,
field_idx - 1,
expected_pointee_idx,
);
// Skip stale object version that has been relocated during incremental GC.
offset += length as usize * WORD_SIZE;
} else {
let n_fields = read_word(heap, offset);
offset += WORD_SIZE;

// There should be at least one field for the index
assert!(n_fields >= 1);

let object_idx = get_scalar_value(read_word(heap, offset));
offset += WORD_SIZE;

let old = seen.insert(object_idx, address);
if let Some(old) = old {
panic!(
"Object with index {} seen multiple times: {:#x}, {:#x}",
object_idx, old, address
);
}

let object_expected_pointees =
objects_map.get(&object_idx).unwrap_or_else(|| {
panic!("Object with index {} is not in the objects map", object_idx)
});

for field_idx in 1..n_fields {
let field = read_word(heap, offset);
offset += WORD_SIZE;
// Get index of the object pointed by the field
let pointee_address = field.wrapping_add(1); // unskew
let pointee_offset = (pointee_address as usize) - (heap.as_ptr() as usize);
let pointee_idx_offset =
pointee_offset as usize + size_of::<Array>().to_bytes().as_usize(); // skip array header (incl. length)
let pointee_idx = get_scalar_value(read_word(heap, pointee_idx_offset));
let expected_pointee_idx =
object_expected_pointees[(field_idx - 1) as usize];
assert_eq!(
pointee_idx,
expected_pointee_idx,
"Object with index {} points to {} in field {}, but expected to point to {}",
object_idx,
pointee_idx,
field_idx - 1,
expected_pointee_idx,
);
}
}
}
}
}

Expand Down Expand Up @@ -406,12 +482,12 @@ impl GC {
REMEMBERED_SET = Some(RememberedSet::new(heap));
LAST_HP = heap_1.last_ptr_address() as u32;

let limits = Limits {
let limits = motoko_rts::gc::generational::Limits {
base: heap_base as usize,
last_free: heap_1.last_ptr_address(),
free: heap_1.heap_ptr_address(),
};
let roots = Roots {
let roots = motoko_rts::gc::generational::Roots {
static_roots,
continuation_table_ptr_loc: continuation_table_ptr_address,
};
Expand All @@ -428,6 +504,19 @@ impl GC {
}
round >= 2
}

GC::Incremental => unsafe {
const INCREMENTS_UNTIL_COMPLETION: usize = 16;
for _ in 0..INCREMENTS_UNTIL_COMPLETION {
let roots = motoko_rts::gc::incremental::roots::Roots {
static_roots,
continuation_table_location: continuation_table_ptr_address,
};
IncrementalGC::instance(heap, incremental_gc_state())
.empty_call_stack_increment(roots);
}
false
},
}
}
}