Background compile JS extension scripts injected at document start [chromium/src : main]

0 views
Skip to first unread message

Leszek Swirski (Gerrit)

unread,
Dec 18, 2025, 5:20:23 AM (yesterday) Dec 18
to Luis Pardo, Justin Lulejian, Emmanuel Romero Ruiz, Jeremy Roman, Tim, Sohail Rajdev, Devlin Cronin, Chromium LUCI CQ, Chromium Metrics Reviews, Kentaro Hara, Raphael Kubo da Costa, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, blink-rev...@chromium.org, loading-rev...@chromium.org, asvitkine...@chromium.org, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, blink-revi...@chromium.org
Attention needed from Devlin Cronin, Jeremy Roman, Justin Lulejian and Luis Pardo

Leszek Swirski added 1 comment

File third_party/blink/renderer/bindings/core/v8/script_streamer.cc
Line 1076, Patchset 17: base::UmaHistogramBoolean("WebCore.Scripts.InlineStreamerTimedOut",
timed_out_);
Leszek Swirski . unresolved

similarly, would be nice to handle UMA histograms consistently inside or outside this method

Luis Pardo

Do you mean emitting one histogram for a real inline scripts and another for extension scripts? The `Source` caller doesn't know which kind of script it is compiling and we don't need it for extensions scripts since we already record the compilation time for scripts that timedout and scripts that didn't. I added the histogram name as a class field and emitting the histogram only when the name is explicitly set.

Leszek Swirski

we don't need it for extensions scripts since we already record the compilation time for scripts that timedout and scripts that didn't.

This was exactly what I meant, it's an awkward inconsistency that extension scripts collect time-out histograms from the outside, while non-extension scripts collect it in here. If you're exposing timeout state, then probably it's best to collect this from the outside for non-extension inline scripts too, with a similar method to your EmitCompilationHistograms here.

Open in Gerrit

Related details

Attention is currently required from:
  • Devlin Cronin
  • Jeremy Roman
  • Justin Lulejian
  • Luis Pardo
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Idc6fc4e4f0a57f197ccba6ef04a77bba58c0ec8e
Gerrit-Change-Number: 6820371
Gerrit-PatchSet: 18
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Sohail Rajdev <sora...@microsoft.com>
Gerrit-Reviewer: Tim <tjud...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Emmanuel Romero Ruiz <emro...@microsoft.com>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Attention: Justin Lulejian <jlul...@chromium.org>
Gerrit-Attention: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Attention: Jeremy Roman <jbr...@chromium.org>
Gerrit-Comment-Date: Thu, 18 Dec 2025 10:20:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Luis Pardo <lpardo...@microsoft.com>
Comment-In-Reply-To: Leszek Swirski <les...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Luis Pardo (Gerrit)

unread,
Dec 18, 2025, 2:45:21 PM (16 hours ago) Dec 18
to Justin Lulejian, Emmanuel Romero Ruiz, Leszek Swirski, Jeremy Roman, Tim, Sohail Rajdev, Devlin Cronin, Chromium LUCI CQ, Chromium Metrics Reviews, Kentaro Hara, Raphael Kubo da Costa, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, blink-rev...@chromium.org, loading-rev...@chromium.org, asvitkine...@chromium.org, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, blink-revi...@chromium.org
Attention needed from Devlin Cronin, Emmanuel Romero Ruiz, Jeremy Roman, Justin Lulejian and Leszek Swirski

Luis Pardo added 2 comments

Patchset-level comments
File-level comment, Patchset 19 (Latest):
Luis Pardo . resolved

@jbr...@chromium.org @les...@chromium.org @rdevlin...@chromium.org Thanks for the reviews. I'll be unresponsive starting tomorrow, I'll leave this in auto-submit and hopefully it can be merged as is. @emro...@microsoft.com will be taking over this work and he could address any remaining feedback in a follow-up CL.

