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

feat: ES module snapshotting #17460

Merged
merged 16 commits into from
Jan 19, 2023
Merged

Conversation

crowlKats
Copy link
Member

@crowlKats crowlKats commented Jan 17, 2023

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.

Copy link
Member

@bartlomieju bartlomieju left a comment

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?

core/runtime.rs Outdated Show resolved Hide resolved
core/modules.rs Outdated Show resolved Hide resolved
core/modules.rs Outdated Show resolved Hide resolved
core/runtime.rs Outdated Show resolved Hide resolved
core/runtime.rs Show resolved Hide resolved
core/runtime.rs Outdated Show resolved Hide resolved
@andreubotella
Copy link
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.

core/runtime.rs Outdated Show resolved Hide resolved
Copy link
Member

@bartlomieju bartlomieju left a comment

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