Skip to content

perf: speculative navigation warmup, RegExp species fuse, speed-mode dial - #445

Closed
shahriar0247 wants to merge 1 commit into
mozilla-firefox:mainfrom
shahriar0247:shahriar0247/perf-speculative-navigation
Closed

shahriar0247 wants to merge 1 commit into
mozilla-firefox:mainfrom
shahriar0247:shahriar0247/perf-speculative-navigation

Conversation

@shahriar0247

@shahriar0247 shahriar0247 commented Nov 12, 2026 •

Copy link
Copy Markdown

Summary

A bundle of independently-verified performance changes from a full local performance investigation of Firefox on Windows (three-stage PGO + cross-module ThinLTO build, Speedometer 3 / JetStream 3 baselines, samply-symbolicated profiles). Each change is small, gated where aggressive, and uses existing in-tree machinery rather than new subsystems.

Changes

# Area Change Why
1 SpiderMonkey New OptimizeRegExpSpeciesFuse + CanOptimizeRegExpSpecies intrinsic, CacheIR stub (tryAttachCanOptimizeRegExpSpecies), and Warp CompilationDependency::Type::RegExpSpecies String.prototype.split/matchAll run SpeciesConstructor on every call even when RegExp.prototype.constructor/@@species are untouched. The fuse lets self-hosted RegExpSplit/RegExpMatchAll and the IC skip the lookup, popping to the generic path on mutation. Mirrors CanOptimizeArraySpecies (motivated by bug 1956245).
2 Urlbar speculativeConnect(result, null, "select") on keyboard selection; nullable context falls back to PrivateBrowsingUtils.isWindowPrivate(this.browserWindow); "select" shares the mousedown http/https handling Firefox already warms connections on autofill-result-added and mousedown — but not when the user arrows through results, which is exactly the pre-navigation window. Private windows unchanged.
3 DOM / speculation New dom.speculation_rules.hover_prefetch_all pref: when the document has no rule sets, hover on a same-origin http(s) link synthesizes a moderate-eagerness PrefetchCandidate fed through the existing SpeculationRules/PrefetchRecordParent path Pages without speculation-rules markup get the same hover-to-prefetch benefit; activation reuses FindMatchingPrefetchRecord, so a click on a completed prefetch serves from the record's cache entry. Parent-side same-site/trustworthy checks still apply.
4 Browser prefs browser.speed.mode dial (0=Performance, 1=Balanced default, 2=Fortress) applied by new SpeedMode.sys.mjs at startup; applied prefs tracked in browser.speed.applied so mode switches cleanly restore A single explicit knob for speculative-networking aggressiveness instead of scattered hidden prefs. Performance mode raises speculative-parallel-limit, per-server persistent connections, DNS cache lifetime and enables speculation rules; Balanced is stock.
5 Browser prefs network.predictor.enable-hover-on-ssl: true, dom.prefetch_dns_for_anchor_https_document: true HTTPS hover preconnect and HTTPS anchor DNS prefetch were off by default; the plumbing already exists and the privacy delta is a DNS/TLS connect only.

Files

Group Files
Species fuse js/src/vm/{CommonPropertyNames.h, RealmFuses.{h,cpp}, Watchtower.cpp, RegExpObject.cpp, SelfHosting.cpp}, js/src/builtin/RegExp.{h,cpp,js}, js/src/jit/{CacheIR.cpp, CacheIRGenerator.h, CompilationDependencyTracker.h, InlinableNatives.{h,cpp}, WarpOracle.cpp, WarpCacheIRTranspiler.cpp}
Species test js/src/jit-test/tests/basic/testRegExpSpecies.js (new)
Urlbar browser/components/urlbar/UrlbarParentController.sys.mjs
Hover prefetch dom/base/SpeculationRules.{h,cpp}, dom/events/EventStateManager.cpp, modules/libpref/init/StaticPrefList.yaml
Speed mode browser/components/speedmode/{SpeedMode.sys.mjs, moz.build} (new), browser/components/{BrowserGlue.sys.mjs, moz.build}, browser/app/profile/firefox.js

Measured results

Measurement Before After Notes
RegExp.prototype[Symbol.split] microbench (fuse-active vs fuse-popped) — ~6.6–12.5% faster op Measured by popping the fuse at runtime on the same binary
RegExp.prototype[Symbol.matchAll] microbench — ~0.9–7.4% faster op Same A/B method
jit-tests (RegExp subset) + testRegExpSpecies.js — PASS Incl. fuse-pop correctness for split/matchAll/replace/search
non262 RegExp suite — PASS Full non262/RegExp run
Speedometer 3 (whole build, PGO+ThinLTO vs non-PGO baseline) 10.5 12.08 (+15%) Build-level gain, not attributable to these diffs alone

The species-fuse Speedometer impact is expected <0.5% — it's a correctness-preserving micro-optimization; the perceived-speed gains are in the navigation-speculation changes.

Testing

  • New jit-test testRegExpSpecies.js covers fuse-pop on constructor, @@species, and prototype mutation.
  • RegExp jit-test subset and test non262/RegExp suite: PASS.
  • SpeedMode.init() verified end-to-end on a live profile: mode 0 writes the bundle and records applied prefs; mode 1 writes {}.
  • Hover-prefetch parent-side path (PrefetchRecordParent::Init, FindMatchingPrefetchRecord, activation in DocumentLoadListener) is the existing upstream machinery — this patch only synthesizes the candidate child-side.

Risk / notes

  • hover_prefetch_all defaults false; only activates when the pref is set (the speed-mode Performance bundle sets it).
  • Synthetic candidates are same-origin-only child-side and still pass parent-side same-site / trustworthy-origin / record-limit checks.
  • No change to private-browsing behavior anywhere.

Authoring environment

Produced by Cognition Devin (CLI agent, SWE-2 Max) at the request of the repo owner: build a faster Firefox and upstream the transferable pieces. Benchmarks, profiling data and the per-change investigation live in the fork's docs/ directory.


Lando: link

⚠️ This pull request has 2 warnings.
🚫 This pull request has 2 blockers.

…e dial

Three independent performance changes built and benchmarked on top of
firefox-main @ 133570141:

- SpiderMonkey: skip RegExp @@species lookups in String.split/matchAll
  via a new OptimizeRegExpSpeciesFuse (mirrors CanOptimizeArraySpecies):
  intrinsic + CacheIR stub + Warp compile dependency. Fuse pops restore
  the generic SpeciesConstructor path.
- Urlbar: speculativeConnect on keyboard selection ('select' reason),
  with privacy derived from the window when no query context exists.
- Hover prefetch: dom.speculation_rules.hover_prefetch_all synthesizes a
  moderate-eagerness PrefetchCandidate for same-origin links when the
  document has no rule sets, reusing the existing SpeculationRules /
  PrefetchRecordParent activation path. Plus a browser.speed.mode
  pref-bundle dial (SpeedMode.sys.mjs) and HTTPS hover-preconnect /
  anchor DNS prefetch defaults.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@firefoxci-taskcluster

Copy link
Copy Markdown
No Taskcluster jobs started for this pull request

The allowPullRequests configuration for this repository (in .taskcluster.yml on the default branch) does not allow starting tasks for this pull request.

@github-actions

Copy link
Copy Markdown
Contributor

(Automated Close) Please do not file pull requests here, see https://firefox-source-docs.mozilla.org/contributing/how_to_submit_a_patch.html

@github-actions github-actions Bot closed this Nov 12, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant