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

Enhanced Orthogonal Persistence (64-Bit with Graph Copy) #4475

Merged
merged 241 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
241 commits
Select commit Hold shift + click to select a range
d30c4cc
Graph copy: Work in progress
luc-blaeser Nov 9, 2023
fe37c49
Implement stable memory reader writer
luc-blaeser Nov 10, 2023
63ddfa4
Add skip function
luc-blaeser Nov 10, 2023
b16fa71
Code refactoring
luc-blaeser Nov 10, 2023
4ec1f66
Continue stabilization function
luc-blaeser Nov 10, 2023
30edeff
Support update at scan position
luc-blaeser Nov 10, 2023
86ba074
Code refactoring
luc-blaeser Nov 10, 2023
7e2da25
Code refactoring
luc-blaeser Nov 10, 2023
1185001
Extend unit test
luc-blaeser Nov 13, 2023
cb1b8f5
Continue implementation
luc-blaeser Nov 13, 2023
00396a0
Adjust test
luc-blaeser Nov 13, 2023
8120b31
Prepare memory compatibility check
luc-blaeser Nov 13, 2023
13576e5
Variable stable to-space offset
luc-blaeser Nov 14, 2023
f999115
Deserialize with partitioned heap
luc-blaeser Nov 14, 2023
ac09cde
Prepare metadata stabilization
luc-blaeser Nov 14, 2023
428df17
Adjust stable memory size
luc-blaeser Nov 14, 2023
1b51de1
Stabilization version management
luc-blaeser Nov 15, 2023
933d720
Remove code redundancies
luc-blaeser Nov 15, 2023
199e56a
Merge branch 'master' into luc/graph-copy
luc-blaeser Nov 15, 2023
d57717a
Fix version upgrade
luc-blaeser Nov 15, 2023
dc0583f
Put object field hashes in a blob
luc-blaeser Nov 15, 2023
8a7997a
Support object type
luc-blaeser Nov 15, 2023
3b170c5
Code refactoring
luc-blaeser Nov 16, 2023
af93675
Support blob, fix bug
luc-blaeser Nov 16, 2023
31ade51
Renaming variable
luc-blaeser Nov 16, 2023
3abe86d
Adjust deserialization heap start
luc-blaeser Nov 16, 2023
8cb4e49
Handle null singleton
luc-blaeser Nov 16, 2023
259a22e
Fix version upgrade
luc-blaeser Nov 16, 2023
94d3a50
Support regions
luc-blaeser Nov 16, 2023
e4d36ae
Backup first word in stable memory
luc-blaeser Nov 16, 2023
b40e0ee
Support additional fields in upgraded actor
luc-blaeser Nov 16, 2023
b9d23c3
Make unit tests runnable again
luc-blaeser Nov 16, 2023
5edb727
Dummy null singleton in unit test
luc-blaeser Nov 16, 2023
01dcdf5
Add test cases
luc-blaeser Nov 16, 2023
67547ce
Support boxed 32-bit and 64-bit numbers
luc-blaeser Nov 16, 2023
8b54030
Support more object types
luc-blaeser Nov 16, 2023
910c940
Support more object types
luc-blaeser Nov 16, 2023
d74b0ff
Handle `true` bool constant
luc-blaeser Nov 16, 2023
844f68a
Grow main memory on bulk copy
luc-blaeser Nov 16, 2023
f96326f
Update benchmark results
luc-blaeser Nov 16, 2023
78c6379
Support bigint
luc-blaeser Nov 16, 2023
42be67e
Clear deserialized data in stable memory
luc-blaeser Nov 16, 2023
b6a5d45
Update test results
luc-blaeser Nov 16, 2023
459b86d
Add documentation
luc-blaeser Nov 16, 2023
250596f
Reformat
luc-blaeser Nov 16, 2023
1066a10
Add missing file
luc-blaeser Nov 17, 2023
569c622
Update design/GraphCopyStabilization.md
luc-blaeser Nov 21, 2023
9c427b0
Update rts/motoko-rts/src/stabilization.rs
luc-blaeser Nov 21, 2023
e0a9105
Update rts/motoko-rts/src/stabilization.rs
luc-blaeser Nov 21, 2023
cce53c9
Graph Copy: Explicit Stable Data Layout (#4293)
luc-blaeser Nov 21, 2023
035a978
Merge branch 'master' into luc/graph-copy
luc-blaeser Nov 21, 2023
e9c5db9
Update rts/motoko-rts/src/stabilization.rs
luc-blaeser Nov 22, 2023
eec755f
Update rts/motoko-rts/src/stabilization/layout.rs
luc-blaeser Nov 22, 2023
24b2add
Handle non-stable fields in stable records
luc-blaeser Nov 22, 2023
063754c
Add object type `Some`
luc-blaeser Nov 22, 2023
597548a
Add test case
luc-blaeser Nov 22, 2023
9232ef1
Adjust stabilization to incremental GC
luc-blaeser Nov 23, 2023
9cd3a7e
Update benchmark results
luc-blaeser Nov 23, 2023
d87b173
Distinguish assertions
luc-blaeser Nov 23, 2023
0b3dd92
Fix RTS unit test
luc-blaeser Nov 23, 2023
630ba84
Update benchmark results
luc-blaeser Nov 23, 2023
5c5d4dd
Adjust test
luc-blaeser Nov 23, 2023
faf2724
Adjust test
luc-blaeser Nov 23, 2023
b2a8b24
Fix: Handle all non-stable types during serialization
luc-blaeser Nov 25, 2023
288dc22
Fix typos and complete comment
luc-blaeser Nov 27, 2023
aaa8b52
Merge branch 'master' into luc/graph-copy
luc-blaeser Nov 28, 2023
d5bdc55
Experiment: Simplified Graph-Copy-Based Stabilization (#4313)
luc-blaeser Dec 6, 2023
e2c501d
Merge branch 'master' into luc/graph-copy
luc-blaeser Dec 6, 2023
c7b4ac9
Bug fix: Allocations are not monotonically growing in partitioned hea…
luc-blaeser Dec 6, 2023
099e228
Update benchmark results
luc-blaeser Dec 6, 2023
ea9dae2
Merge branch 'master' into luc/graph-copy
luc-blaeser Dec 7, 2023
58d940c
Merge branch 'master' into luc/graph-copy
luc-blaeser Dec 7, 2023
02de5f7
Update benchmark results
luc-blaeser Dec 7, 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
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
f0f1e10
Merge branch 'master' into luc/graph-copy
luc-blaeser Dec 20, 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
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
759747f
Merge branch 'master' into luc/graph-copy
luc-blaeser Feb 13, 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
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
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
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
0ad0068
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 5, 2024
b2b28e8
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 8, 2024
5b99095
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 10, 2024
63d5818
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-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
ae9e0e2
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 11, 2024
21bd33a
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-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
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
d5b4d1d
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 11, 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
502c4a2
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Apr 12, 2024
1099098
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 3, 2024
60a53a7
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 3, 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
7262c4f
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 14, 2024
2cd38f2
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 14, 2024
ba5b26d
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 14, 2024
f01c40a
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 17, 2024
5c46be4
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 17, 2024
5ce47d5
Fix typo in documentation
luc-blaeser May 17, 2024
3117162
Fix typo in documentation
luc-blaeser May 17, 2024
a79f848
Bug fix: Allow stabilization beyond compiler-specified stable memory …
luc-blaeser May 17, 2024
c3760c1
Merge branch 'luc/graph-copy-on-stable-heap64' of https://github.com/…
luc-blaeser May 17, 2024
5e2bb34
Adjustment to RTS unit tests
luc-blaeser May 17, 2024
4f10463
Add comments
luc-blaeser May 17, 2024
29da94d
Code refactoring
luc-blaeser May 17, 2024
c4d9433
Fix difference between debug and release test execution
luc-blaeser May 17, 2024
356af53
Fix typo in comment
luc-blaeser May 17, 2024
046706e
Fix typo in comment
luc-blaeser May 17, 2024
2cf9889
Fix typo in comment
luc-blaeser May 17, 2024
ebe7467
Fix typo in comment
luc-blaeser May 17, 2024
38ac6e8
Delete unused file
luc-blaeser May 17, 2024
ada6407
Merge branch 'luc/graph-copy-on-stable-heap64' of https://github.com/…
luc-blaeser May 17, 2024
6a7642f
Code refactoring
luc-blaeser May 17, 2024
a5ff1ea
Use correct trap for an unreachable case
luc-blaeser May 17, 2024
aec904d
Remove dead code
luc-blaeser May 17, 2024
bba2aa4
Fix typo in comment
luc-blaeser May 17, 2024
15a35e7
Fix typo in function identifier
luc-blaeser May 17, 2024
720012c
Merge branch 'luc/graph-copy-on-stable-heap64' of https://github.com/…
luc-blaeser May 17, 2024
ef0004e
Fix indendation
luc-blaeser May 17, 2024
c91ce0e
Removing unused code
luc-blaeser May 17, 2024
3c96e31
Merge branch 'luc/graph-copy-on-stable-heap64' of https://github.com/…
luc-blaeser May 17, 2024
7827899
Fix typo in comment
luc-blaeser May 17, 2024
739c27b
Fix typo in comment
luc-blaeser May 17, 2024
1cc52bf
Fix RTS compile error
luc-blaeser May 17, 2024
0d8178b
Bug fix: Object size lookup during stabilization
luc-blaeser May 21, 2024
5fde63f
experiment: refactoring of ir extensions in graph-copy PR (#4543)
crusso May 21, 2024
08d756c
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser May 24, 2024
289eaf3
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jun 7, 2024
a0b0f6e
Merge branch 'luc/stable-heap64-merge-object-tagging' into luc/graph-…
luc-blaeser Jun 7, 2024
a10e14a
Manual merge conflict resolution
luc-blaeser Jun 7, 2024
537291f
Merge branch 'luc/stable-heap64-merge-object-tagging' into luc/graph-…
luc-blaeser Jun 7, 2024
b566edc
Adjust test case, remove file check
luc-blaeser Jun 10, 2024
329a8a6
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jun 17, 2024
92767f8
Merge branch 'luc/graph-copy-on-stable-heap64' into luc/graph-copy-on…
luc-blaeser Jun 17, 2024
3d0f9b7
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jun 18, 2024
6d6fbfe
Manual merge conflict resolution
luc-blaeser Jun 18, 2024
d546419
Merge branch 'luc/graph-copy-on-stable-heap64' into luc/graph-copy-on…
luc-blaeser Jun 18, 2024
b80dbb1
Manual merge conflict resolution
luc-blaeser Jun 18, 2024
84cdbd6
test graph copy of text and blob iterators (#4562)
crusso Jun 18, 2024
98cf87d
Merge branch 'luc/graph-copy-on-stable-heap64' into luc/graph-copy-on…
luc-blaeser Jun 18, 2024
4d8990a
Optimize instruction limit checks
luc-blaeser Jun 20, 2024
9de8285
Bug fix graph copy limit on destabilization
luc-blaeser Jun 20, 2024
9522446
Incremental stable memory clearing after graph copy
luc-blaeser Jun 21, 2024
316a424
Parameter tuning for graph copy
luc-blaeser Jun 21, 2024
bbb648a
Merge branch 'luc/graph-copy-on-stable-heap64' into luc/graph-copy-on…
luc-blaeser Jun 21, 2024
ae35f93
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jun 21, 2024
c3d04af
Merge branch 'luc/graph-copy-on-stable-heap64' into luc/graph-copy-on…
luc-blaeser Jun 21, 2024
bb46a86
Merge branch 'luc/stable-heap64-merge-object-tagging' into luc/graph-…
luc-blaeser Jun 24, 2024
a7578bc
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jun 25, 2024
b4742ca
Manual merge conflict resolution
luc-blaeser Jun 25, 2024
5f24019
Manual merge conflict resolution
luc-blaeser Jun 25, 2024
e8b6510
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jun 26, 2024
60de85f
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jun 27, 2024
3adee9f
Remove redundant code
luc-blaeser Jul 1, 2024
a1b2e10
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jul 8, 2024
983061f
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jul 8, 2024
8ad042f
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jul 22, 2024
7fc01bd
Manual merge conflict resolution: Remove `ObjInd` from graph-copy sta…
luc-blaeser Jul 22, 2024
fd6a1c1
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Jul 22, 2024
d556308
Manual merge conflict resolution
luc-blaeser Jul 22, 2024
571f6c5
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Aug 9, 2024
bff5312
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Aug 19, 2024
f23b598
Merge Preparation: Latest IC with Graph Copy (#4630)
luc-blaeser Aug 20, 2024
16b1e35
Merge branch 'luc/stable-heap64' into luc/graph-copy-on-stable-heap64
luc-blaeser Aug 20, 2024
8c3d408
Message-dependent stable memory access limit
luc-blaeser Aug 20, 2024
ce94118
Graph copy: Fix accessed memory limit during stabilization
luc-blaeser Aug 21, 2024
320fe4b
Enhanced Orthogonal Persistence (Complete Integration) (#4488)
luc-blaeser Aug 26, 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
  •  
  •  
  •  
10 changes: 7 additions & 3 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_RELEASE_RTS MOC_DEBUG_RTS"
envs[moc]="MOC_NON_INCREMENTAL_RELEASE_RTS MOC_NON_INCREMENTAL_DEBUG_RTS MOC_INCREMENTAL_RELEASE_RTS MOC_INCREMENTAL_DEBUG_RTS MOC_EOP_RELEASE_RTS MOC_EOP_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,8 +32,12 @@ hint[candid-tests]="make -C $rel_root/src candid-tests"

rts_hint="make -C $rel_root/rts"

real[MOC_RELEASE_RTS]=rts/mo-rts.wasm
real[MOC_DEBUG_RTS]=rts/mo-rts-debug.wasm
real[MOC_NON_INCREMENTAL_RELEASE_RTS]=rts/mo-rts-non-incremental.wasm
real[MOC_NON_INCREMENTAL_DEBUG_RTS]=rts/mo-rts-non-incremental-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_EOP_RELEASE_RTS]=rts/mo-rts-eop.wasm
real[MOC_EOP_DEBUG_RTS]=rts/mo-rts-eop-debug.wasm

for var in ${envs[moc]}; do
hint[$var]=$rts_hint
Expand Down
59 changes: 55 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ rec {
name = "motoko-rts-deps";
src = subpath ./rts;
sourceRoot = "rts/motoko-rts-tests";
sha256 = "sha256-YEw2AFi15JVKP7owsPDoBT3qSegOO90FRn2qoUBAICw=";
sha256 = "sha256-prLZVOWV3BFb8/nKHyqZw8neJyBu1gs5d0D56DsDV2o=";
copyLockfile = true;
};

Expand Down Expand Up @@ -261,8 +261,12 @@ rec {

installPhase = ''
mkdir -p $out/rts
cp mo-rts.wasm $out/rts
cp mo-rts-debug.wasm $out/rts
cp mo-rts-non-incremental.wasm $out/rts
cp mo-rts-non-incremental-debug.wasm $out/rts
cp mo-rts-incremental.wasm $out/rts
cp mo-rts-incremental-debug.wasm $out/rts
cp mo-rts-eop.wasm $out/rts
cp mo-rts-eop-debug.wasm $out/rts
'';

# This needs to be self-contained. Remove mention of nix path in debug
Expand All @@ -272,7 +276,17 @@ rec {
-t ${nixpkgs.rustc-nightly} \
-t ${rtsDeps} \
-t ${rustStdDeps} \
$out/rts/mo-rts.wasm $out/rts/mo-rts-debug.wasm
$out/rts/mo-rts-non-incremental.wasm $out/rts/mo-rts-non-incremental-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
remove-references-to \
-t ${nixpkgs.rustc-nightly} \
-t ${rtsDeps} \
-t ${rustStdDeps} \
$out/rts/mo-rts-eop.wasm $out/rts/mo-rts-eop-debug.wasm
'';

allowedRequisites = [];
Expand Down Expand Up @@ -363,6 +377,31 @@ rec {
EXTRA_MOC_ARGS = "--sanity-checks";
};

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";
};

enhanced_orthogonal_persistence_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs {
EXTRA_MOC_ARGS = "--enhanced-orthogonal-persistence";
};

snty_enhanced_orthogonal_persistence_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs {
EXTRA_MOC_ARGS = "--sanity-checks --enhanced-orthogonal-persistence";
};

perf_subdir = dir: deps:
(test_subdir dir deps).overrideAttrs (args: {
checkPhase = ''
Expand Down Expand Up @@ -474,15 +513,27 @@ rec {
in fix_names ({
run = test_subdir "run" [ moc ] ;
run-dbg = snty_subdir "run" [ moc ] ;
run-eop-release = enhanced_orthogonal_persistence_subdir "run" [ moc ];
run-eop-debug = snty_enhanced_orthogonal_persistence_subdir "run" [ moc ];
# 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 ] ;
drun-eop-release = enhanced_orthogonal_persistence_subdir "run-drun" [ moc nixpkgs.drun ] ;
drun-eop-debug = snty_enhanced_orthogonal_persistence_subdir "run-drun" [ moc nixpkgs.drun ] ;
fail = test_subdir "fail" [ moc ];
fail-eop = enhanced_orthogonal_persistence_subdir "fail" [ moc ];
repl = test_subdir "repl" [ moc ];
repl-eop = enhanced_orthogonal_persistence_subdir "repl" [ moc ];
ld = test_subdir "ld" ([ mo-ld ] ++ ldTestDeps);
ld-eop = enhanced_orthogonal_persistence_subdir "ld" ([ mo-ld ] ++ ldTestDeps);
idl = test_subdir "idl" [ didc ];
mo-idl = test_subdir "mo-idl" [ moc didc ];
mo-idl-eop = enhanced_orthogonal_persistence_subdir "mo-idl" [ moc didc ];
trap = test_subdir "trap" [ moc ];
trap-eop = enhanced_orthogonal_persistence_subdir "trap" [ moc ];
run-deser = test_subdir "run-deser" [ deser ];
perf = perf_subdir "perf" [ moc nixpkgs.drun ];
bench = perf_subdir "bench" [ moc nixpkgs.drun ic-wasm ];
Expand Down
4 changes: 4 additions & 0 deletions design/Custom-Sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ let hash : string -> int32 = fun s ->
(Lib.String.explode s)
)
```

Motoko generates an additional `"enhanced-orthogonal-persistence"` private custom section to
mark Motoko Wasm binaries that rely on IC's support to retain the main Wasm memory on an upgrade,
cf. [Orthogonal Persistence](OrthogonalPersistence.md).
8 changes: 8 additions & 0 deletions design/DFX-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ used only in very specific cases.
The above metadata is stored in the Wasm module, and is only accessible by the controllers of the canister, unless the
metadata name is specified in the `--public-metadata` flag.

Moreover, the compiler generates a special marker custom section `"enhanced-orthogonal-persistence"` if the new orthogonal
persistence support is enabled, see [Orthogonal Persistence](OrthogonalPersistence.md). This section is always private and
always emited independent of the compiler flags `--public-metadata` or `--public-metadata`.

Checking stable type compatibility
----------------------------------

Expand All @@ -130,6 +134,10 @@ a type safe way without unintentional data loss.

If the check succeeds, nothing will be printed.
If the check fails, the error message will be printed in stderr and the command returns with exit code 1.
The check can also emit warning messages, e.g. if stable variables are dropped.

With [enhanced orthogonal persistence](OrthogonalPersistence.md), the stable compatibility is also integrated in the runtime
system, to atomically guarantee memory compatibility during an upgrade.

Invoking the IDE
----------------
Expand Down
132 changes: 132 additions & 0 deletions design/GraphCopyStabilization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Graph-Copy-Based Stabilization

This is part of the enhanced orthogonal persistence support, see [Orthogonal Persistence](OrthogonalPersistence.md).

## Purpose
This 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.
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_destabilize_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
* When receiving the `dfx` error "The request timed out." during explicit stabilization, upgrade, or destabilization, one can simply repeat the call until it completes.
* Steps 3 (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**

* The graph copy steps also limit the amount of processed stable data (read or write), in order not to exceed the
IC's stable memory access limits.

Operation | Message Type | IC Stable Access Limit | **Increment Limit**
----------|--------------|----------------------|--------------------
**Explicit (de)stabilization step** | Update | 2 GB | **1 GB**
**Actual upgrade** | Upgrade | 8 GB | **6 GB**

## 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 destabilization 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.).
luc-blaeser marked this conversation as resolved.
Show resolved Hide resolved
* 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.
* Both stabilization and destabilization read and write data linearly, which is beneficial for guarding a work set limit (number of accessed pages) per IC message. Destabilization is also linear because it deserializes objects in the same order back as they have been serialized.

## 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.
25 changes: 17 additions & 8 deletions design/Implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@

## Heap

* Uniform representation with 32 bit word size.
* Uniform representation with a defined word size.
For [enhanced orthogonal persistence](OrthogonalPersistence.md), 64-bit words are used, while for classical persistence, the word size is 32-bit.

* Use pointer tagging in LSB;.
- 0 for pointers, 1 for scalars.
- Scalars are real value shifted left by 1, lowest bit set.

* Q: Allocation and GC strategies?
* Use pointer tagging in the LSB:
- 1 for pointers, 0 for scalars.
- Scalars are real value shifted left by 1, lowest bit clear.
For [enhanced orthogonal persistence](OrthogonalPersistence.md), the types of scalars are additionally tagged.

* Garbage collected.


## Primitive types

* Nat and Int compile to heap-allocated big nums; unboxed for small numbers `<= 31` bit.

* Nat8/16 compile to unboxed scalars; Nat32/64 are boxed.
* Nat8/16 compile to unboxed scalars;
On a 32-bit heap, Nat32/64 are boxed.
On a 64-bit heap, only Nat64 is boxed, while Nat32 remains unboxed.
- May unbox locally.

* Characters are scalars (unicode code points).

* Text is heap-allocated.
* Text is heap-allocated. Using ropes for concatenations.


## Tuples
Expand Down Expand Up @@ -103,6 +107,11 @@ TODO

TODO

## Persistence

Different * [persistence modes](OrthogonalPersistence.md):
* [Enhanced orthogonal persistence](OrthogonalPersistence.md).
* [Classical persistence](OldStableMemory.md).

# Hypervisor Extensions needed

Expand Down
Loading