rugnux: count overloads and flag ice-ring reflections over the images on all threads

The two passes over every integrated reflection that open the scaling step ran on one
thread: 1.2-1.3 s on a 78 M-reflection sweep, on the critical path before the scaling
engine starts. One image per task now; the counts are integers and each reflection's
ice flag depends on itself alone, so the result is the same at any thread count.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EizBKhTqrAYago9KJG3dA3
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-12 22:38:09 +02:00
1 parent f567771d56
commit e24fb88b53
1 file changed
+27 -12
+27 -12
View File
@@ -406,16 +406,26 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) {
// drops the whole rocking event) - they are the strongest reflections, mostly at low resolution,
// and what a model's low-resolution terms rest on.
{
for (const auto &io : indexer->GetIntegrationOutcome())
for (const auto &r : io.reflections) {
// Integer counts, one image per task: the totals do not depend on the split.
const auto &outcomes = indexer->GetIntegrationOutcome();
std::atomic<int64_t> n_all{0}, n_low{0}, n_over{0}, n_over_low{0};
ParallelFor(static_cast<int>(outcomes.size()), config_.nthreads, [&](int o) {
int64_t all = 0, low = 0, over = 0, over_low = 0;
for (const auto &r : outcomes[o].reflections) {
const bool low_res = r.d >= OVERLOAD_LOW_RES_A;
++result.integrated_reflections;
result.integrated_reflections_low_res += low_res;
++all;
low += low_res;
if (r.overloaded) {
++result.overloaded_reflections;
result.overloaded_reflections_low_res += low_res;
++over;
over_low += low_res;
}
}
n_all += all; n_low += low; n_over += over; n_over_low += over_low;
});
result.integrated_reflections += n_all;
result.integrated_reflections_low_res += n_low;
result.overloaded_reflections += n_over;
result.overloaded_reflections_low_res += n_over_low;
if (result.integrated_reflections > 0)
logger.Info("Overloads: {} of {} integrated reflections ({:.3f}%) held a saturated pixel, {:.3f}% of "
"the {} coarser than {:.0f} A", result.overloaded_reflections,
@@ -460,15 +470,20 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) {
*ice_score, ice_min_score, ice_spot_ratio.value_or(NAN), ice_min_spot_ratio);
} else if (experiment_.IsDetectIceRings()) {
const float ice_width = config_.spot_finding.ice_ring_width_Q_recipA;
size_t total = 0, flagged = 0;
for (auto &outcome : indexer->GetIntegrationOutcome()) {
for (auto &r : outcome.reflections) {
++total;
auto &outcomes = indexer->GetIntegrationOutcome();
std::atomic<size_t> n_total{0}, n_flagged{0};
ParallelFor(static_cast<int>(outcomes.size()), config_.nthreads, [&](int o) {
size_t all = 0, on_ice = 0;
for (auto &r : outcomes[o].reflections) {
++all;
r.on_ice_ring = IsOnIceRing(r.d, ice_width);
if (r.on_ice_ring)
++flagged;
++on_ice;
}
}
n_total += all;
n_flagged += on_ice;
});
const size_t total = n_total, flagged = n_flagged;
result.ice_rings_detected = true;
result.ice_flagged_fraction = total > 0 ? static_cast<double>(flagged) / total : 0.0;
logger.Info("Ice-ring handling: ice score {:.2f} (gate {:.2f}), spot ratio {:.2f} (gate "