Skip to content

Conversation

rachgreen33
Copy link
Contributor

@rachgreen33 rachgreen33 commented Sep 16, 2025

This change aligns with the V8 team's recommendation of setting flags this way through their API, rather than directly referencing v8::internal::v8_flags.

@rachgreen33 rachgreen33 changed the title Feat: Update V8 flag initialization to use V8 API, and restore default liftoff behavior Chore: Update V8 flag initialization to use V8 API, and restore default liftoff behavior Sep 16, 2025
static wasm::own<wasm::Engine> engine;

std::call_once(init, []() {
::v8::internal::v8_flags.liftoff = false;
Copy link
Member

Choose a reason for hiding this comment

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

But why? It was written years ago, but at the time loading Wasm module wouldn't complete before all compilation phases completed, so Liftoff compilation was wasteful. Is that not the case anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the callout on this. I discussed with Matt and we do want to keep this disabled - Updated.

Copy link
Contributor

@mpwarres mpwarres Sep 17, 2025

Choose a reason for hiding this comment

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

Keeping it SGTM, but I think it would be helpful to add a comment that provides some context on why we set it. Internal bug b/278233034 contains some pointers to past discussions. I'd suggest something like: "Disable Liftoff compiler to force optimized JIT up-front."

Copy link
Member

Choose a reason for hiding this comment

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

Again, this is based on tests from years ago, but TurboFan was always blocking loading of Wasm modules, and this flag doesn't affect that. What it does is that it skips Liftoff compilation that would be discarded in favor of TurboFan anyway... It would be good to verify that's still the case, though.

There are some docs for V8 here: https://v8.dev/docs/wasm-compilation-pipeline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want Turbofan to block on loading of Wasm modules, right? Thanks for the docs link, it aligns with discussion above: --no-liftoff sets the "TurboFan only" mode. If liftoff is enabled, calls can immediately use the compiled code, and then re-compilation with TurboFan is triggered in the background only after a certain threshold of calls.

@rachgreen33 rachgreen33 changed the title Chore: Update V8 flag initialization to use V8 API, and restore default liftoff behavior Chore: Update V8 flag initialization to use V8 API Sep 16, 2025
Signed-off-by: Rachel Green <[email protected]>
@rachgreen33 rachgreen33 marked this pull request as ready for review September 17, 2025 17:18
Copy link
Contributor

@mpwarres mpwarres left a comment

Choose a reason for hiding this comment

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

Also worth documenting in the PR description that V8 team recommends setting flags this way rather than directly referencing v8::internal::v8_flags.

static wasm::own<wasm::Engine> engine;

std::call_once(init, []() {
::v8::internal::v8_flags.liftoff = false;
Copy link
Contributor

@mpwarres mpwarres Sep 17, 2025

Choose a reason for hiding this comment

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

Keeping it SGTM, but I think it would be helpful to add a comment that provides some context on why we set it. Internal bug b/278233034 contains some pointers to past discussions. I'd suggest something like: "Disable Liftoff compiler to force optimized JIT up-front."

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