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

v8 is bailing out of caching bytecode when source file contains 'use asm' #55

Open
naugtur opened this issue Jul 29, 2022 · 0 comments
Open

Comments

@naugtur
Copy link

naugtur commented Jul 29, 2022

Background:

I've been tracing performance of a service-worker waking up after it's already been running before.
The code in the service worker is loaded via https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts
It's bundled and the bundle is split into chunks.

What I've found is one of the chunks taking significantly longer to compile despite being similar size.
v8compileasm
The difference is that one chunk is not cached in v8 bytecode cache.

After bisecting it for a while I found the culprit inside borc/src/decoder.asm.js

The issue:

Existence of 'use asm' anywhere in the bundle causes v8 to bail out from caching bytecode for the entire file.
Removing 'use asm' is enough to fix it.

This might also be an argument for switching to rust+wasm, but it seems removing 'use asm' is a decent quick fix.

  • I did not test in a regular website, just a service worker behind an extension. The code path it takes in v8 seems to be the same though.
  • Removing 'use asm' may have negative impact on performance in FireFox if they kept their asm code paths maintained.

To be clear: I have no expectations about actions from your side. Sharing my findings. I'm here if you need more details on how I got this result and how to test further.

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

No branches or pull requests

1 participant