WebAssembly optimized code caching?

36 views
Skip to first unread message

Michael Hagar

unread,
Sep 18, 2023, 11:09:21 AM9/18/23
to v8-dev
Is the description here : https://v8.dev/docs/wasm-compilation-pipeline#code-caching still accurate?

I was trying to confirm that using WebAssembly.compileStreaming would cache the optimized code, but I couldn't find the v8.wasm.cachedModule logs in the trace, nor the v8.wasm.moduleCacheHit logs.

Is there any case where Chrome will cache optimized WASM code in the case that WebAssembly.instantiate is used? Or does it strictly require that WebAssembly.compileStreaming or WebAssembly.instantiateStreaming be used?

Andreas Haas

unread,
Sep 18, 2023, 11:21:44 AM9/18/23
to v8-...@googlegroups.com
Hi,

The description should still be accurate. Did you make sure that enough code gets optimized to trigger caching?

Code does not get cached for WebAssembly.instantiate because we use the url of the wasm module as the cache key, and with WebAssembly.instantiate we don't know the url where the module came from.

Cheers, Andreas

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/0305cb61-6162-4cd1-adde-226be3249ff9n%40googlegroups.com.


--

Andreas Haas

Software Engineer

ah...@google.com


Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Liana Sebastian

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.

    

This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.


Michael Hagar

unread,
Sep 18, 2023, 11:34:36 AM9/18/23
to v8-dev
Thanks Andreas - what confused me is this comment on the Firefox bug tracker: https://bugzilla.mozilla.org/show_bug.cgi?id=1763375#c1 . I took that to mean that Chrome would cache compiled code for regular WebAssembly.instantiate, but I guess that's not the case, and it's only for the streaming functions.

When you say "enough code", what are the current thresholds for caching the module?

Andreas Haas

unread,
Sep 18, 2023, 11:40:49 AM9/18/23
to v8-...@googlegroups.com
Hi,

The threshold is defined in [1]. The Firefox issue is talking about a different caching, that I assume you are not talking about. There is an in-process cache of wasm modules, so if you compile the same module twice, then the second compilation will just be a cache lookup. But when you restart Chrome, or open a different web page, then this cache is not available.

Cheers, Andreas


Reply all
Reply to author
Forward
0 new messages