SearchSERPTelemetry runs parent main-thread work for every HTTP response on every page, even when no search results page is tracked
Categories
(Firefox :: Search, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox163 | --- | fixed |
People
(Reporter: jesup, Assigned: jesup)
References
Details
(Keywords: perf)
Attachments
(1 external file)
ContentHandler in SearchSERPTelemetry.sys.mjs observes http-on-examine-response and http-on-examine-cached-response for the whole session. For every response, on every page, observeActivity() calls ChannelWrapper.get(channel), resolves the top browser via channel.loadInfo.browsingContext?.top.embedderElement, and then dispatches a separate main-thread runnable. Only inside that runnable does it look up whether the channel belongs to a tracked SERP (_findItemForBrowser), which for nearly all browsing finds nothing.
This runs in the parent process main thread, which is the bottleneck for request handling on busy pages (HTTP channel parents, classifier callbacks, OnStartRequest processing all run there).
Measured with the Gecko profiler on live (not recorded) page loads, optimized Linux build:
- imgur.com cold load (~1400 channels):
SearchSERPTelemetry.observeActivitywas ~7% of the parent-sidensHttpChannel::OnStartRequestsamples and 63 of 3201 parent main-thread samples (~2%), plus one extra main-thread runnable per response (480observeActivityrunnables in the first 3s, ~19.5ms). - On that page the parent main thread was 80-86% busy, and queued work there (e.g. URL classifier callbacks) was delayed by a median of 12ms and up to ~100ms, so per-response overhead directly lengthens request start times.
Suggested fix: return early from observeActivity() before ChannelWrapper.get() and the dispatch when no SERP is being tracked (TelemetryHandler._browserInfoByURL is empty), e.g. by passing a "has tracked SERPs" callback to ContentHandler alongside findItemForBrowser. Alternatively, only add the observers while at least one SERP is tracked.
Care is needed for the case where a SERP tab opens a new tab/window (the handler checks the opener tab and the previous window), but those still require a tracked SERP to exist, so an empty-map early return should not change behavior.
| Assignee | ||
Comment 1•5 days ago
|
||
ContentHandler observes every HTTP response for the whole session, and for each one wrapped
the channel and dispatched a main-thread runnable before finding out whether any SERP was
tracked. Return early when none is.
Updated•5 days ago
|
Comment 3•3 days ago
|
||
| bugherder | ||
Description
•