-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use an indexed sort for expensive comparisons in MuonShowerInformationFiller #40675
Use an indexed sort for expensive comparisons in MuonShowerInformationFiller #40675
Conversation
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-40675/34023
|
A new Pull Request was created by @dan131riley (Dan Riley) for master. It involves the following packages:
@cmsbuild, @mandrenguyen, @clacaputo can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
enable profiling |
please test |
-1 Failed Tests: RelVals-INPUT RelVals-INPUTThe relvals timed out after 4 hours. Comparison SummarySummary:
|
please test |
type muon |
+1 Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-be7814/30451/summary.html Comparison SummarySummary:
|
+reconstruction |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @perrotta, @dpiparo, @rappoccio (and backports should be raised in the release meeting by the corresponding L2) |
+1 |
PR description:
MuonShowerInformationFiller has several sorts over the muon hits that use comparison functions involving complex calculations. This has two problems, (1) the comparison function is executed O(n*log(n)), so the same complex calculations are performed multiple times, and (2) when vector instructions are enabled, the values calculated may not be completely stable, which may make the sort ill-defined. See issue #33663 for details.
This PR replaces the use of
stable_sort
with a custom sort function that pre-calculates and caches the values to be sorted, performs an index sort on the cached values, and constructs the output container. This reduces the number of complex calculations to O(n), at some cost in complexity and memory usage. In practice this is measured to reduce the CPU time for a typical sort by 2/3. It also fixes the segmentation faults.In addition, this PR also corrects two places where I believe the in-place sorting of
stable_sort
was incorrectly sorting the input containers to two functions.It would arguably be better for the MuonShowerInformationFiller to define its own hit type that caches the global coordinates and derived quantities; however, that would be a much more intrusive change, where this PR is fairly minimal.
PR validation:
Workflow 136.844 runs successfully in a Skylake IB, spot checks of the sort results found the results to be identical. Mostly technical fix, but may cause small physics changes due to the correction of the inadvertent sorts.