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 #4193

Merged
merged 311 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
311 commits
Select commit Hold shift + click to select a range
5424d16
Comment refactoring
luc-blaeser Aug 25, 2023
cd8131e
Prepare memory compatibility check
luc-blaeser Aug 28, 2023
4d26bd1
Draft the memory compatibility check
luc-blaeser Aug 28, 2023
5bb8424
Add sub-type cache
luc-blaeser Aug 28, 2023
589542e
Code refactoring
luc-blaeser Aug 28, 2023
be38c4e
Add test case
luc-blaeser Aug 29, 2023
eb0366d
Add unit test
luc-blaeser Aug 29, 2023
40e1f35
Unit test for recursive types
luc-blaeser Aug 29, 2023
3d708e2
Code refactoring, added test case
luc-blaeser Aug 29, 2023
b3ac218
Upgrade check: Support mutable variables
luc-blaeser Aug 29, 2023
31df132
Continue compatibility check
luc-blaeser Aug 29, 2023
f2d67c5
Add test case
luc-blaeser Aug 30, 2023
ed8f4f7
Revert run script changes
luc-blaeser Aug 30, 2023
5bb6a39
Compatibility check: Support all stable primitive types
luc-blaeser Aug 31, 2023
963edbc
More unit tests
luc-blaeser Aug 31, 2023
b9e0167
Check array compatibility
luc-blaeser Aug 31, 2023
6c17834
Code refactoring
luc-blaeser Aug 31, 2023
7076c8a
Code refactoring
luc-blaeser Aug 31, 2023
dd001bd
Check tuple type compatibility
luc-blaeser Aug 31, 2023
66d0920
Recursive type constructor resolution
luc-blaeser Aug 31, 2023
4fb4b04
Adjust test case
luc-blaeser Aug 31, 2023
1f26c67
Support generic type resolution
luc-blaeser Sep 1, 2023
bf25c9a
Revert run script change
luc-blaeser Sep 1, 2023
82d8ca1
Add test case
luc-blaeser Sep 1, 2023
e788076
Adjust generic resolution
luc-blaeser Sep 1, 2023
ce36cf8
Check variant type compatibility
luc-blaeser Sep 1, 2023
b75497c
Adjust generic resolution
luc-blaeser Sep 1, 2023
a444c17
Support `any` and `none` type checks
luc-blaeser Sep 1, 2023
cca62ec
Check actor type compatibility
luc-blaeser Sep 1, 2023
87bb037
Rearrange type encoding
luc-blaeser Sep 1, 2023
f91d441
Work in progress: Function type compatibility
luc-blaeser Sep 1, 2023
0eb9bc4
Check function type compatibility
luc-blaeser Sep 1, 2023
e797c79
Adjust cache initialization
luc-blaeser Sep 4, 2023
5811ea3
Revert cache initialization
luc-blaeser Sep 4, 2023
e22be2b
Add unit tests
luc-blaeser Sep 4, 2023
23b54af
Support `Nat` to `Int` compatibility
luc-blaeser Sep 4, 2023
0eb283c
Fix contravariance check
luc-blaeser Sep 4, 2023
12af096
Revert test case changes
luc-blaeser Sep 4, 2023
95ef9fc
Increase reserved data segment section
luc-blaeser Sep 4, 2023
de7600a
Migrate from old serialization
luc-blaeser Sep 4, 2023
a3b9d76
Include missing `wasm` file
luc-blaeser Sep 4, 2023
394f873
Adjust test case
luc-blaeser Sep 4, 2023
7bdd8cd
Fix blob comparison in deserialization
luc-blaeser Sep 4, 2023
9c2736b
Upgrade stable memory version
luc-blaeser Sep 4, 2023
b26ac99
Code refactoring
luc-blaeser Sep 4, 2023
12fda07
Collect unused old stable variables
luc-blaeser Sep 5, 2023
a80e610
Require mutable invariance
luc-blaeser Sep 5, 2023
5cc4588
Update documentation
luc-blaeser Sep 5, 2023
0be9769
Update benchmark results (incremental GC)
luc-blaeser Sep 5, 2023
e9e91ce
Merge branch 'master' into luc/stable-heap
luc-blaeser Sep 6, 2023
87abf2f
Merge branch 'master' into luc/stable-heap
luc-blaeser Sep 6, 2023
c588239
Manual merge from master
luc-blaeser Sep 6, 2023
b10aedd
Adjust test
luc-blaeser Sep 7, 2023
3fae535
Merge branch 'master' into luc/stable-heap
luc-blaeser Sep 7, 2023
2c31217
Manual merge of region PR
luc-blaeser Sep 7, 2023
b119d80
Adjust profile report script
luc-blaeser Sep 7, 2023
568b3cc
Check compatibility with Candid subtype
luc-blaeser Sep 8, 2023
e9f91cf
Merge branch 'master' into luc/stable-heap
luc-blaeser Sep 12, 2023
9e0c490
Update documentation
luc-blaeser Sep 12, 2023
fdf601c
Downscale test for CI
luc-blaeser Sep 13, 2023
f5ca132
Change IC dependency to pull request
luc-blaeser Sep 14, 2023
0e7dcb7
Test CI build option
luc-blaeser Sep 14, 2023
0e73ccf
Update test.yml
ggreif Sep 14, 2023
051da06
Merge branch 'master' into luc/stable-heap
luc-blaeser Sep 22, 2023
0a8baf0
Remove memory reserve
luc-blaeser Sep 22, 2023
e984eeb
Manual merge RTS
luc-blaeser Sep 22, 2023
ad587dc
Manual merge compiler
luc-blaeser Sep 22, 2023
63e28a8
Update benchmark results
luc-blaeser Sep 22, 2023
69cf3d8
Fix typos and unwanted documentation deletion
luc-blaeser Sep 27, 2023
64bad1a
Merge branch 'master' into luc/stable-heap
luc-blaeser Sep 27, 2023
c4c98d7
Re-Insert Memory Reserve for Queries and Upgrades (#4158)
luc-blaeser Sep 27, 2023
cf9a37d
Optimize field search
luc-blaeser Sep 27, 2023
43bde5d
Improve memory compatibility check
luc-blaeser Sep 27, 2023
67ebe00
Merge branch 'master' into luc/stable-heap
luc-blaeser Sep 28, 2023
cce91a8
Delete unused source file
luc-blaeser Sep 28, 2023
a9756db
Downsize test
luc-blaeser Sep 28, 2023
cd85353
Exempt blob tag from Candid parsing
luc-blaeser Sep 29, 2023
89528b5
Merge branch 'master' into luc/stable-heap
luc-blaeser Oct 4, 2023
4d79801
Resolve merge conflict
luc-blaeser Oct 4, 2023
338ff5e
Support memory sanity checks
luc-blaeser Oct 6, 2023
76f2bde
Bug fix: Null comparison in pattern matching
luc-blaeser Oct 18, 2023
dde1d7e
Update benchmark results
luc-blaeser Oct 18, 2023
0329c71
Merge branch 'master' into luc/stable-heap
luc-blaeser Oct 18, 2023
bcb7f73
Upgrade IC dependency, use persistence flag
luc-blaeser Oct 20, 2023
df90d47
Merge branch 'master' into luc/stable-heap
luc-blaeser Oct 20, 2023
539e4b3
Update IC dependency
luc-blaeser Oct 20, 2023
29bc1fd
Update IC dependency
luc-blaeser Oct 27, 2023
8026ee9
Merge branch 'master' into luc/stable-heap
luc-blaeser Oct 27, 2023
ad1264b
Adjust test
luc-blaeser Oct 27, 2023
d27d9ee
Use new upgrade option
luc-blaeser Nov 3, 2023
149206d
Update IC dependency
luc-blaeser Nov 6, 2023
3dfa7ec
Merge branch 'master' into luc/stable-heap
luc-blaeser Nov 6, 2023
bd46954
Adjust test
luc-blaeser Nov 6, 2023
c19aabd
Update IC dependency
luc-blaeser Nov 8, 2023
867e3ad
Merge branch 'master' into luc/stable-heap
luc-blaeser Nov 8, 2023
4c90132
Merge branch 'master' into luc/stable-heap
luc-blaeser Nov 15, 2023
c6071a0
Manual merge conflict resolution
luc-blaeser Nov 15, 2023
a0bae88
Remove code redundancies
luc-blaeser Nov 15, 2023
7d3d017
Adjust version upgrade
luc-blaeser Nov 15, 2023
ccb43ac
Merge branch 'master' into luc/stable-heap
luc-blaeser Nov 22, 2023
8f42dc0
Add test cases
luc-blaeser Nov 22, 2023
def8030
Merge branch 'master' into luc/stable-heap
luc-blaeser Dec 15, 2023
cad375a
Manually resolve merge conflicts
luc-blaeser Dec 15, 2023
bc7a51f
Update IC dependency
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
51d5242
Drop content of destabilized `Any`-typed actor field
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
e8986b3
Adjust comment
luc-blaeser Dec 19, 2023
c455a11
Merge branch 'master' into luc/stable-heap
luc-blaeser Dec 19, 2023
d6daf39
Eliminate redundant size field in `Object` header
luc-blaeser Dec 20, 2023
acce2ff
Merge branch 'master' into luc/stable-heap
luc-blaeser Dec 20, 2023
3e24296
Merge branch 'master' into luc/stable-heap
luc-blaeser Dec 21, 2023
a613365
Record the upgrade instruction costs
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
1e2e35d
Update IC dependency
luc-blaeser Jan 9, 2024
55216e2
Merge branch 'master' into luc/stable-heap
luc-blaeser Jan 9, 2024
bf3e05b
Merge branch 'master' into luc/stable-heap
luc-blaeser Feb 2, 2024
be54eca
Merge branch 'master' into luc/stable-heap
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
d8f7f04
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
1aa3cd2
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 8, 2024
3e43218
Distinguish tuple type in memory compatibility check
luc-blaeser Sep 28, 2023
6b188e6
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 11, 2024
affc532
Manual merge conflict resolution
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
94e5257
Optimization: Enhanced Orthogonal Persistence with Object Pooling (#4…
luc-blaeser Mar 20, 2024
0067284
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 20, 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
ea702bf
Merge branch 'master' into luc/stable-heap
luc-blaeser Mar 27, 2024
f6abef5
Merge branch 'master' into luc/stable-heap
luc-blaeser Apr 5, 2024
df3c8a3
Upgrade IC dependency
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
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
38878fd
Code refactoring: Constant blobs
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
3d52046
Code Refactoring: Getting rid of `Stream` interface.
luc-blaeser Apr 11, 2024
2c6875c
Handle all cases on constant equality
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
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
87c1a52
Merge branch 'master' into luc/stable-heap
luc-blaeser Apr 12, 2024
9ff46f5
Merge branch 'master' into luc/stable-heap
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
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
db2536e
Add WASI support when detecting persistence version
luc-blaeser May 14, 2024
f0d78ec
Support Wasi mode without stable memory support
luc-blaeser May 14, 2024
d9c23e8
Merge branch 'master' into luc/stable-heap
luc-blaeser May 17, 2024
6be52e1
subdivide ambiguous tags
crusso May 17, 2024
7b03506
WIP: rts for precise tagging
crusso May 17, 2024
cc85f80
used correct tags in compile.ml
crusso May 17, 2024
8430baa
Optimization
luc-blaeser May 22, 2024
bdf39b0
Update benchmark result
luc-blaeser May 22, 2024
4e1246b
Merge branch 'master' into luc/stable-heap
luc-blaeser May 24, 2024
99b2985
ugly attempt to tag allocations
crusso May 17, 2024
0b0976a
implement refined tagging; refine Blob Const (WIP); todo: refine Cons…
crusso May 18, 2024
00e5895
copy, don't alias, in blob_to_text;restrict blob_of_text; generslize …
crusso May 22, 2024
6bbfdea
refine Const.Array into Const.Array and Const.Tuple to reflect precis…
crusso May 22, 2024
4981b3a
adapt incremental array slicing; fix rts tests
crusso May 23, 2024
788f403
rust format
crusso May 23, 2024
30c91ee
adapt generational array slicing; updeate bench numbers
crusso May 24, 2024
28d98e0
fix blob comparistion in patterns
crusso May 30, 2024
4310118
refactor slicing
crusso May 30, 2024
448962f
hide encoding of array tags in helpers
crusso May 30, 2024
2cb651a
refactor array_slicing
crusso May 30, 2024
3de6cac
Merge branch 'master' into claudio/precise-heap-tags
crusso May 31, 2024
b44b133
extern array_slicing test
crusso May 31, 2024
8dbe885
add basic tag checking on unboxing of new tags
crusso May 31, 2024
ac88615
refine tags for actors and shared functions, TAG_BLOB_A and TAB_ARRAY_S
crusso May 31, 2024
6f581c6
format
crusso May 31, 2024
9f86d91
implement required coercions
crusso Jun 1, 2024
ba137c7
fix bugs; extend interpreter; rename prims; add __LINE__ to Tagged.sa…
crusso Jun 3, 2024
4d41889
Update rts/motoko-rts/src/debug.rs
crusso Jun 4, 2024
0fdbc12
document tags
crusso Jun 4, 2024
0ed4fe6
reformat; implement and use blob_of_ptr_size, blob_of_str; fix base32…
crusso Jun 5, 2024
41f8917
remove unused pattern match code from compile.ml
crusso Jun 5, 2024
1e8d0f6
use binary, not text, blob for IDL decoding check
crusso Jun 5, 2024
e8c4c19
add more assertions
crusso Jun 5, 2024
f5e97a9
assert array tag difference is even
crusso Jun 5, 2024
afde9e1
fix one broken assert (missing TAG_BLOB_A case); refactor other asserts
crusso Jun 5, 2024
34dd29d
Update rts/motoko-rts-tests/src/gc/heap.rs
crusso Jun 6, 2024
0082f1d
Update rts/motoko-rts-tests/src/gc/heap.rs
crusso Jun 7, 2024
a1f5db7
Merge branch 'claudio/precise-heap-tags' into luc/stable-heap
luc-blaeser Jun 7, 2024
b7cdc7a
Manual merge conflict resolution
luc-blaeser Jun 7, 2024
7331086
Merge branch 'master' into luc/stable-heap
luc-blaeser Jun 7, 2024
02b6b4b
Merge branch 'luc/stable-heap' into luc/stable-heap-merge-object-tagging
luc-blaeser Jun 7, 2024
8cffb0e
Fix usage of specific blob tags
luc-blaeser Jun 7, 2024
6ce9381
Merge branch 'master' into luc/stable-heap
luc-blaeser Jun 17, 2024
54266a0
Merge branch 'luc/stable-heap' into luc/stable-heap-merge-object-tagging
luc-blaeser Jun 17, 2024
1fd2b8f
Merge branch 'master' into luc/stable-heap
luc-blaeser Jun 21, 2024
d56083c
Merge branch 'luc/stable-heap' into luc/stable-heap-merge-object-tagging
luc-blaeser Jun 21, 2024
f0f432e
Code refactoring in RTS
luc-blaeser Jun 24, 2024
e7bf60c
Code refactoring in compiler backend
luc-blaeser Jun 24, 2024
5bd4bf2
Merge branch 'master' into luc/stable-heap
luc-blaeser Jun 25, 2024
0ff25ce
Manual merge conflict resolution
luc-blaeser Jun 25, 2024
e83e95b
Code refactoring, RTS project config
luc-blaeser Jun 26, 2024
e00bafb
Make memory check feature compile again
luc-blaeser Jun 27, 2024
49e0bc4
Deprecate `stableVarQuery`
luc-blaeser Jul 8, 2024
cd9588f
Merge branch 'master' into luc/stable-heap
luc-blaeser Jul 8, 2024
b8471c8
Manual merge conflict resolution
luc-blaeser Jul 8, 2024
0a8a13f
Adjust expected test output
luc-blaeser Jul 8, 2024
a210119
EOP: Using a Dedicated Stable Option Type in Persistent State (#4601)
luc-blaeser Jul 12, 2024
d3d9776
EOP: Relaxed Upgrade Compatibility Check (#4602)
luc-blaeser Jul 22, 2024
5ddd166
Merge branch 'master' into luc/stable-heap
luc-blaeser Jul 22, 2024
3b09b35
Merge branch 'master' into luc/stable-heap
luc-blaeser Aug 9, 2024
77d6b84
Manual merge conflict resolution
luc-blaeser Aug 9, 2024
d0ac733
Merge branch 'master' into luc/stable-heap
luc-blaeser Aug 9, 2024
5fb7341
Update benchmark result
luc-blaeser Aug 9, 2024
e0fa86c
Merge branch 'master' into luc/stable-heap
luc-blaeser Aug 19, 2024
6029604
Update benchmark result
luc-blaeser Aug 19, 2024
c325710
Enhanced Orthogonal Persistence (64-Bit without Graph Copy) (#4225)
luc-blaeser Aug 26, 2024
2b5e349
Merge branch 'master' into luc/stable-heap
luc-blaeser Aug 26, 2024
b4e036d
Update change log
luc-blaeser Aug 26, 2024
f609bda
Refine documentation
luc-blaeser Aug 26, 2024
71384a3
Fix documentation
luc-blaeser Aug 26, 2024
ce4fec0
Documentation improvement
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
  •  
  •  
  •  
31 changes: 31 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@

* motoko (`moc`)

* **For beta testing:** Support __enhanced orthogonal persistence__, enabled with new moc flag `--enhanced-orthogonal-persistence` (#4193).

This implements scalable and efficient orthogonal persistence (stable variables) for Motoko:
* The Wasm main memory (heap) is retained on upgrade with new program versions directly picking up this state.
* The Wasm main memory has been extended to 64-bit to scale as large as stable memory in the future.
* The runtime system checks that data changes of new program versions are compatible with the old state.

Implications:
* Upgrades become extremely fast, only depending on the number of types, not on the number of heap objects.
* Upgrades will no longer hit the IC instruction limit, even for maximum heap usage.
* The change to 64-bit increases the memory demand on the heap, in worst case by a factor of two.
* For step-wise release handling, the IC initially only offers a limited capacity of the 64-bit space (e.g. 4GB or 6GB), that will be gradually increased in future to the capacity of stable memory.
* There is moderate performance regression of around 10% for normal execution due to combined related features (precise tagging, change to incremental GC, and handling of compile-time-known data).
* The garbage collector is fixed to incremental GC and cannot be chosen.
* `Float.format(#hex prec, x)` is no longer supported (expected to be very rarely used in practice).
* The debug print format of `NaN` changes (originally `nan`).

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

```
...
"type" : "motoko"
...
"args" : "--enhanced-orthogonal-persistence"
...
```

For more information, see:
* The Motoko design documentation `design/OrthogonalPersistence.md`
* The Motoko user documentation `doc/md/canister-maintenance//upgrades.md`.

* Candid decoding: impose an upper limit on the number of values decoded or skipped in a single candid payload,
as a linear function, `max_values`, of binary payload size.

Expand Down
8 changes: 5 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_NON_INCREMENTAL_RELEASE_RTS MOC_NON_INCREMENTAL_DEBUG_RTS MOC_INCREMENTAL_RELEASE_RTS MOC_INCREMENTAL_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,10 +32,12 @@ 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_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
94 changes: 61 additions & 33 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-prLZVOWV3BFb8/nKHyqZw8neJyBu1gs5d0D56DsDV2o=";
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 @@ -255,10 +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 @@ -268,12 +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,11 +376,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 {
Expand All @@ -384,6 +392,16 @@ rec {
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 @@ -442,23 +460,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 @@ -494,23 +513,33 @@ 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 ];
viper = test_subdir "viper" [ moc nixpkgs.which nixpkgs.openjdk nixpkgs.z3_4_12 ];
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 +583,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 +731,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 +806,9 @@ EOF
check-grammar
check-error-codes
] ++
builtins.attrValues tests ++
builtins.attrValues js;
builtins.attrValues tests
++ builtins.attrValues js
;
};

viperServer = nixpkgs.fetchurl {
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
Loading