Skip to content

Add functionality to profiler-edit to merge two profiles, one with samples and one with markers - #5448

Open
mstange wants to merge 1 commit into
firefox-devtools:mainfrom
mstange:push-vzyqvzrmrvqx
Open

mstange wants to merge 1 commit into
firefox-devtools:mainfrom
mstange:push-vzyqvzrmrvqx

Conversation

@mstange

@mstange mstange commented May 6, 2025 •

Copy link
Copy Markdown
Contributor

Main | Deploy preview

I've been using this script to make profiles of Firefox startup on Android, with sample data from simpleperf and marker data from the Gecko profiler.

I was using the following org.mozilla.fenix-geckoview-config.yaml:

env:
  PERF_SPEW_DIR: /storage/emulated/0/Android/data/org.mozilla.fenix/files
  IONPERF: func
  JIT_OPTION_emitInterpreterEntryTrampoline: true
  JIT_OPTION_enableICFramePointers: true
  JIT_OPTION_onlyInlineSelfHosted: true

  MOZ_PROFILER_STARTUP: 1
  MOZ_PROFILER_STARTUP_NO_BASE: 1 # bug 1955125
  MOZ_PROFILER_STARTUP_INTERVAL: 500
  MOZ_PROFILER_STARTUP_FEATURES: nostacksampling,nomarkerstacks,screenshots,ipcmessages,java,cpu,markersallthreads
  MOZ_PROFILER_STARTUP_FILTERS: GeckoMain,Compositor,Renderer,IPDL Background,*

Example profiles to merge: https://share.firefox.dev/4ssKZZq and https://share.firefox.dev/48gWwSb

You can run it with yarn build-node-tools && node ./node-tools-dist/profiler-edit.js -i 'https://storage.googleapis.com/profile-store/ycbv8644eb0e11n62hgh04yya7xgamhq2qgd94r' -o ~/Downloads/merged.json.gz --merge-markers-from 'https://storage.googleapis.com/profile-store/ag9r7sm5h7zgxphw8werwqs22gdf7kt50q0dqf0' --only-keep-processes-with-name-prefix org.mozilla.fenix

Loading profile from URL https://storage.googleapis.com/profile-store/ycbv8644eb0e11n62hgh04yya7xgamhq2qgd94r
Kept 418 of 2540 threads in processes whose name starts with "org.mozilla.fenix".
Loading profile from URL https://storage.googleapis.com/profile-store/ag9r7sm5h7zgxphw8werwqs22gdf7kt50q0dqf0
Merged the markers of 178 threads, aligning the profiles with startTimeAsClockMonotonicNanosecondsSinceBoot.
Saving profile to /Users/mstange/Downloads/merged.json.gz
Finished.

This gives https://share.firefox.dev/4z2OoQx .

@codecov

codecov Bot commented Jul 24, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.12500% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.78%. Comparing base (7269a79) to head (9db4c81).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/node-tools/profiler-edit.ts 41.17% 20 Missing ⚠️
src/profile-logic/merge-markers.ts 91.48% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5448      +/-   ##
==========================================
- Coverage   84.78%   84.78%   -0.01%     
==========================================
  Files         358      359       +1     
  Lines       38946    39063     +117     
  Branches    10917    11066     +149     
==========================================
+ Hits        33022    33120      +98     
- Misses       5488     5507      +19     
  Partials      436      436              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fqueze

fqueze commented Jul 25, 2025

Copy link
Copy Markdown
Contributor

Is this specific to android? I could be tempted to merge a samply profile with a resource usage profile.

@mstange

mstange commented Jul 25, 2025

Copy link
Copy Markdown
Contributor Author

The part that's specific to Android / Linux is the use of startTimeAsClockMonotonicNanosecondsSinceBoot to align the timestamps in the two profiles.

Also, the markers from the "samples" profile are discarded. You are probably interested in keeping markers from both profiles, which will be more complicated because you'll also have to merge the schemas.

@fqueze

fqueze commented Jul 25, 2025

Copy link
Copy Markdown
Contributor

You are probably interested in keeping markers from both profiles, which will be more complicated because you'll also have to merge the schemas.

If we added more useful markers to samply profiles, yes. Currently all the markers I see in these profiles are mmap markers that don't tell me much.

@mstange
mstange force-pushed the push-vzyqvzrmrvqx branch from c967c63 to b0d1a1b Compare August 15, 2025 13:05
@mstange
mstange force-pushed the push-vzyqvzrmrvqx branch from b0d1a1b to c432b01 Compare August 25, 2025 18:28
@mstange
mstange force-pushed the push-vzyqvzrmrvqx branch 2 times, most recently from a1a2f14 to a0ca052 Compare October 23, 2025 18:42
@mstange
mstange force-pushed the push-vzyqvzrmrvqx branch from a0ca052 to 577a1a7 Compare January 6, 2026 12:10
@mstange
mstange force-pushed the push-vzyqvzrmrvqx branch 2 times, most recently from 651ba1a to 06de2e3 Compare March 9, 2026 20:37
…o profiler-edit.

This replaces the merge-android-profiles script. It combines the samples of a
system-wide simpleperf profile with the markers of a Gecko profile from the same
run, for Android startup profiling. The markers are copied into the threads with
the same pid and tid, and the profiles are aligned by their monotonic clock
start times. The markers of Gecko's "X (JVM)" threads go into the thread of "X".
@mstange
mstange marked this pull request as ready for review October 26, 2026 20:18
@mstange mstange changed the title [deploy] Add a script to merge two profiles, one with samples and one with markers Add functionality to profiler-edit to merge two profiles, one with samples and one with markers Oct 26, 2026
@mstange

mstange commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

I've ported the script functionality to the profiler-edit script. I'd like to use this in CI to create better profiles for the newssite-applink-startup test.

https://bugzilla.mozilla.org/show_bug.cgi?id=2085919

@mstange
mstange requested a review from canova October 26, 2026 20:20
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.

2 participants