Skip to content

Commit

Permalink
Add V8.ProduceCodeCache UMA
Browse files Browse the repository at this point in the history
This CL adds V8.ProduceCodeCache UMA to measure the duration of
ProduceCacheInternal. This metric is only recorded when
ProduceCacheOptions is kProduceCodeCache. This metric can be useful to
estimate the impact of the CacheCodeOnIdle feature.

Bug: 1410082
Bug: 1260908
Change-Id: Ia90dce325961c2690a5c4bd20fb83ab5d33cc56a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4191623
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org>
Commit-Queue: Minoru Chikamune <chikamune@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1097708}
  • Loading branch information
chikamune-cr authored and Chromium LUCI CQ committed Jan 27, 2023
1 parent e031758 commit 608248a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions third_party/blink/renderer/bindings/core/v8/v8_code_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "third_party/blink/renderer/bindings/core/v8/v8_code_cache.h"

#include "base/metrics/histogram_functions.h"
#include "build/build_config.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/mojom/v8_cache_options.mojom-blink.h"
Expand Down Expand Up @@ -234,6 +235,7 @@ static void ProduceCacheInternal(
TRACE_EVENT_BEGIN1(kTraceEventCategoryGroup, trace_name, "fileName",
source_url.GetString().Utf8());

base::ElapsedTimer timer;
std::unique_ptr<v8::ScriptCompiler::CachedData> cached_data(
v8::ScriptCompiler::CreateCodeCache(unbound_script));
if (cached_data) {
Expand All @@ -253,6 +255,7 @@ static void ProduceCacheInternal(
cache_handler->SetCachedMetadata(
code_cache_host, V8CodeCache::TagForCodeCache(cache_handler), data,
length);
base::UmaHistogramTimes("V8.ProduceCodeCache", timer.Elapsed());
}

TRACE_EVENT_END1(kTraceEventCategoryGroup, trace_name, "data",
Expand Down
10 changes: 10 additions & 0 deletions tools/metrics/histograms/metadata/v8/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,16 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>

<histogram name="V8.ProduceCodeCache" units="ms" expires_after="2023-06-20">
<owner>chikamune@chromium.org</owner>
<owner>chrome-worker@google.com</owner>
<summary>
Time spent serializing and persisting code (mojo call) for V8 code caching.
Recorded when ProduceCacheInternal() is called. Only recorded when producing
a code cache is required.
</summary>
</histogram>

<histogram name="V8.RegExpBacktracks" units="backtracks"
expires_after="2025-01-01">
<owner>jgruber@chromium.org</owner>
Expand Down

0 comments on commit 608248a

Please sign in to comment.