File third_party/blink/renderer/bindings/core/v8/script_streamer.cc
Line 1076, Patchset 17: base::UmaHistogramBoolean("WebCore.Scripts.InlineStreamerTimedOut",
timed_out_);
Leszek Swirski . unresolved

similarly, would be nice to handle UMA histograms consistently inside or outside this method

Luis Pardo

Do you mean emitting one histogram for a real inline scripts and another for extension scripts? The `Source` caller doesn't know which kind of script it is compiling and we don't need it for extensions scripts since we already record the compilation time for scripts that timedout and scripts that didn't. I added the histogram name as a class field and emitting the histogram only when the name is explicitly set.

Leszek Swirski

we don't need it for extensions scripts since we already record the compilation time for scripts that timedout and scripts that didn't.

This was exactly what I meant, it's an awkward inconsistency that extension scripts collect time-out histograms from the outside, while non-extension scripts collect it in here. If you're exposing timeout state, then probably it's best to collect this from the outside for non-extension inline scripts too, with a similar method to your EmitCompilationHistograms here.

Luis Pardo

Added a TODO for now. @emro...@microsoft.com can follow-up in another CL.

Open in Gerrit

Related details

Attention is currently required from:
  • Devlin Cronin
  • Emmanuel Romero Ruiz
  • Jeremy Roman
  • Justin Lulejian
  • Leszek Swirski
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Idc6fc4e4f0a57f197ccba6ef04a77bba58c0ec8e
Gerrit-Change-Number: 6820371
Gerrit-PatchSet: 19
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Sohail Rajdev <sora...@microsoft.com>
Gerrit-Reviewer: Tim <tjud...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Emmanuel Romero Ruiz <emro...@microsoft.com>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Attention: Justin Lulejian <jlul...@chromium.org>
Gerrit-Attention: Jeremy Roman <jbr...@chromium.org>
Gerrit-Attention: Emmanuel Romero Ruiz <emro...@microsoft.com>
Gerrit-Attention: Leszek Swirski <les...@chromium.org>
Gerrit-Comment-Date: Thu, 18 Dec 2025 19:45:10 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Justin Lulejian (Gerrit)

unread,
Dec 18, 2025, 3:59:25 PM (15 hours ago) Dec 18
to Luis Pardo, Emmanuel Romero Ruiz, Leszek Swirski, Jeremy Roman, Tim, Sohail Rajdev, Devlin Cronin, Chromium LUCI CQ, Chromium Metrics Reviews, Kentaro Hara, Raphael Kubo da Costa, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, blink-rev...@chromium.org, loading-rev...@chromium.org, asvitkine...@chromium.org, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, blink-revi...@chromium.org
Attention needed from Devlin Cronin, Emmanuel Romero Ruiz, Jeremy Roman, Leszek Swirski and Luis Pardo

Justin Lulejian added 4 comments

Patchset-level comments
Justin Lulejian . resolved

Thanks Luis! Had a couple comments.

Commit Message
Line 12, Patchset 19 (Latest):compilation in the background thread earlier in the compilation process,
this CL, makes changes to extensions/ and blink/ to make this happen:
Justin Lulejian . unresolved

```suggestion
compilation in the background thread earlier in the compilation process. This CL makes changes to extensions/ and blink/ to make this happen:

```

File third_party/blink/renderer/core/exported/extension_script_streamer.cc
Line 23, Patchset 19 (Latest):// Executed on the main thread only
Justin Lulejian . unresolved
File tools/metrics/histograms/metadata/extensions/histograms.xml
Line 329, Patchset 19 (Latest): Number of scripts injected at document start that were eligible for
background compilation.
Justin Lulejian . unresolved

Let's document precisely when a histogram is emitted, in addition to what is emitted[[1]](https://chromium.googlesource.com/chromium/src/tools/+/HEAD/metrics/histograms/README.md#State-When-It-Is-Recorded). So let's do that for each new histogram. For example:

```suggestion
Number of scripts to be injected at document start that were eligible for
background compilation.
    Emitted when `extensions_features::kExtensionsBackgroundCompilation` is
enabled, the navigation is ready to commit, and the scripts have started
streaming to v8 for compilation.
```

If the histograms are so closely related that they'd probably be added/removed together (example: `...EligibleScriptsPercentage`) I think it's fine to say:

 `Emitted at the same time as Extensions.BackgroundCompileInjectedScripts.EligibleScriptsCount`.
Open in Gerrit

Related details

Attention is currently required from:
  • Devlin Cronin
  • Emmanuel Romero Ruiz
  • Jeremy Roman
  • Leszek Swirski
  • Luis Pardo
Gerrit-Attention: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Attention: Jeremy Roman <jbr...@chromium.org>
Gerrit-Attention: Emmanuel Romero Ruiz <emro...@microsoft.com>
Gerrit-Attention: Leszek Swirski <les...@chromium.org>
Gerrit-Comment-Date: Thu, 18 Dec 2025 20:59:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Luis Pardo (Gerrit)

unread,
Dec 18, 2025, 4:52:01 PM (14 hours ago) Dec 18
to Justin Lulejian, Emmanuel Romero Ruiz, Leszek Swirski, Jeremy Roman, Tim, Sohail Rajdev, Devlin Cronin, Chromium LUCI CQ, Chromium Metrics Reviews, Kentaro Hara, Raphael Kubo da Costa, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, blink-rev...@chromium.org, loading-rev...@chromium.org, asvitkine...@chromium.org, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, blink-revi...@chromium.org
Attention needed from Devlin Cronin, Emmanuel Romero Ruiz, Jeremy Roman, Justin Lulejian and Leszek Swirski

Luis Pardo voted and added 3 comments

Votes added by Luis Pardo

Auto-Submit+1

3 comments

Commit Message
Line 12, Patchset 19:compilation in the background thread earlier in the compilation process,

this CL, makes changes to extensions/ and blink/ to make this happen:
Justin Lulejian . resolved

```suggestion
compilation in the background thread earlier in the compilation process. This CL makes changes to extensions/ and blink/ to make this happen:

```

Luis Pardo

Done

File third_party/blink/renderer/core/exported/extension_script_streamer.cc
Line 23, Patchset 19:// Executed on the main thread only
Justin Lulejian . resolved
Luis Pardo

Done

File tools/metrics/histograms/metadata/extensions/histograms.xml
Line 329, Patchset 19: Number of scripts injected at document start that were eligible for
background compilation.
Justin Lulejian . resolved

Let's document precisely when a histogram is emitted, in addition to what is emitted[[1]](https://chromium.googlesource.com/chromium/src/tools/+/HEAD/metrics/histograms/README.md#State-When-It-Is-Recorded). So let's do that for each new histogram. For example:

```suggestion
Number of scripts to be injected at document start that were eligible for
background compilation.
    Emitted when `extensions_features::kExtensionsBackgroundCompilation` is
enabled, the navigation is ready to commit, and the scripts have started
streaming to v8 for compilation.
```

If the histograms are so closely related that they'd probably be added/removed together (example: `...EligibleScriptsPercentage`) I think it's fine to say:

 `Emitted at the same time as Extensions.BackgroundCompileInjectedScripts.EligibleScriptsCount`.
Luis Pardo

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Devlin Cronin
  • Emmanuel Romero Ruiz
  • Jeremy Roman
  • Justin Lulejian
  • Leszek Swirski
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Idc6fc4e4f0a57f197ccba6ef04a77bba58c0ec8e
Gerrit-Change-Number: 6820371
Gerrit-PatchSet: 20
Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
Gerrit-Reviewer: Sohail Rajdev <sora...@microsoft.com>
Gerrit-Reviewer: Tim <tjud...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Emmanuel Romero Ruiz <emro...@microsoft.com>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Attention: Justin Lulejian <jlul...@chromium.org>
Gerrit-Attention: Jeremy Roman <jbr...@chromium.org>
Gerrit-Attention: Emmanuel Romero Ruiz <emro...@microsoft.com>
Gerrit-Attention: Leszek Swirski <les...@chromium.org>
Gerrit-Comment-Date: Thu, 18 Dec 2025 21:51:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Justin Lulejian <jlul...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Devlin Cronin (Gerrit)

