Skip to content

feat: ES module snapshotting#17460

Merged
crowlKats merged 16 commits into
denoland:mainfrom
crowlKats:es_module_snapshot
Jan 19, 2023
Merged

feat: ES module snapshotting#17460
crowlKats merged 16 commits into
denoland:mainfrom
crowlKats:es_module_snapshot

Conversation

@crowlKats

@crowlKats crowlKats commented Jan 17, 2023

Copy link
Copy Markdown
Member

This commit adds support for snapshotting ES modules. This is done by
adding an ability to serialize and deserialize a "ModuleMap" and attach it
to the snapshot, using "add_context_data" API.

This has been tested with 400 modules and seems to not have a limit on
the number of modules that might be snapshotted.

@bartlomieju bartlomieju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe to skip handling of modules in non-global realms, would you agree @andreubotella?

Comment thread core/runtime.rs Outdated
Comment thread core/modules.rs Outdated
Comment thread core/modules.rs Outdated
Comment thread core/runtime.rs Outdated
Comment thread core/runtime.rs
Comment thread core/runtime.rs Outdated
@andreubotella

Copy link
Copy Markdown
Contributor

I think it's safe to skip handling of modules in non-global realms, would you agree @andreubotella?

I guess that depends on the use case for module snapshotting. For deno compile / Deploy use cases, a module's initial evaluation might create ShadowRealms which would need to persist state in the snapshot, which might include module state. But if that's not a significant use case for now, then it's fine.

However, in this use case it would probably be good to make sure that any non-GC'd realms have an empty module map when snapshotting. If this PR lands before #15760 I'll make sure to add that check.

Comment thread core/runtime.rs Outdated

@bartlomieju bartlomieju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, exciting to finally land this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants