Take the error-model split and the ASU grouping off one thread

Three regions of the merge tail, measured with instrumented timers and confirmed
against a cycle profile. On a tail-heavy dataset the scale and merge tail is 70%
of the run's wall clock at six of thirty-two logical cores busy, with the GPU idle
88% of the time, so this is where the CPU headroom is.

fit_error_model ran a serial four-level nth_element cascade over the whole sample
pool, twelve times per dataset. The two halves either side of a partition are
disjoint and their contents are already fixed by the parent's nth_element, so the
recursion can descend both at once; it now does while a range is worth a thread.
The bins are unchanged.

ComputeAsuGroups sorted indices with an indirect comparator, taking a cache miss
per comparison into an array far larger than the last-level cache. It now sorts
packed key-and-run pairs. Tie order does not matter because the packed key encodes
h, k, l and the hand exactly, so every run in a tie reduces to the same reflection.

The per-thread histogram prefix walked thirty-two separate histograms column-wise
on one thread. It becomes a parallel per-group total, one sequential scan over two
flat arrays, and a parallel hand-out of the bases - the same sums in the same
order.

Faster on 21 of 23 matched pairs in an alternating A/B, and on 15 of 15 in the
quieter of the two sessions: 0.6% to 2.3% of whole-run wall clock depending on the
dataset, around 1.8% in aggregate, and 3 to 4% of the time spent outside the image
loop. The reflection files are byte-identical on every dataset tested.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NNnL26LAvruQ9eLUUWvrJ
This commit is contained in:
2026-08-24 18:50:50 +02:00
co-authored by Claude Opus 5
parent 54adcaafcc
commit 2f54a1189d
2 changed files with 51 additions and 20 deletions
+1
View File
@@ -18,6 +18,7 @@ This is an UNSTABLE release. It includes many experimental features, as well as
* HDF5 and image stream: `mirror_y` records whether the assembled image is mirrored in Y relative to the detector's raw readout.
* rugnux: an image integrated in pyFAI through the `.poni` file written by `--mode calibration` now comes out with the correct azimuth. Radial integration is unchanged.
* rugnux: the `.poni` file declares pyFAI's `orientation`, which needs pyFAI 2024.01 or newer.
* rugnux: scaling and merging are faster, with identical output.
* The per-image resolution estimate now predicts the resolution the merged data reach, rather than reporting the highest-resolution spot found; rugnux reports the run's value as `SPOT_RESOLUTION_ESTIMATE` in its report.
* rugnux: fixing the space group with `-S` no longer prevents the lattice from being found; the group is applied to scaling and merging rather than to the indexing search.
* rugnux: the detector geometry is also logged in XDS's convention (`ORGX`/`ORGY`, detector axis vectors, rotation axis), so it can be compared with an XDS refinement.