Skip to content

Add profiler marker system#8882

Open
jdahlin wants to merge 13 commits intoLadybirdBrowser:masterfrom
jdahlin:profile-markers
Open

Add profiler marker system#8882
jdahlin wants to merge 13 commits intoLadybirdBrowser:masterfrom
jdahlin:profile-markers

Conversation

@jdahlin
Copy link
Copy Markdown
Contributor

@jdahlin jdahlin commented Apr 12, 2026

Add a marker collection system for profiler timeline events, inspired by Firefox's marker infrastructure. Markers are timestamped events emitted from engine code that let a profiler UI explain what happened: layout, style, GC, script parsing, DOM events, timers, network, IPC, and media decode.

The public API is a small set of macros in LibCore/Markers.h that gate all argument evaluation behind a relaxed atomic bool check. When no collector is active, cost per call site is one atomic load and a predicted-not-taken branch, no clock reads, no allocations, no string formatting. Design rationale is documented in Documentation/Profiler/Markers.md.

This PR includes 46 markers, they serve as test cases for the reset of the profiling subsystems (profiler, devtools integration, firefox profiling export) and are expected to change over time.

An example of what we are working towards can be seen on this link: https://share.firefox.dev/3Qim8IG

I expect 5-6 PRs before we can get there (marker, profiler, webcontent hookup, devtools, exporter), wip branch of all of the pieces integrated, can be found here.

@jdahlin jdahlin requested a review from AtkinsSJ as a code owner April 12, 2026 18:06
@jdahlin jdahlin force-pushed the profile-markers branch 5 times, most recently from 7c544c1 to 1a82da2 Compare April 13, 2026 15:29
@github-actions
Copy link
Copy Markdown

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

@github-actions github-actions bot added the conflicts Pull request has merge conflicts that need resolution label Apr 13, 2026
@github-actions github-actions bot removed the conflicts Pull request has merge conflicts that need resolution label Apr 13, 2026
@jdahlin jdahlin force-pushed the profile-markers branch 4 times, most recently from 0c0ad03 to f1fb980 Compare April 14, 2026 13:04
jdahlin added 13 commits April 14, 2026 15:44
Add a marker system for profiler timeline events. Design and rationale
are documented in Documentation/Profiler/Markers.md.
Add collectMarkers() and clearMarkers() to the Internals interface for
testing marker emission. collectMarkers() takes a thread-safe snapshot
of the marker collector and returns an array of plain objects with name,
type, phase, category, timing, and field properties. An optional type
filter narrows results to a specific marker schema.
Add Marker test mode to test-web, --collect-markers plumbing, and
a GC marker in Heap.cpp. Include all 12 test files; four pass now
(basic, clear, filter, gc), eight have FAIL expectations that flip
as subsequent commits add markers.
Add markers to Document and ViewportPaintable covering the core
rendering pipeline:
- Style: MARKER_SCOPE for update_style with sub-labels for :has()
  invalidation, style invalidation, media rules, and recompute
- Layout: MARKER_SCOPE for update_layout with sub-labels for tree
  build and formatting context
- Paint: MARKER_SCOPE for record_display_list and paint_all_phases
- Navigation: instant markers for Document::create and readiness
  state transitions (DOMLoading, DOMInteractive, DOMComplete)
- Observers: interval markers for IntersectionObserver,
  ResizeObserver, and animation/transition events
Emit a DOMEvent marker scope around event dispatch with event type,
target node name, latency, and standard event flags (bubbles,
cancelable, composed, isTrusted).
Add MARKER_SCOPE for the HTML parse phase and instant markers for
DOMContentLoaded and Load events in the parser end state machine.
Emit a ParseCSS MARKER_SCOPE when parsing a CSS stylesheet, including
the stylesheet URL in the marker fields.
Add markers to the HTML event loop and timer infrastructure:
- Task execution intervals with source-specific names and categories
- setTimeout/setInterval callback intervals with delay and ID fields
- requestAnimationFrame callback scope
- Microtask checkpoint intervals (filtered to >= 2 queued microtasks
  to reduce noise; Firefox does not emit these at all)
Emit UserTiming markers for performance.mark() (instant) and
performance.measure() (interval). Measure timestamps are converted
from DOMHighResTimeStamp to MonotonicTime for accurate placement on
the profiler timeline.
Emit ConsoleTime IntervalStart/IntervalEnd markers for console.time()
and console.timeEnd(), using the timer label as the marker name.
Add markers across web platform APIs:
- Network: fetch start, XHR send, WebSocket new/send, font face load
- Scripting: classic script evaluation scope, off-thread parse/codegen
  intervals on both worker and main threads
- Input: mouse down, key down instant markers
- Storage: localStorage setItem
- History: pushState/replaceState
- Media: HTMLMediaElement.play
- Observers: MutationObserver callback intervals
- Image: decode interval with URL and byte count
Emit a MARKER_SCOPE around each IPC message handler invocation with
the message name as a searchable field.
Add interval markers for FFmpeg demuxing and audio/video decoding with
track type, byte count, and PTS fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant