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

bug: repro for graph copy bug #4540

Open
wants to merge 762 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
762 commits
Select commit Hold shift + click to select a range
673b7c2
Manual merge conflict resolution
luc-blaeser Dec 15, 2023
9d6cd0f
Manual merge conflict resolution
luc-blaeser Dec 15, 2023
f36196a
Remove non-incremental GC test options
luc-blaeser Dec 15, 2023
874e920
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Dec 15, 2023
198b8d2
Merge branch 'master' into luc/graph-copy
luc-blaeser Dec 15, 2023
4ff7dc0
Drop content of destabilized `Any`-typed actor field
luc-blaeser Dec 18, 2023
704ae2e
Refactor `is_primitive_type` in Candid parser and subtype check
luc-blaeser Dec 19, 2023
aaf193f
Do not use the cache for the main actor type compatibility check
luc-blaeser Dec 19, 2023
1de669b
Update benchmark results
luc-blaeser Dec 19, 2023
51d5242
Drop content of destabilized `Any`-typed actor field
luc-blaeser Dec 19, 2023
ec54297
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Dec 19, 2023
9e4287c
Manual merge: Adjust test
luc-blaeser Dec 19, 2023
911e3d7
Refactor `is_primitive_type` in Candid parser and subtype check
luc-blaeser Dec 19, 2023
3981a91
Do not use the cache for the main actor type compatibility check
luc-blaeser Dec 19, 2023
0ca9ce3
Update benchmark results
luc-blaeser Dec 19, 2023
113f1fa
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Dec 19, 2023
e8986b3
Adjust comment
luc-blaeser Dec 19, 2023
c455a11
Merge branch 'master' into luc/stable-heap
luc-blaeser Dec 19, 2023
dd095e9
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Dec 19, 2023
665629c
Increase chunk size for stable memory clearing
luc-blaeser Dec 19, 2023
b584dad
Custom bigint serialization
luc-blaeser Dec 20, 2023
2f3af19
Update benchmark results
luc-blaeser Dec 20, 2023
1e22eff
Update documentation
luc-blaeser Dec 20, 2023
eaa514e
Update documentation
luc-blaeser Dec 20, 2023
69cb014
Optimize array deserialization
luc-blaeser Dec 20, 2023
d737ce4
Update benchmark results
luc-blaeser Dec 20, 2023
291603b
Code refactoring of upgrade version checks
luc-blaeser Dec 20, 2023
c77355e
Remove redundant math functions
luc-blaeser Dec 20, 2023
0fe3926
Eliminate size redundancy in the `Object` header
luc-blaeser Dec 20, 2023
f75bb76
Also adjust the `Object` header in the compiler
luc-blaeser Dec 20, 2023
28aac93
Revert "Also adjust the `Object` header in the compiler"
luc-blaeser Dec 20, 2023
dcc1c5f
Revert "Eliminate size redundancy in the `Object` header"
luc-blaeser Dec 20, 2023
d6daf39
Eliminate redundant size field in `Object` header
luc-blaeser Dec 20, 2023
a02e9de
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Dec 20, 2023
acce2ff
Merge branch 'master' into luc/stable-heap
luc-blaeser Dec 20, 2023
dcb4fca
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Dec 20, 2023
a9aae27
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Dec 20, 2023
f0f1e10
Merge branch 'master' into luc/graph-copy
luc-blaeser Dec 20, 2023
3e24296
Merge branch 'master' into luc/stable-heap
luc-blaeser Dec 21, 2023
9698f31
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Dec 21, 2023
97590a1
Update base library dependency
luc-blaeser Dec 21, 2023
1bcfa80
Merge branch 'master' into luc/graph-copy
luc-blaeser Dec 21, 2023
fd5126d
Record the upgrade instruction costs
luc-blaeser Dec 21, 2023
a7d1cb5
Update tests for new `Prim.rts_upgrade_instructions()` function
luc-blaeser Dec 21, 2023
bc06ed9
Make test more ergonomic
luc-blaeser Dec 21, 2023
a613365
Record the upgrade instruction costs
luc-blaeser Dec 21, 2023
d01f039
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Dec 21, 2023
c92f870
Manual merge conflict resolution
luc-blaeser Dec 21, 2023
193a684
Update IC dependency
luc-blaeser Jan 4, 2024
eeceffc
Merge branch 'master' into luc/stable-heap
luc-blaeser Jan 4, 2024
e8fe7d8
Updating nix hashes
github-actions[bot] Jan 4, 2024
b85c1fa
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Jan 4, 2024
ee01e06
Updating nix hashes
github-actions[bot] Jan 4, 2024
1e2e35d
Update IC dependency
luc-blaeser Jan 9, 2024
55216e2
Merge branch 'master' into luc/stable-heap
luc-blaeser Jan 9, 2024
b4b2076
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Jan 9, 2024
588ebb1
Merge branch 'master' into luc/graph-copy
luc-blaeser Jan 17, 2024
7cf5e2f
Incremental Graph-Copy-Based Upgrades (#4361)
crusso Feb 2, 2024
5d8ea66
Merge branch 'master' into luc/graph-copy
luc-blaeser Feb 2, 2024
bf3e05b
Merge branch 'master' into luc/stable-heap
luc-blaeser Feb 2, 2024
554406b
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Feb 2, 2024
4301053
Limit array length because of optimized array iterator
luc-blaeser Feb 8, 2024
c58ed1a
Code refactoring
luc-blaeser Feb 8, 2024
4644555
Update benchmark results
luc-blaeser Feb 8, 2024
be54eca
Merge branch 'master' into luc/stable-heap
luc-blaeser Feb 13, 2024
eb41b07
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Feb 13, 2024
e39a125
Update motoko base dependency
luc-blaeser Feb 13, 2024
759747f
Merge branch 'master' into luc/graph-copy
luc-blaeser Feb 13, 2024
1e83095
Enhanced Orthogonal Persistence: Use Passive Data Segments (32-Bit) (…
luc-blaeser Feb 22, 2024
ef2e8a5
Update IC dependency
luc-blaeser Feb 22, 2024
5a252ce
Enhanced Orthogonal Persistence: Use Passive Data Segments (64-Bit) (…
luc-blaeser Feb 22, 2024
38b1ef8
Update IC dependency
luc-blaeser Feb 22, 2024
d8f7f04
Merge Preparation: Precise Tagging + Enhanced Orthogonal Persistence …
luc-blaeser Feb 29, 2024
7996b86
Merge Preparation: Precise Tagging + Enhanced Orthogonal Persistence …
luc-blaeser Feb 29, 2024
5c6cb9d
Merge branch 'master' into luc/stable-heap
luc-blaeser Feb 29, 2024
ef69565
Merge branch 'master' into luc/stable-heap
luc-blaeser Feb 29, 2024
ba4facc
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Feb 29, 2024
c0d3d6a
Manual merge conflict resolution
luc-blaeser Feb 29, 2024
1aa3cd2
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 8, 2024
b6191d9
Update Motoko base depedency
luc-blaeser Mar 8, 2024
1480f65
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Mar 8, 2024
3e43218
Distinguish tuple type in memory compatibility check
luc-blaeser Sep 28, 2023
d5bc0b8
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Mar 11, 2024
6b188e6
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 11, 2024
bb8e7d7
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Mar 11, 2024
181f1cb
Manual merge conflict resolution
luc-blaeser Mar 11, 2024
affc532
Manual merge conflict resolution
luc-blaeser Mar 11, 2024
a31a11f
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Mar 11, 2024
fa85e2b
Adjust to new upgrade option
luc-blaeser Mar 12, 2024
743b9af
Update IC dependency
luc-blaeser Mar 13, 2024
87dfbb7
Adjust expected test result
luc-blaeser Mar 13, 2024
c500dd2
Optimize null pointer
luc-blaeser Mar 15, 2024
07c42db
Downsize test case
luc-blaeser Mar 15, 2024
c24994a
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 15, 2024
9f96c71
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Mar 15, 2024
6421a24
Manual merge conflict resolution
luc-blaeser Mar 15, 2024
94e5257
Optimization: Enhanced Orthogonal Persistence with Object Pooling (#4…
luc-blaeser Mar 20, 2024
6fec30a
Optimization: Object Pooling for Enhanced Orthogonal Persistence (#4465)
luc-blaeser Mar 20, 2024
0067284
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 20, 2024
da19f25
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Mar 20, 2024
4ac71ba
Merge branch 'master' into luc/graph-copy
luc-blaeser Mar 21, 2024
432d986
Merge branch 'luc/stable-heap64' into luc/graph-copy
luc-blaeser Mar 22, 2024
7760866
Manual merge conflict resolution (work in progress)
luc-blaeser Mar 22, 2024
c11dee2
Adjust tests, resolve some merge bugs
luc-blaeser Mar 22, 2024
5f8471b
Adjust RTS test case
luc-blaeser Mar 22, 2024
90a7d65
Make RTS tests run again
luc-blaeser Mar 22, 2024
d1c9ed1
Add missing function export
luc-blaeser Mar 25, 2024
847940f
Adjust imports, manual merge conflict resolution
luc-blaeser Mar 25, 2024
5437764
Manual merge conflict resolution
luc-blaeser Mar 25, 2024
b3d5429
Manual merge conflict resolution
luc-blaeser Mar 25, 2024
c538366
Adjust persistence initialization
luc-blaeser Mar 25, 2024
c1a6401
Adjust persistence version management
luc-blaeser Mar 25, 2024
f28d7d8
Adjust stable memory metadata for enhanced orthogonal persistence
luc-blaeser Mar 25, 2024
c3f1b56
Adjust stable memory metadata for enhanced orthogonal persistence
luc-blaeser Mar 25, 2024
7c8987b
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 25, 2024
e1237ac
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Mar 25, 2024
ea719c4
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Mar 25, 2024
f72a97e
Add comment
luc-blaeser Mar 25, 2024
6a4b908
Adjust graph stabilization initialization
luc-blaeser Mar 25, 2024
7e6e72c
Adjust GC mode during destabilization
luc-blaeser Mar 25, 2024
747a2d7
Adjust object visitor for graph destabilization
luc-blaeser Mar 25, 2024
5cdd47c
Adjust incremental graph destabilization
luc-blaeser Mar 25, 2024
62b9fc8
Adjust error message
luc-blaeser Mar 25, 2024
e73dcb6
Adjust tests
luc-blaeser Mar 25, 2024
b977eec
Adjust tests
luc-blaeser Mar 25, 2024
c43d679
Update benchmark results
luc-blaeser Mar 25, 2024
279596b
Adjust test
luc-blaeser Mar 25, 2024
41bfcf3
Upgrade stable memory version after graph destabilization
luc-blaeser Mar 26, 2024
6cc347d
Adjust memory sanity check
luc-blaeser Mar 26, 2024
2545f37
Clear memory on graph destabilization as first step
luc-blaeser Mar 26, 2024
7ada856
Adjust big int serialization for 64-bit
luc-blaeser Mar 26, 2024
3e0a634
Fix: Clear memory on graph destabilization
luc-blaeser Mar 26, 2024
1f214c9
Add test case for graph stabilization
luc-blaeser Mar 26, 2024
b1c548f
Add test case for incremental graph stabilization
luc-blaeser Mar 26, 2024
0c82a96
Add tests for graph stabilization
luc-blaeser Mar 26, 2024
d6ea08c
Add more tests for graph stabilization
luc-blaeser Mar 26, 2024
b0588d2
Add more test cases for graph stabilization
luc-blaeser Mar 26, 2024
43811de
Add more test cases for graph stabilization
luc-blaeser Mar 26, 2024
7c37b9f
More conservative persistence version check
luc-blaeser Mar 26, 2024
bad7d14
Adjust expected test results
luc-blaeser Mar 26, 2024
fa6f122
Adjust test
luc-blaeser Mar 26, 2024
32f922d
Adjust tests
luc-blaeser Mar 26, 2024
e2ff569
Adjust tests
luc-blaeser Mar 26, 2024
8c04c41
Adjust RTS test for stabilization
luc-blaeser Mar 27, 2024
93ab664
Adjust tests
luc-blaeser Mar 27, 2024
db08f50
Adjust test results
luc-blaeser Mar 27, 2024
ea702bf
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 27, 2024
a55e541
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Mar 27, 2024
4f6519b
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Mar 27, 2024
99e57a3
Remove unwanted binary files
luc-blaeser Mar 28, 2024
588204f
Update .gitignore
luc-blaeser Mar 28, 2024
9be3553
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Mar 28, 2024
ed22258
Adjust comment
luc-blaeser Mar 28, 2024
9e3dd6d
Code refactoring
luc-blaeser Mar 28, 2024
4e628b3
Enhanced Orthogonal Persistence: Refactor 64-bit Port of SLEB128 for …
luc-blaeser Apr 5, 2024
f6abef5
Merge branch 'master' into luc/stable-heap
luc-blaeser Apr 5, 2024
5f975ba
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 5, 2024
0ad0068
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 5, 2024
df3c8a3
Upgrade IC dependency
luc-blaeser Apr 8, 2024
09c00cb
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 8, 2024
b2b28e8
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 8, 2024
0e0227e
Undo temporary change in GitHub workflow
luc-blaeser Apr 9, 2024
bdaa979
Update design/OrthogonalPersistence.md
luc-blaeser Apr 9, 2024
524f996
Adjust sentinel value for static roots
luc-blaeser Apr 9, 2024
f81edb7
Remove obsolete comment
luc-blaeser Apr 9, 2024
7739fd6
Remove redundant IDL parsing case
luc-blaeser Apr 9, 2024
e98774b
Optimize global type table blob loads
luc-blaeser Apr 9, 2024
b34d4ce
Remove unclear comment
luc-blaeser Apr 9, 2024
e7861e7
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 10, 2024
aeb7aee
Adjust data segment loading
luc-blaeser Apr 10, 2024
5b99095
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 10, 2024
f924ec8
Update rts/motoko-rts/src/persistence/compatibility.rs
luc-blaeser Apr 10, 2024
0101f0d
Side-effect-free constant function equality check
luc-blaeser Apr 10, 2024
d3c4ef4
Merge branch 'luc/stable-heap' of https://github.com/dfinity/motoko i…
luc-blaeser Apr 10, 2024
a4ff2e2
Enhanced Orthogonal Persistence: Optimize Nested Shared Objects (#4492)
luc-blaeser Apr 11, 2024
8b68dad
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 11, 2024
0e43a20
Manual merge conflict resolution
luc-blaeser Apr 11, 2024
63d5818
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 11, 2024
38878fd
Code refactoring: Constant blobs
luc-blaeser Apr 11, 2024
4cc4b56
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 11, 2024
69f5025
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 11, 2024
03f1e89
Format adjustment
luc-blaeser Apr 11, 2024
af1e6c9
Update src/codegen/compile.ml
luc-blaeser Apr 11, 2024
787b574
Move "object pool frozen" safety check
luc-blaeser Apr 11, 2024
060312b
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 11, 2024
f905718
Manual merge conflict resolution
luc-blaeser Apr 11, 2024
ae9e0e2
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 11, 2024
3d52046
Code Refactoring: Getting rid of `Stream` interface.
luc-blaeser Apr 11, 2024
811a9b6
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 11, 2024
0808ebd
Manual merge conflict resolution
luc-blaeser Apr 11, 2024
21bd33a
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 11, 2024
2c6875c
Handle all cases on constant equality
luc-blaeser Apr 11, 2024
16f5ef1
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 11, 2024
94bf7ae
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 11, 2024
24cfff4
Refactor null comparison
luc-blaeser Apr 11, 2024
7912b94
Adding upgrade option with explicit control of memory persistence
luc-blaeser Apr 11, 2024
b84d3ae
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 11, 2024
f3c3af2
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 11, 2024
1426277
Fix merge mistake
luc-blaeser Apr 11, 2024
c7bcf45
Update benchmark results
luc-blaeser Apr 11, 2024
d5b4d1d
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 11, 2024
0231575
Adjust test
luc-blaeser Apr 11, 2024
7d71daf
Bug fix: Enforce invariance for mutable objects, variants, and services
luc-blaeser Apr 12, 2024
66abe49
Refine test case
luc-blaeser Apr 12, 2024
695b3ef
Refine test case
luc-blaeser Apr 12, 2024
932f650
Adding some explanatory comments to test case
luc-blaeser Apr 12, 2024
0af485e
experiment: remove regression in idl_sub (#4497)
crusso Apr 12, 2024
c80e7a0
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 12, 2024
884645f
Manual merge conflict resolution
luc-blaeser Apr 12, 2024
a434984
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 12, 2024
60f4f96
Manual merge conflict resolution
luc-blaeser Apr 12, 2024
625052f
Add test cases
luc-blaeser Apr 12, 2024
87c1a52
Merge branch 'master' into luc/stable-heap
luc-blaeser Apr 12, 2024
3d4fd4d
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser Apr 12, 2024
502c4a2
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 12, 2024
9ff46f5
Merge branch 'master' into luc/stable-heap
luc-blaeser May 3, 2024
4ac623d
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser May 3, 2024
753914d
Update Motoko base dependency
luc-blaeser May 3, 2024
1099098
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 3, 2024
0efcfd5
Simplify memory compatibility check
luc-blaeser May 3, 2024
beb54ab
Refine documentation for actor field mutability variance
luc-blaeser May 3, 2024
2ed5e03
Add safety guard for temporary pointers during IDL deserialization
luc-blaeser May 3, 2024
cbc4908
Update benchmark results
luc-blaeser May 3, 2024
e319e22
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser May 3, 2024
ed6362f
Manual merge conflict resolution
luc-blaeser May 3, 2024
60a53a7
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 3, 2024
38cb834
Apply the expected shift distance
luc-blaeser May 3, 2024
dd0fa8b
Remove redundant code
luc-blaeser May 3, 2024
ab27dc7
Code refactoring: Move constant
luc-blaeser May 3, 2024
665e726
Add a debug assertion
luc-blaeser May 3, 2024
64fcb47
Code refactoring: Reduce code difference
luc-blaeser May 3, 2024
4900f29
Update comment
luc-blaeser May 10, 2024
5a680e0
Represent function indices as `i32`
luc-blaeser May 10, 2024
b15c54a
Use pointer compression on Candid destabilization
luc-blaeser May 14, 2024
6d7fe43
Detect persistence mode
luc-blaeser May 14, 2024
24e6f03
Code refactoring
luc-blaeser May 14, 2024
2b53fe0
Merge branch 'master' into luc/stable-heap
luc-blaeser May 14, 2024
6f87078
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser May 14, 2024
0ffdd07
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 14, 2024
a0f243e
Manual merge conflict resolution
luc-blaeser May 14, 2024
db2536e
Add WASI support when detecting persistence version
luc-blaeser May 14, 2024
9bd6537
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser May 14, 2024
7262c4f
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 14, 2024
f0d78ec
Support Wasi mode without stable memory support
luc-blaeser May 14, 2024
034a40b
Merge branch 'luc/stable-heap' into luc/stable-heap64
luc-blaeser May 14, 2024
a3aff8d
Manual merge conflict resolution
luc-blaeser May 14, 2024
2cd38f2
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 14, 2024
ec633e3
Fix test case
luc-blaeser May 14, 2024
ba5b26d
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 14, 2024
b1fa5a0
bug repro for bad use of virtual stablemem_grow
crusso May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 3 additions & 5 deletions bin/wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare -A envs # list of expected environment variables with paths to products
# Define build products here
real[moc]=src/moc
hint[moc]="make -C $rel_root/src moc"
envs[moc]="MOC_NON_INCREMENTAL_RELEASE_RTS MOC_NON_INCREMENTAL_DEBUG_RTS MOC_INCREMENTAL_RELEASE_RTS MOC_INCREMENTAL_DEBUG_RTS"
envs[moc]="MOC_RELEASE_RTS MOC_DEBUG_RTS"
real[mo-ld]=src/mo-ld
hint[mo-ld]="make -C $rel_root/src mo-ld"
real[mo-doc]=src/mo-doc
Expand All @@ -32,10 +32,8 @@ hint[candid-tests]="make -C $rel_root/src candid-tests"

rts_hint="make -C $rel_root/rts"

real[MOC_NON_INCREMENTAL_RELEASE_RTS]=rts/mo-rts.wasm
real[MOC_NON_INCREMENTAL_DEBUG_RTS]=rts/mo-rts-debug.wasm
real[MOC_INCREMENTAL_RELEASE_RTS]=rts/mo-rts-incremental.wasm
real[MOC_INCREMENTAL_DEBUG_RTS]=rts/mo-rts-incremental-debug.wasm
real[MOC_RELEASE_RTS]=rts/mo-rts.wasm
real[MOC_DEBUG_RTS]=rts/mo-rts-debug.wasm

for var in ${envs[moc]}; do
hint[$var]=$rts_hint
Expand Down
87 changes: 32 additions & 55 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ let ic-ref-run =
cp ${ic-hs-pkgs.ic-hs}/bin/ic-ref-run $out/bin
''; in

let
nixos-unstable = import nixpkgs.sources.nixpkgs-unstable {};
in

let haskellPackages = nixpkgs.haskellPackages.override {
overrides = import nix/haskell-packages.nix nixpkgs subpath;
}; in
Expand All @@ -35,6 +39,7 @@ let
wasmtime
rust-bindgen
python3
nixos-unstable.emscripten
] ++ pkgs.lib.optional pkgs.stdenv.isDarwin [
libiconv
];
Expand Down Expand Up @@ -193,7 +198,7 @@ rec {
name = "motoko-rts-deps";
src = subpath ./rts;
sourceRoot = "rts/motoko-rts-tests";
sha256 = "sha256-jN5nx5UNBHlYKnC0kk90h6mWPUNrqPS7Wln2TixbGgA=";
sha256 = "sha256-YEw2AFi15JVKP7owsPDoBT3qSegOO90FRn2qoUBAICw=";
copyLockfile = true;
};

Expand Down Expand Up @@ -241,6 +246,7 @@ rec {
"directory" = "$(stripHash ${allDeps})"
__END__


${llvmEnv}
export TOMMATHSRC=${nixpkgs.sources.libtommath}
export MUSLSRC=${nixpkgs.sources.musl-wasi}/libc-top-half/musl
Expand All @@ -257,8 +263,6 @@ rec {
mkdir -p $out/rts
cp mo-rts.wasm $out/rts
cp mo-rts-debug.wasm $out/rts
cp mo-rts-incremental.wasm $out/rts
cp mo-rts-incremental-debug.wasm $out/rts
'';

# This needs to be self-contained. Remove mention of nix path in debug
Expand All @@ -269,11 +273,6 @@ rec {
-t ${rtsDeps} \
-t ${rustStdDeps} \
$out/rts/mo-rts.wasm $out/rts/mo-rts-debug.wasm
remove-references-to \
-t ${nixpkgs.rustc-nightly} \
-t ${rtsDeps} \
-t ${rustStdDeps} \
$out/rts/mo-rts-incremental.wasm $out/rts/mo-rts-incremental-debug.wasm
'';

allowedRequisites = [];
Expand Down Expand Up @@ -363,26 +362,6 @@ rec {
(test_subdir dir deps).overrideAttrs {
EXTRA_MOC_ARGS = "--sanity-checks";
};

generational_gc_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs {
EXTRA_MOC_ARGS = "--generational-gc";
};

snty_compacting_gc_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs {
EXTRA_MOC_ARGS = "--sanity-checks --compacting-gc";
};

snty_generational_gc_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs {
EXTRA_MOC_ARGS = "--sanity-checks --generational-gc";
};

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

perf_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs (args: {
Expand Down Expand Up @@ -442,23 +421,24 @@ rec {
'';
};

profiling-graphs = testDerivation {
src = test_src "perf";
buildInputs =
(with nixpkgs; [ perl wabt wasm-profiler-instrument wasm-profiler-postproc flamegraph-bin ]) ++
[ moc nixpkgs.drun ];
checkPhase = ''
patchShebangs .
type -p moc && moc --version
type -p drun && drun --help
./profile-report.sh
'';
installPhase = ''
mv _profile $out;
mkdir -p $out/nix-support
echo "report flamegraphs $out index.html" >> $out/nix-support/hydra-build-products
'';
};
# wasm-profiler is not compatible with passive data segments and memory64
# profiling-graphs = testDerivation {
# src = test_src "perf";
# buildInputs =
# (with nixpkgs; [ perl wabt wasm-profiler-instrument wasm-profiler-postproc flamegraph-bin ]) ++
# [ moc nixpkgs.drun ];
# checkPhase = ''
# patchShebangs .
# type -p moc && moc --version
# type -p drun && drun --help
# ./profile-report.sh
# '';
# installPhase = ''
# mv _profile $out;
# mkdir -p $out/nix-support
# echo "report flamegraphs $out index.html" >> $out/nix-support/hydra-build-products
# '';
#};


fix_names = builtins.mapAttrs (name: deriv:
Expand Down Expand Up @@ -497,9 +477,6 @@ rec {
# ic-ref-run = test_subdir "run-drun" [ moc ic-ref-run ];
drun = test_subdir "run-drun" [ moc nixpkgs.drun ];
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 All @@ -510,7 +487,8 @@ rec {
perf = perf_subdir "perf" [ moc nixpkgs.drun ];
bench = perf_subdir "bench" [ moc nixpkgs.drun ic-wasm ];
# viper = test_subdir "viper" [ moc nixpkgs.which nixpkgs.openjdk nixpkgs.z3 ];
inherit qc lsp unit candid profiling-graphs coverage;
# TODO: profiling-graph is excluded because the underlying partity_wasm is deprecated and does not support passive data segments and memory64.
inherit qc lsp unit candid coverage;
}) // { recurseForDerivations = true; };

samples = stdenv.mkDerivation {
Expand Down Expand Up @@ -554,7 +532,7 @@ rec {
doInstallCheck = true;
test = ./test + "/test-${n}.js";
installCheckPhase = ''
NODE_PATH=$out/bin node $test
NODE_PATH=$out/bin node --experimental-wasm-memory64 $test
'';
};
in
Expand Down Expand Up @@ -702,15 +680,13 @@ EOF
mkdir -p $out
ln -s ${base-doc} $out/base-doc
ln -s ${docs} $out/docs
ln -s ${tests.profiling-graphs} $out/flamegraphs
ln -s ${tests.coverage} $out/coverage
cd $out;
# generate a simple index.html, listing the entry points
( echo docs/overview-slides.html;
echo docs/html/motoko.html;
echo base-doc/
echo coverage/
echo flamegraphs/ ) | \
echo coverage/ ) | \
tree -H . -l --fromfile -T "Motoko build reports" > index.html
'';

Expand Down Expand Up @@ -779,8 +755,9 @@ EOF
check-grammar
check-error-codes
] ++
builtins.attrValues tests ++
builtins.attrValues js;
builtins.attrValues tests
++ builtins.attrValues js
;
};

viperServer = nixpkgs.fetchurl {
Expand Down
129 changes: 129 additions & 0 deletions design/GraphCopyStabilization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Graph-Copy-Based Stabilization

This is part of the enhanced orthogonal persistence support, see `OrthogonalPersistence.md`.
It allows future potentially radical changes of the persistent memory layout, such as introducing a new GC, rearranging persistent metadata, or specializing arrays for small element types etc.

## Purpose

This allows potentially radical changes of the persistent main memory layout, e.g. introducing a new GC or rearranging persistent metadata.
This also relies on precise value tagging to allow more advanced changes that require value metadata, e.g. specializing arrays for small value element types or even downgrading to 32-bit heap layouts (provided that the amount of live data fits into a 32-bit memory).

## Design

Graph copy of sub-graph of stable objects from main memory to stable memory and vice versa on upgrades.

## Properties
* Preserve sharing for all objects like in the heap.
* Allow the serialization format to be independent of the main memory layout.
* Limit the additional main memory needed during serialization and deserialization.
* Avoid deep call stack recursion (stack overflow).
* Allows arbitrarily long large stabilization/destabilization due to incremental mechanism (see below).

## Memory Compatibility Check
Apply a memory compatibility check analogous to the enhanced orthogonal persistence, since the upgrade compatibility of the graph copy is not identical to the Candid subtype relation.


## Incremental Upgrade

Supporting arbitrarily large upgrades beyond the instruction limit:
* Splitting the stabilization/destabilization in multiple asynchronous messages.
* Limiting the stabilization work units to fit the update or upgrade messages.
* Blocking other messages during the explicit incremental stabilization.
* Restricting the upgrade functionality to the canister owner and controllers.
* Stopping the GC during the explicit incremental upgrade process.

**Note**: Graph copying needs to be explicitly initiated as the usual upgrade engages enhanced orthogonal persistence, simply retaining main memory with compatibility check.

### Usage

When upgrading to a Motoko version that is not compatible with the current enhanced orthogonal persistence:

1. Initiate the explicit stabilization before the upgrade:

```
dfx canister call CANISTER_ID __motoko_stabilize_before_upgrade "()"
```

* An assertion first checks that the caller is the canister owner or a canister controller.
* All other messages to the canister will be blocked until the upgrade has been successfully completed.
* The GC is stopped.
* If defined, the actor's pre-upgrade function is called before the explicit stabilization.
* The stabilzation runs in possibly multiple asynchronous messages, each with a limited number of instructions.

2. Run the actual upgrade:

```
dfx deploy CANISTER_ID
```

* Completes the explicit stabilization if not yet done before this call.
* Perform the actual upgrade of the canister on the IC.
* Detects that graph-copying is in use.
* Clears the heap if enhanced orthogonal persistence is active.
* Start the destabilization with a limited number of steps to fit into the upgrade message.
* If destabilization cannot be completed, the canister does not start the GC and does not accept messages except step 3.

3. Complete the explicit destabilization after the upgrade:

```
dfx canister call CANISTER_ID __motoko_destabilze_after_upgrade "()"
```

* An assertion checks that the caller is the canister owner or a canister controller.
* All other messages remain blocked until the successful completion of the destabilization.
* The destabilzation runs in possibly multiple asynchronous messages, each with a limited number of instructions.
* If defined, the actor's post-upgrade function is called at the end of the explicit destabilization.
* The GC is restarted.

### Remarks

* Steps 2 (explicit destabilization) may not be needed if the corresponding operation fits into the upgrade message.
* Stabilization and destabilization steps are limited to the increment limits:

Operation | Message Type | IC Instruction Limit | **Increment Limit**
----------|--------------|----------------------|--------------------
**Explicit (de)stabilization step** | Update | 20e9 | **16e9**
**Actual upgrade** | Upgrade | 200e9 | **160e9**

## Graph-Copy Algorithm
Applying Cheney’s algorithm [1, 2] for both serialization and deserialization:

### Serialization
* Cheney’s algorithm using main memory as from-space and stable memory as to-space:
* Focusing on stable variables as root (sub-graph of stable objects).
* The target pointers and Cheney’s forwarding pointers denote the (skewed) offsets in stable memory.
* Using streaming reads for the `scan`-pointer and streaming writes for the `free`-pointer in stable memory.

### Deserialization
* Cheney’s algorithm using stable memory as from-space and main memory as to-space:
* Starting with the stable root created during the serialization process.
* A scan stack is used in the main memory to remember the deserialized objects for later scanning.
* Objects are allocated in main memory using the default allocator.
* Using random read/write access on the stable memory.

## Stable Format
For a long-term perspective, the object layout of the serialized data in the stable memory is fixed and independent of the main memory layout.
* Pointers are represented in 64-bit like main memory in enhanced orthogonal persistence.
* The Brooks forwarding pointer used by the incremental GC is omitted.
* The pointers encode skewed stable memory offsets to the corresponding target objects.
* References to the null objects are encoded by a defined null sentinel value.
* `BigInt` are explicitly serialized in a defined portable little endian representation, without that the serialization or deserialization allocates temporary objects.
The format is also versioned to allow future refinements of the graph copy algorithm.

## Specific Aspects
* Field hashes in objects are serialized in a blob. On deserialization, the hash blob is allocated in the dynamic heap. Same-typed objects that have been created by the same program version share the same hash blob.
* Stable records can dynamically contain non-stable fields due to structural sub-typing. A dummy value can be serialized for such fields as a new program version can no longer access this field through the stable types.
* For backwards compatibility, old Candid destabilzation is still supported when upgrading from a program that used older compiler version.
* Incremental GC: Serialization needs to consider Brooks forwarding pointers (not to be confused with the Cheney's forwarding information), while deserialization can deal with partitioned heap that can have internal fragmentation (free space at partition ends).
* The partitioned heap prevents linear scanning of the heap, especially in the presence of large objects that can be placed at a higher partition than subsequently allocated normal-sized objects. For this reason, a scan stack is allocated in the main memory, remembering the deserialized objects that still need to be scanned. With this, the deserialization does not need to make any assumptions of the heap structure (e.g. monotonically increasing allocations, free space markers, empty heap on deserialization start etc.).
* If actor fields are promoted to the `Any` type in a new program version, their content is released in that variable to allow memory reclamation.

## Open Aspects
* Unused fields in stable records that are no longer declared in a new program versions should be removed. This could be done during garbage collection, when objects are moved/evacuated. This scenario equally applies to enhanced orthogonal persistence.
* The scan stack used during destabilization involves dynamic allocations.

## References

[1] C. J. Cheney. A Non-Recursive List Compacting Algorithm. Communications of the ACM, 13(11):677-8, November 1970.

[2] R. Jones and R. Lins. Garbage Collection: Algorithms for Automatic Dynamic Memory Management. Wiley 2003. Algorithm 6.1: Cheney's algorithm, page 123.
6 changes: 5 additions & 1 deletion design/StableMemory.md → design/OldStableMemory.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Stable Memory API
# Old Stable Memory API

This describes the legacy stable memory mechanism intended to be replaced by
true orthogonal persistence where the main memory is retained across upgrades.
See `OrthogonalPersistence.md`.

The current implementation of stable variables is based on
serialization and deserialization of all stable data on upgrade. This
Expand Down
Loading