Azimuthal geometry cache keeps six geometries instead of one

A run alternates between a handful of centres (file, measured, post-refined,
probe, the beam-centre ladder's trial centres), and every miss rebuilt the
16.7 Mpx geometry table. The cache now keeps the six most recently used
(~170 MB each at 16 Mpx). Tables are bit-identical whether cached or built.

p.mtz md5 unchanged on myob/cytc/thau/kdp (GPU build). Timing: no measurable
change on myob/cytc/thau at 3 repeats; it removes table rebuilds where
geometries alternate.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVmAWnzCmRKAXVUCdc4iNi
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-06 23:10:07 +02:00
1 parent a395f358ef
commit fc61700c95
2 files changed
+25 -15

No files matched your search

+11 -8
View File
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "JFJochMath.h"
#include <algorithm>
#include <bit>
#include <cmath>
#include <thread>
@@ -128,16 +129,18 @@ void AzimuthalIntegrationMapping::SetupConvGeomCached(const DiffractionGeometry
static_cast<uint32_t>(width), static_cast<uint32_t>(height)});
std::lock_guard lock(cache.m);
if (cache.key != key) {
auto &entries = cache.entries;
auto it = std::find_if(entries.begin(), entries.end(), [&](const auto &e) { return e.key == key; });
if (it == entries.end()) {
SetupConvGeom(geom, nullptr);
cache.key = key;
cache.pixel_to_bin = pixel_to_bin;
cache.pixel_resolution = pixel_resolution;
cache.corrections = corrections;
if (entries.size() == AzimuthalIntegrationGeometryCache::MAX_ENTRIES)
entries.erase(entries.begin());
entries.push_back({key, pixel_to_bin, pixel_resolution, corrections});
} else {
pixel_to_bin = cache.pixel_to_bin;
pixel_resolution = cache.pixel_resolution;
corrections = cache.corrections;
std::rotate(it, it + 1, entries.end());
pixel_to_bin = entries.back().pixel_to_bin;
pixel_resolution = entries.back().pixel_resolution;
corrections = entries.back().corrections;
}
// What SetupPixel leaves at a masked pixel.