Skip to content

feat: add performance profiler as stepping action#35

Open
wdconinc wants to merge 3 commits intomainfrom
performance-profiling
Open

feat: add performance profiler as stepping action#35
wdconinc wants to merge 3 commits intomainfrom
performance-profiling

Conversation

@wdconinc
Copy link
Contributor

Briefly, what does this PR introduce?

This PR adds a performance profiler plugin as a stepping action. For each step it keeps track of the duration that it is being simulated (this only works for default stacking actions), and at the end of run lists all tracks that took longer than 10 ms to simulate, along with their PDG and start/end position.

Example output:

PerformanceProfileSteppingAction INFO  track 1 (2212): 12 ms (0.029269 -0.004519 1.757631 mm -> -102.125110 -73.161965 6923.859749 mm, 938.270000 (M?)eV)
PerformanceProfileSteppingAction INFO  track 9 (-321): 10 ms (0.029269 -0.004519 1.757631 mm -> -277.006274 -1473.096044 3519.430984 mm, 493.680000 (M?)eV)
PerformanceProfileSteppingAction INFO  track 10 (211): 13 ms (0.029269 -0.004519 1.757631 mm -> -396.945489 -787.958616 1582.872183 mm, 139.570000 (M?)eV)
PerformanceProfileSteppingAction INFO  track 6181 (-22): 15 ms (106.995649 776.761659 -401.489860 mm -> 107.365071 778.207138 -1545.354784 mm, 3.783558 (M?)eV)
PerformanceProfileSteppingAction INFO  track 6267 (-22): 10 ms (107.289909 778.630931 -402.464097 mm -> 107.502939 763.628645 226.130404 mm, 2.407724 (M?)eV)
PerformanceProfileSteppingAction INFO  track 25248 (-22): 31 ms (123.662639 764.565346 -439.257661 mm -> 138.962176 775.684364 -326.500907 mm, 3.491873 (M?)eV)
PerformanceProfileSteppingAction INFO  track 27569 (11): 14 ms (166.477612 -1121.195617 2351.318946 mm -> 140.948726 -1200.141784 2569.490636 mm, 0.510999 (M?)eV)
PerformanceProfileSteppingAction INFO  track 27813 (2112): 15 ms (-456.534854 -711.108410 1607.115610 mm -> -70.120630 1923.261126 1245.808178 mm, 939.565361 (M?)eV)
PerformanceProfileSteppingAction INFO  track 27858 (2112): 22 ms (-1288.722733 -345.548613 2264.401897 mm -> -2053.894041 83.307443 2732.565622 mm, 939.565360 (M?)eV)
PerformanceProfileSteppingAction INFO  track 28452 (2112): 15 ms (117.221294 -1963.661356 2019.896461 mm -> 34.670203 -2049.162650 1986.983329 mm, 939.565360 (M?)eV)
PerformanceProfileSteppingAction INFO  track 28465 (2112): 10 ms (224.358432 -1940.989177 2055.132725 mm -> 1135.633326 -1753.395162 2048.960419 mm, 939.565361 (M?)eV)
PerformanceProfileSteppingAction INFO  track 29245 (2112): 11 ms (-692.575491 -699.084520 1687.174783 mm -> 1600.277864 -385.261933 1253.103476 mm, 939.565476 (M?)eV)
PerformanceProfileSteppingAction INFO  track 29563 (-22): 43 ms (-108.498510 -763.717067 1416.221122 mm -> -134.371499 -772.001318 1302.836329 mm, 3.648589 (M?)eV)
PerformanceProfileSteppingAction INFO  track 29955 (2112): 26 ms (-734.443022 1845.196633 3137.381185 mm -> -1352.866966 1398.789799 3453.263058 mm, 939.565360 (M?)eV)
PerformanceProfileSteppingAction INFO  track 31505 (14): 10 ms (-873.428301 -1434.637187 3454.402212 mm -> 2466.324741 -3500.000000 599.340318 mm, 29.791916 (M?)eV)

What kind of change does this PR introduce?

  • Bug fix (issue #__)
  • New feature (issue #__)
  • Documentation update
  • Other: __

Please check if this PR fulfills the following:

  • Tests for the changes have been added
  • Documentation has been added / updated
  • Changes have been communicated to collaborators

Does this PR introduce breaking changes? What changes might users need to make to their code?

No.

Does this PR change default behavior?

No.

@wdconinc
Copy link
Contributor Author

This now produces plots like this:
image

@wdconinc wdconinc force-pushed the performance-profiling branch from e900a82 to 700371a Compare June 25, 2025 14:39

RUNNER.action.step = {
"name": "PerformanceProfileSteppingAction"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to run unconditionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rahmans1 pushed a commit to eic/detector_benchmarks that referenced this pull request Oct 22, 2025
…alysis

This benchmark measures computational performance of detector simulation
by profiling time spent in different detector regions during Geant4 stepping.

- Add benchmarks/timing_profiling/ with run_profile.sh and analysis scripts
- Integrate with CI/CD pipeline via .gitlab-ci.yml
- Uses PerformanceProfileSteppingAction plugin to collect timing data
- Generates annotated plots showing computational hotspots in detector geometry
- Outputs CSV summaries of timing by detector region

Requires: eic/npsim#35

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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