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

perf: warm expensive init code at snapshot time #22714

Merged
merged 6 commits into from Mar 22, 2024

Conversation

mmastrac
Copy link
Member

@mmastrac mmastrac commented Mar 5, 2024

WIP -- slightly different approach to similar changes in #22386

Note that this doesn't use a warmup script -- we are actually just doing more work at snapshot time.

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

I like this approach more. bootstrap code ∝ startup time

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.

Everything looks okay to me, but this completely breaks cargo build --features __runtime_js_sources.

When I try to run a file:

console.log(Deno);

I get this:

$ cargo build --features __runtime_js_sources
$ ./target/debug/deno run foo.js

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.41.2
Args: ["./target/debug/deno", "run", "foo.js"]

thread 'main' panicked at /Users/ib/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_core-0.269.0/runtime/jsruntime.rs:603:9:
Failed to initialize a JsRuntime: TypeError: Cannot read properties of undefined (reading 'length')
    at Object.internals.__bootstrapNodeProcess (node:process:888:30)
    at initialize (ext:deno_node/02_init.js:30:15)
    at ext:runtime_main/js/99_main.js:917:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Since we're working on a lot of Node compat APIs at the moment, we should preserve __runtime_js_sources working.

@mmastrac
Copy link
Member Author

@bartlomieju Confirmed that __runtime_js_sources continues to work with this patch.

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

Awesome! Excited to see its impact

@mmastrac mmastrac enabled auto-merge (squash) March 22, 2024 20:21
@mmastrac mmastrac merged commit 08ec6e5 into denoland:main Mar 22, 2024
17 checks passed
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.

None yet

4 participants