Offer a way to inspect whether a script or function comes from code cache |
|||||||||
Issue descriptionIn case of cache hits, JavaScript functions are not compiled, but deserialized from cache instead. There has been interest in a way to find out whether caching has been leveraged. V8 already marks the top-level function that originate from cache. This is used to print useful information to stdout with --js-flags=--profile-deserialization V8 currently disables code caching (both producing and consuming) when the debugger (DevTools) is active. Wrt tracing events, code caching is simply part of compilation. Maybe we want to change this? I'm entirely unclear how and what information to surface to the UI. Via tracing, or in DevTools? Somehow annotate functions in DevTools? Or mark them accordingly in the profiler? So the next steps would be: - Correctly mark all functions after deserialization. - Do not disable caching when debugger is active. - Decide on how to surface this information in the UI.
,
Sep 27 2017
,
Sep 27 2017
,
Sep 27 2017
The cache is per-source, but we may not have produced code cache for every function in the script. So there may be functions that do not need to compile as the code originate from cache, and others that do need to compile. The code cache we are talking about is persistent and part of the HTTP cache. I think for users that would care about this detail it is clear what benefits the code cache brings.
,
Sep 27 2017
The following revision refers to this bug: https://chromium.googlesource.com/v8/v8.git/+/5dcedc18c1dec88f0b2a7118fef551de1a45a8ec commit 5dcedc18c1dec88f0b2a7118fef551de1a45a8ec Author: Yang Guo <yangguo@chromium.org> Date: Wed Sep 27 14:32:34 2017 [snapshot] correctly mark SFIs with deserialized code. We used to only mark top-level SFIs with the 'deserialized' bit. Now we do it for every SFI that has cached code. This is the first step to surface caching information in the future. R=cbruni@chromium.org Bug: chromium:769166 Change-Id: I12f21511419ce54fd07a2cc277a65866660c366a Reviewed-on: https://chromium-review.googlesource.com/686715 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#48184} [modify] https://crrev.com/5dcedc18c1dec88f0b2a7118fef551de1a45a8ec/src/snapshot/code-serializer.cc [modify] https://crrev.com/5dcedc18c1dec88f0b2a7118fef551de1a45a8ec/test/cctest/test-serialize.cc
,
Sep 28 2017
If I understand correctly, there are two caches that store scripts - HTTP cache - Cache Storage (aka "service worker cache") Each script cache can also store V8 code caching. I think there's interest in being able to inspect whether code caching was used for both the Cache Storage and HTTP cache cases.
,
Sep 28 2017
Is this the same one as what is discussed on the other thread? E.g. looks like there're two desires: - It'd be great if whether something comes from cached bytecode or not could be indicated in tracing and perhaps in dev tools - It'd be useful to have something like that in resource timings to collect that from wild And this issue is about the former (for the latter Web Perf W3C WG is the right place to discuss). Matt: and yes we'll want that info for both cases. +kouhei, +hiroshige as they're going to look into adding more detailed UMA around V8 code caching.
,
Sep 29 2017
Assigning horo@ per offline discussion. (Still P3 for now, please indicate if this needs higher priority)
,
Oct 2 2017
I created a CL to show the V8 cache information in DevTools: https://chromium-review.googlesource.com/c/chromium/src/+/694405
,
Oct 2 2017
,
Oct 2 2017
Could DevTools + V8 confirm this is the UI we want (comment 9)? And does this meet Facebook's use case?
,
Oct 2 2017
Note that the current caching info is only at the script granularity. If code for a script is cached, really only the top-level function and iifes benefit. We now also have a kProduceFullCodeCache option when compiling the script to cache code for all functions in the script. Once that option is used, we should provide a per-function way to surface caching information.
,
Oct 2 2017
The change in #5 adds the per-function cache info, but that's not exposed yet, mainly because I don't know how to best expose it.
,
Oct 2 2017
If V8 expose Function::Deserialized() method, Blink can check it in InspectorFunctionCallEvent::Data() and can show it in the DevTools Timeline. [1]: https://chromium-review.googlesource.com/c/v8/v8/+/694327 [2]: https://chromium-review.googlesource.com/c/chromium/src/+/694326
,
Oct 3 2017
Nate, Vladan: your feedback's also really appreciated. Also +caseq@ for DevTools UI.
,
Oct 3 2017
@horo, all Devtools related functionality should be exposed via inspector protocol going forward, so I'm not entirely sure whether exposing v8::Function::Deserialized is the right way to do it.
,
Oct 3 2017
I'm not familiar enough with the performance tab. But I think the performance tab is using the infrastructure of TRACE logs same as chrome://tracing, not using the inspector protocol. Is my understanding incorrect? > DevTools team
,
Oct 5 2017
> Nate, Vladan: your feedback's also really appreciated This UI works for us. Ieas for possible improvements: - as you mentioned, seeing which specific functions were de-serialized and which were not would also be useful - you might want to add a tooltip to the UI to explain to other users what "Deserialized" means. Maybe "File was loaded as pre-compiled code from HTTP cache"? - it would be nice to know if the function was de-serialized from bytecode or JITed code
,
Oct 5 2017
We never cached optimized code. With Ignition and TurboFan, this means that we only cache bytecode. It makes no sense to cache optimized code, since these are context-dependent, and since we deserialize into foreign contexts, cached optimized code would probably just deopt all the time.
,
Oct 24 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/f12653d66a5166628b845deabbbec4482e5ea38d commit f12653d66a5166628b845deabbbec4482e5ea38d Author: Tsuyoshi Horo <horo@chromium.org> Date: Tue Oct 24 05:48:01 2017 Show the info of V8 cache and ScriptStream in DevTools Screenshot: crbug.com/769166#c9 Bug: 769166 Change-Id: I87a7b39bedbf22b54daf10356c45bf0eebeccf3d Reviewed-on: https://chromium-review.googlesource.com/694405 Commit-Queue: Tsuyoshi Horo <horo@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Reviewed-by: Alexei Filippov <alph@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Cr-Commit-Position: refs/heads/master@{#511044} [add] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/LayoutTests/http/tests/devtools/service-workers/resources/v8-cache-iframe.html [add] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/LayoutTests/http/tests/devtools/service-workers/resources/v8-cache-script.js [add] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/LayoutTests/http/tests/devtools/service-workers/resources/v8-cache-worker.js [add] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/LayoutTests/http/tests/devtools/service-workers/service-worker-v8-cache-expected.txt [add] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/LayoutTests/http/tests/devtools/service-workers/service-worker-v8-cache.html [modify] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/LayoutTests/http/tests/devtools/tracing/timeline-js/compile-script-expected.txt [modify] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp [modify] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp [modify] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h [modify] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/Source/devtools/front_end/performance_test_runner/TimelineTestRunner.js [modify] https://crrev.com/f12653d66a5166628b845deabbbec4482e5ea38d/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js
,
Oct 25 2017
The patch #20 landed in 64.0.3249.0. $ git find-releases f12653d66a5166628b845deabbbec4482e5ea38d commit f12653d66a5166628b845deabbbec4482e5ea38d was: initially in 64.0.3249.0
,
Jun 25 2018
|
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by kozyatinskiy@chromium.org
, Sep 27 2017