New issue
Advanced search Search tips

Issue 719172 link

Starred by 33 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Feature

Blocked on:
issue 719007



Sign in to add a comment

Implicit caching of WebAssembly compilation artifacts

Project Member Reported by evan....@gmail.com, May 6 2017

Issue description

What steps will reproduce the problem?
(1) Load http://webassembly.org/demo/Tanks/ in Chrome 58.0.3029.96
(2) Load http://webassembly.org/demo/Tanks/ in Firefox 53.0.2
(3) Compare load times

What is the expected result?

The time to load the demo in Chrome is similar to or better than the time to load the demo in Firefox.

What happens instead?

Chrome loads the demo in 11 seconds but Firefox loads the demo in 5 seconds (as measured by time-to-game). It appears that Chrome is failing to cache the compilation of the WebAssembly module. Capturing a flame graph in Chrome shows a function called "doNativeWasm" taking over 8 seconds before the game starts executing code. I'm assuming that's the WebAssembly module being compiled.

 
Components: Blink>JavaScript>WebAssembly

Comment 2 by danno@chromium.org, May 7 2017

Cc: clemensh@chromium.org ahaas@chromium.org
Owner: bradnelson@chromium.org
Status: Assigned (was: Untriaged)
I see that time to first line of main (AOT) is same for my app with or without indexeddb (in latest canary M62). The module is getting loaded from indexeddb (after enabling the enable-webassembly structured cloning flag which is off by default) but the performance does not change. Wiping indexeddb clean does not help too.
Perhaps this feature does not work in WebWorker yet in latest Canary. (even after enabling the flag)
We too are facing this issue, Can Google Team  please prioritise this issue ?
Blockedon: 719007
Labels: -Pri-3 Pri-2

Comment 7 by pwnall@chromium.org, Nov 30 2017

#6: I was under the impression that  Issue 719007  (which I'm working on) is needed to get WASM module storage without the WASM structured cloning flag. While the current serialization format (used to serialize WASM modules when the flag is set) will not be supported in the final implementation, it should still be caching WASM compilation.

I browsed through code down this path, which seems to suggest that compiled output is being serialized.

v8::ValueSerializer::WriteValue
-> v8::internal::ValueSerializer::WriteObject
-> v8::internal::ValueSerializer::WriteWasmModule
-> v8::internal::wasm::NativeModuleSerializer::SerializeWasmModule
-> v8::internal::CodeSerializer::Serialize

If I'm correct, this bug can be fixed independently of 719007. If not, can you please let me know what I'm getting wrong?
 Issue 719007  is now marked as WontFix. What does that mean for the fate of this issue? It's still an extremely important issue for us at Figma because it's blocking us from giving our users a good experience.
Cc: bbudge@chromium.org
This issue is also blocking us at Superhuman to deploy some of our web assembly modules that is meant to increase the performance. I am pretty sure there are a tonne of other products/projects waiting on this.

Thank you, appreciate it!
- BK

Sent via Superhuman ( https://sprh.mn/?vip=bhavesh@superhuman.com )

On Wed, Jun 06, 2018 at 5:37 PM, evan.… < monorail+v2.4223502460@chromium.org > wrote:
Owner: bbudge@chromium.org
We're looking at a different caching approach which we think will work better for developers and may be more likely to find support in other browsers as well. I will create the tracking bug for this work soon and reference it here.
That sounds promising. Is it already in the Chrome Canary? If not, which Chrome release (which month/year) would be the candidate? I think this is a crucial feature.

I would like to remind you the defunct NaCl did a better job of caching the compiled code. The Webassembly is supposed to do better, isn't it? 
Project Member

Comment 13 by bugdroid1@chromium.org, Aug 16

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0155acba99c2fee96a227607eb6bc2b1f49bd16a

commit 0155acba99c2fee96a227607eb6bc2b1f49bd16a
Author: Bill Budge <bbudge@chromium.org>
Date: Thu Aug 16 16:27:02 2018

[blink] Only create metadata handler for document RawResources.

- RawResource is used for several non-text resources, as well as
  document resources. The cached metadata handling has been set up
  for a document's inline scripts. This makes it difficult to cache
  metadata properly for other RawResources, such as WebAssembly
  modules. This change only creates SourceKeyedMetadataHandler for
  RawResources whose type is kMainResource.
- Renames RawResource::CacheHandler to InlineScriptCacheHandler so
  it doesn't hide the Resource::CacheHandler method, and so we can
  later add other kinds of metadata handlers.

Bug: chromium:719172
Change-Id: I53f361a0df48dc9d73780971e3408dfff08de518
Reviewed-on: https://chromium-review.googlesource.com/1173496
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583684}
[modify] https://crrev.com/0155acba99c2fee96a227607eb6bc2b1f49bd16a/third_party/blink/renderer/core/loader/document_loader.cc
[modify] https://crrev.com/0155acba99c2fee96a227607eb6bc2b1f49bd16a/third_party/blink/renderer/platform/loader/fetch/raw_resource.cc
[modify] https://crrev.com/0155acba99c2fee96a227607eb6bc2b1f49bd16a/third_party/blink/renderer/platform/loader/fetch/raw_resource.h

Project Member

Comment 14 by bugdroid1@chromium.org, Aug 17

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/cc081ca9aefcc65fa4dcbbeb0a7c80c0f5e5421f

commit cc081ca9aefcc65fa4dcbbeb0a7c80c0f5e5421f
Author: Bill Budge <bbudge@chromium.org>
Date: Fri Aug 17 20:01:00 2018

[blink] Add a ScriptCachedMetadataHandler class.

- Moves ScriptResource::SingleCachedMetadataHandlerImpl out of
  ScriptResource and into the blink namespace so it can be used by other
  script-like resources.
- Creates this CacheHandler type for RawResource type kRaw, which will
  be needed for WASM modules.

Bug: chromium:719172
Change-Id: I34a2740310d2d3f4ccb0cea1bb664db0b9c53f5e
Reviewed-on: https://chromium-review.googlesource.com/1174903
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584159}
[modify] https://crrev.com/cc081ca9aefcc65fa4dcbbeb0a7c80c0f5e5421f/third_party/blink/renderer/core/loader/resource/script_resource.cc
[modify] https://crrev.com/cc081ca9aefcc65fa4dcbbeb0a7c80c0f5e5421f/third_party/blink/renderer/core/loader/resource/script_resource.h
[modify] https://crrev.com/cc081ca9aefcc65fa4dcbbeb0a7c80c0f5e5421f/third_party/blink/renderer/platform/loader/BUILD.gn
[modify] https://crrev.com/cc081ca9aefcc65fa4dcbbeb0a7c80c0f5e5421f/third_party/blink/renderer/platform/loader/fetch/raw_resource.cc
[modify] https://crrev.com/cc081ca9aefcc65fa4dcbbeb0a7c80c0f5e5421f/third_party/blink/renderer/platform/loader/fetch/raw_resource.h
[add] https://crrev.com/cc081ca9aefcc65fa4dcbbeb0a7c80c0f5e5421f/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.cc
[add] https://crrev.com/cc081ca9aefcc65fa4dcbbeb0a7c80c0f5e5421f/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h

Project Member

Comment 15 by bugdroid1@chromium.org, Sep 28

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4

commit d64546bc9ceeeac31127eca8b64b4722c3ebb8d4
Author: Bill Budge <bbudge@chromium.org>
Date: Fri Sep 28 16:06:47 2018

[caching] Add WebAssembly cache

- Modifies Mojo code caching API to specify JS or WASM cache.
- Adds WebAssembly GeneratedCodeCache.

Bug: chromium:719172
Change-Id: Ie7dec8112a8e6cea7c576e2e502683bba0bb3d4a
Reviewed-on: https://chromium-review.googlesource.com/1235283
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595107}
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/browser/browsing_data/storage_partition_http_cache_data_remover.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/browser/code_cache/generated_code_cache_context.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/browser/code_cache/generated_code_cache_context.h
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/browser/renderer_host/code_cache_host_impl.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/browser/renderer_host/code_cache_host_impl.h
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/browser/storage_partition_impl_unittest.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/renderer/loader/code_cache_loader_impl.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/renderer/loader/code_cache_loader_impl.h
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/renderer/renderer_blink_platform_impl.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/content/renderer/renderer_blink_platform_impl.h
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/public/mojom/loader/code_cache.mojom
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/public/platform/code_cache_loader.h
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/public/platform/platform.h
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/renderer/platform/loader/fetch/resource.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/renderer/platform/loader/fetch/resource.h
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/renderer/platform/loader/fetch/resource_loader.h
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/renderer/platform/loader/fetch/resource_test.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler_test.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/renderer/platform/testing/code_cache_loader_mock.cc
[modify] https://crrev.com/d64546bc9ceeeac31127eca8b64b4722c3ebb8d4/third_party/blink/renderer/platform/testing/code_cache_loader_mock.h

Great work Bill! Very exciting!

Project Member

Comment 17 by bugdroid1@chromium.org, Oct 4

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f27eb2437ce09336e6c175965e72021ee0800b6d

commit f27eb2437ce09336e6c175965e72021ee0800b6d
Author: Bill Budge <bbudge@chromium.org>
Date: Thu Oct 04 18:45:41 2018

[caching] Allow WebAssembly fetches to use code cache.

Fixes a few problems preventing the WASM cache from working.
- Routes raw resource metadata to the WASM code cache.
- Separates JS and WASM generated code caches. They can't share
  a directory.
- Allow cached metadata to be set on RawResources.

Bug: chromium:719172
Change-Id: I0f3709340948bb25d134504bb03632eb1ce24196
Reviewed-on: https://chromium-review.googlesource.com/c/1255963
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596779}
[modify] https://crrev.com/f27eb2437ce09336e6c175965e72021ee0800b6d/content/browser/code_cache/generated_code_cache_context.cc
[modify] https://crrev.com/f27eb2437ce09336e6c175965e72021ee0800b6d/third_party/blink/renderer/platform/loader/fetch/raw_resource.cc
[modify] https://crrev.com/f27eb2437ce09336e6c175965e72021ee0800b6d/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc
[modify] https://crrev.com/f27eb2437ce09336e6c175965e72021ee0800b6d/third_party/blink/renderer/platform/loader/fetch/resource_loader.h

Project Member

Comment 18 by bugdroid1@chromium.org, Oct 5

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/ca3220c64954260da79d23c8566ec5e9dbe57f96

commit ca3220c64954260da79d23c8566ec5e9dbe57f96
Author: Bill Budge <bbudge@chromium.org>
Date: Fri Oct 05 21:24:46 2018

[wasm] Expose function IsSupportedVersion

- Exposes IsSupportedVersion function which compares serialized
  version to current Wasm version.
- Tweaks the comments on serialization to match the code.

Bug: chromium:719172
Change-Id: I76df9605aee16fd98cd82b54dba2e9acbd56b41b
Reviewed-on: https://chromium-review.googlesource.com/c/1265141
Reviewed-by: Ben Smith <binji@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56420}
[modify] https://crrev.com/ca3220c64954260da79d23c8566ec5e9dbe57f96/src/wasm/wasm-serialization.cc
[modify] https://crrev.com/ca3220c64954260da79d23c8566ec5e9dbe57f96/src/wasm/wasm-serialization.h

Project Member

Comment 19 by bugdroid1@chromium.org, Oct 12

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/9ecd4545fe424146f0a5fa5dbcaccd775048131a

commit 9ecd4545fe424146f0a5fa5dbcaccd775048131a
Author: Bill Budge <bbudge@chromium.org>
Date: Fri Oct 12 21:34:45 2018

[api] Add WebAssembly caching API

- Adds embedder callback to notify fully tiered compilation is finished,
  returning a WasmCompiledModule for serialization.