unread,
Dec 18, 2025, 6:23:11 PM (13 hours ago) Dec 18
to Luis Pardo, Devlin Cronin, Justin Lulejian, Emmanuel Romero Ruiz, Leszek Swirski, Jeremy Roman, Tim, Sohail Rajdev, Chromium LUCI CQ, Chromium Metrics Reviews, Kentaro Hara, Raphael Kubo da Costa, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, blink-rev...@chromium.org, loading-rev...@chromium.org, asvitkine...@chromium.org, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, blink-revi...@chromium.org
Attention needed from Emmanuel Romero Ruiz, Jeremy Roman, Justin Lulejian, Leszek Swirski and Luis Pardo

Devlin Cronin voted and added 1 comment

Votes added by Devlin Cronin

Code-Review+1

1 comment

Patchset-level comments
File-level comment, Patchset 20 (Latest):
Devlin Cronin . resolved

//extensions LGTM; thanks, Luis!

Open in Gerrit

Related details

Attention is currently required from:
  • Emmanuel Romero Ruiz
  • Jeremy Roman
  • Justin Lulejian
  • Leszek Swirski
  • Luis Pardo
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Idc6fc4e4f0a57f197ccba6ef04a77bba58c0ec8e
    Gerrit-Change-Number: 6820371
    Gerrit-PatchSet: 20
    Gerrit-Owner: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Jeremy Roman <jbr...@chromium.org>
    Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
    Gerrit-Reviewer: Leszek Swirski <les...@chromium.org>
    Gerrit-Reviewer: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Reviewer: Sohail Rajdev <sora...@microsoft.com>
    Gerrit-Reviewer: Tim <tjud...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Emmanuel Romero Ruiz <emro...@microsoft.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
    Gerrit-Attention: Justin Lulejian <jlul...@chromium.org>
    Gerrit-Attention: Luis Pardo <lpardo...@microsoft.com>
    Gerrit-Attention: Jeremy Roman <jbr...@chromium.org>
    Gerrit-Attention: Emmanuel Romero Ruiz <emro...@microsoft.com>
    Gerrit-Attention: Leszek Swirski <les...@chromium.org>
    Gerrit-Comment-Date: Thu, 18 Dec 2025 23:22:56 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Leszek Swirski (Gerrit)

    unread,
    4:29 AM (3 hours ago) 4:29 AM
    to Luis Pardo, Devlin Cronin, Justin Lulejian, Emmanuel Romero Ruiz, Jeremy Roman, Tim, Sohail Rajdev, Chromium LUCI CQ, Chromium Metrics Reviews, Kentaro Hara, Raphael Kubo da Costa, chromium...@chromium.org, AyeAye, kinuko...@chromium.org, blink-rev...@chromium.org, loading-rev...@chromium.org, asvitkine...@chromium.org, blink-revie...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, blink-revi...@chromium.org
    Attention needed from Emmanuel Romero Ruiz, Jeremy Roman, Justin Lulejian and Luis Pardo

    Leszek Swirski voted and added 1 comment

    Votes added by Leszek Swirski

    Code-Review+1

    1 comment

    Patchset-level comments
    Leszek Swirski . resolved

    v8 still lgtm

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Emmanuel Romero Ruiz
    • Jeremy Roman
    • Justin Lulejian
    • Luis Pardo
    Gerrit-Comment-Date: Fri, 19 Dec 2025 09:29:08 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages