-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[browser] wasm memory snapshot into browser cache #82049
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
Merged
pavelsavara
merged 56 commits into
dotnet:main
from
pavelsavara:browser_memory_snapshot3
Mar 14, 2023
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
ea02d94
wip
pavelsavara c1aa6c3
wip
pavelsavara bf9ef4d
wip
pavelsavara f883a72
Merge branch 'main' into browser_memory_snapshot3
pavelsavara 3fe9aba
wip
pavelsavara f4225aa
Merge branch 'main' into browser_memory_snapshot3
pavelsavara d2e5b49
fix
pavelsavara c409f51
Merge branch 'main' into browser_memory_snapshot3
pavelsavara e695c42
feedback
pavelsavara 1189015
lint
pavelsavara b92c82e
Update src/mono/wasm/memory-snapshot.md
pavelsavara 7ccc8e6
Update src/mono/wasm/memory-snapshot.md
pavelsavara ec762ac
Update src/mono/wasm/memory-snapshot.md
pavelsavara 91c0211
Update src/mono/wasm/memory-snapshot.md
pavelsavara 20d548b
Update src/mono/wasm/memory-snapshot.md
pavelsavara 8e6865c
more linear memory usage and recovery from failure of snapshot use
pavelsavara 7bf7881
feedback
pavelsavara aec9b53
Merge branch 'main' into browser_memory_snapshot3
pavelsavara 5651f37
start runtime twice for unit tests, so that the actual tests is runni…
pavelsavara a16f667
Merge branch 'main' into browser_memory_snapshot3
pavelsavara 31b46ff
wip
pavelsavara 43a73e1
continue loading non-snapshot assets
pavelsavara f49354a
disable adding methods to __indirect_function_table before we take me…
pavelsavara 53781ab
rename startupMemoryCache
pavelsavara 60b2c5a
try to fix threads
pavelsavara 33b6e3e
Merge branch 'main' into browser_memory_snapshot3
pavelsavara 977b46c
whitespace
pavelsavara 933594b
fix
pavelsavara c68c9e8
fix storing memory
pavelsavara fa3e331
assert
pavelsavara c7f913b
- make snapshot hash more resilient
pavelsavara 9cb1b72
fix
pavelsavara d1bbb9c
- renamed memorySnapshotSkippedOrDone
pavelsavara ee4ba76
- rename loadedMemorySnapshot
pavelsavara 83f0032
Merge branch 'main' into browser_memory_snapshot3
pavelsavara 85ac81d
fix
pavelsavara b7790f2
Merge branch 'main' into browser_memory_snapshot3
pavelsavara 3168c42
- internal config exitAfterSnapshot
pavelsavara 4a25447
measure
pavelsavara 5067cf7
Merge branch 'main' into browser_memory_snapshot3
pavelsavara 1761786
fix
pavelsavara 94e931a
fix
pavelsavara 2a7508e
optimize timezone detection
pavelsavara 9759ad8
feedback
pavelsavara 1f4e4c6
fix
pavelsavara e2a2cd4
- enable snapshot in blazor
pavelsavara eaaeaa5
store cache key
pavelsavara bc86ffe
feedback and cleanup
pavelsavara 59a7a56
fix debugging
pavelsavara 6d9f7ee
fix
pavelsavara 3e961d1
Merge branch 'main' into browser_memory_snapshot3
pavelsavara f617787
Update src/mono/wasm/memory-snapshot.md
pavelsavara cfc5acf
Update src/mono/wasm/memory-snapshot.md
pavelsavara c78ef57
Update src/mono/wasm/runtime/assets.ts
pavelsavara 7309e43
Update src/mono/wasm/runtime/assets.ts
pavelsavara 5f8aeef
Merge branch 'main' into browser_memory_snapshot3
pavelsavara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Memory snapshot of the Mono runtime | ||
|
||
We take snapshot of WASM memory after first cold start at run time. | ||
We store it on the client side in the browser cache. | ||
For subsequent runs with the same configuration and same assets, we use the snapshot | ||
instead of downloading everything again and doing the runtime startup again. | ||
These subsequent starts are significantly faster. | ||
|
||
### Implementation details | ||
|
||
- the consistency of inputs (configuration and assets) with the snapshot is done by calculating SHA256 of the inputs. | ||
- the DLLs and other downloaded assets each have SHA256 which is used to validate 'integrity' by the browser. | ||
- the mono-config has field `assetsHash` which is summary SHA256 of all the assets. | ||
- the configuration could be changed programmatically and so we calculate the hash at the runtime, just before taking snapshot. | ||
- the snapshot is taken just after we initialize the Mono runtime. | ||
- before cwraps are initialized (they would be initialized again on subsequent start). | ||
- after loading all the DLLs into memory. | ||
- after loading ICU and timezone data. | ||
- after applying environment variables and other runtime options. | ||
- before any worker threads initialization. | ||
- before any JavaScript interop initialization. | ||
- before any Managed code executes. | ||
- therefore we do not expect to store any application state in the snapshot. | ||
|
||
### How to opt out | ||
You can turn this feature of by calling `withStartupMemoryCache (false)` on [dotnet API](https://github.com/dotnet/runtime/blob/main/src/mono/wasm/runtime/dotnet.d.ts). | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.