- Adds function to pass previously compiled bytes into WASM streaming
  compilation, for deserialization.
- Plumbs this API through StreamingDecoder.

Bug: chromium:719172
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Ibe376f3a8ccfa90fda730ef4ff6628a1532da45c
Reviewed-on: https://chromium-review.googlesource.com/c/1252884
Reviewed-by: Adam Klein <adamk@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56617}
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/include/v8.h
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/src/wasm/module-compiler.cc
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/src/wasm/module-compiler.h
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/src/wasm/streaming-decoder.cc
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/src/wasm/streaming-decoder.h
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/src/wasm/wasm-js.cc
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/src/wasm/wasm-js.h
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/src/wasm/wasm-objects.h
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/test/cctest/wasm/test-streaming-compilation.cc
[modify] https://crrev.com/9ecd4545fe424146f0a5fa5dbcaccd775048131a/test/unittests/wasm/streaming-decoder-unittest.cc

Project Member

Comment 20 by bugdroid1@chromium.org, Oct 25

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/9fa085e59a7de104deb550112784a359f80b8991

commit 9fa085e59a7de104deb550112784a359f80b8991
Author: Bill Budge <bbudge@chromium.org>
Date: Thu Oct 25 15:56:24 2018

[wasm] When bypassing compilation, deserialize in a context

- Moves call to DeserializeNativeModule into SaveContext to avoid
  a crash in IsWasmCodegenAllowed.

Bug: chromium:719172
Change-Id: Idd367824a325fc684f29e335b0c07e515f9fdad3
Reviewed-on: https://chromium-review.googlesource.com/c/1298375
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56997}
[modify] https://crrev.com/9fa085e59a7de104deb550112784a359f80b8991/src/wasm/module-compiler.cc

Labels: -Type-Bug Type-Feature
Summary: Implicit caching of WebAssembly compilation artifacts (was: Chrome fails to cache WebAssembly compilation)
Project Member

Comment 22 by bugdroid1@chromium.org, Nov 20

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4d028f1266f84e97733b73c8ffe451e529a3bf01

commit 4d028f1266f84e97733b73c8ffe451e529a3bf01
Author: Bill Budge <bbudge@chromium.org>
Date: Tue Nov 20 15:05:12 2018

[WebAssembly] Add blink::feature kWasmCodeCache.

- Adds kWasmCodeCache to blink::features.
- Checks if enabled before creating the cache in the browser.
- Checks if enabled before fetching from cache in renderer.

This is patterned after the Javascript IsolatedCodeCache feature.

Bug: chromium:719172
Change-Id: I1ffea5d8029b2b550c45e3ba25821889c7c2183c
Reviewed-on: https://chromium-review.googlesource.com/c/1341071
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609705}
[modify] https://crrev.com/4d028f1266f84e97733b73c8ffe451e529a3bf01/content/browser/code_cache/generated_code_cache_context.cc
[modify] https://crrev.com/4d028f1266f84e97733b73c8ffe451e529a3bf01/content/browser/storage_partition_impl_unittest.cc
[modify] https://crrev.com/4d028f1266f84e97733b73c8ffe451e529a3bf01/content/child/runtime_features.cc
[modify] https://crrev.com/4d028f1266f84e97733b73c8ffe451e529a3bf01/third_party/blink/common/features.cc
[modify] https://crrev.com/4d028f1266f84e97733b73c8ffe451e529a3bf01/third_party/blink/public/common/features.h
[modify] https://crrev.com/4d028f1266f84e97733b73c8ffe451e529a3bf01/third_party/blink/public/platform/web_runtime_features.h
[modify] https://crrev.com/4d028f1266f84e97733b73c8ffe451e529a3bf01/third_party/blink/renderer/platform/exported/web_runtime_features.cc
[modify] https://crrev.com/4d028f1266f84e97733b73c8ffe451e529a3bf01/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc
[modify] https://crrev.com/4d028f1266f84e97733b73c8ffe451e529a3bf01/third_party/blink/renderer/platform/runtime_enabled_features.json5

Sign in to add a comment