From 3d8728e3a165a03aa1fdb9dabca2aae5ea43960f Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Wed, 21 Oct 2026 01:52:55 +0200 Subject: [PATCH 1/2] JFJochXFELReader: the positional-read handles are held for the most recent files only The direct chunk read opened one HDF5ImageSource::RawFile per file and never released it, so the MAX_OPEN_FILES bound on the HDF5 handles did not hold for that path: a dataset stored one frame per file would keep a descriptor per file open. They now follow the same least-recently-used bound; a reading thread still holding a released handle keeps it through its shared_ptr. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu --- reader/JFJochXFELReader.cpp | 7 +++++++ reader/JFJochXFELReader.h | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/reader/JFJochXFELReader.cpp b/reader/JFJochXFELReader.cpp index 3051edf1a..d59e524b4 100644 --- a/reader/JFJochXFELReader.cpp +++ b/reader/JFJochXFELReader.cpp @@ -84,6 +84,7 @@ std::shared_ptr JFJochXFELReader::RawFileAt(size if (raw_files_.size() != files_.size()) { raw_files_.assign(files_.size(), nullptr); user_block_.assign(files_.size(), 0); + raw_order_.clear(); } if (!raw_files_[file]) { const hid_t fcpl = H5Fget_create_plist(FileAt(file).GetID()); @@ -97,6 +98,11 @@ std::shared_ptr JFJochXFELReader::RawFileAt(size throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Cannot open " + files_[file]); raw_files_[file] = raw; user_block_[file] = user_block; + raw_order_.push_back(file); + if (raw_order_.size() > MAX_OPEN_FILES) { + raw_files_[raw_order_.front()].reset(); + raw_order_.erase(raw_order_.begin()); + } } return raw_files_[file]; } @@ -718,6 +724,7 @@ void JFJochXFELReader::Close() { open_files_.clear(); raw_files_.clear(); user_block_.clear(); + raw_order_.clear(); files_.clear(); frames_.clear(); dataset_.reset(); diff --git a/reader/JFJochXFELReader.h b/reader/JFJochXFELReader.h index ec79bdfae..2f9059b56 100644 --- a/reader/JFJochXFELReader.h +++ b/reader/JFJochXFELReader.h @@ -84,9 +84,11 @@ class JFJochXFELReader : public JFJochReader { }; Layout layout_; // Positional-read handles on the files, opened as first needed (under hdf5_mutex), with the size of - // each file's user block, which HDF5 chunk addresses count from. + // each file's user block, which HDF5 chunk addresses count from. Like open_files_, only the most + // recently used MAX_OPEN_FILES are held (raw_order_); a reader still using a released one keeps it. mutable std::vector> raw_files_; mutable std::vector user_block_; + mutable std::vector raw_order_; static Layout ReadLayout(HDF5ReadOnlyFile &file, const Frame &frame); // The files, in the order given, every frame in them, and the run's mean of every value the geometry From 50397ed9ffe24e5322e07366cc4c2b5fc8e35fd5 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Wed, 21 Oct 2026 01:52:55 +0200 Subject: [PATCH 2/2] rugnux stills: the saturation log says why a stated limit is kept It named only a Jungfraujoch-written file, also when the limit was given with --saturation. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu --- rugnux/RugnuxStills.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rugnux/RugnuxStills.cpp b/rugnux/RugnuxStills.cpp index 1bc05a7b9..8f37aee11 100644 --- a/rugnux/RugnuxStills.cpp +++ b/rugnux/RugnuxStills.cpp @@ -722,7 +722,7 @@ void Rugnux::DetectSaturation(int start_image, int images_to_process) { logger.Info("Saturation: the values of {} sampled frames pile up from {} - the file's limit is {}{}", sample.size(), *ceiling, stated, adopt ? ", so pixels from there on are treated as overloaded" - : *ceiling < stated ? "; the file's is kept (written by Jungfraujoch)" : ""); + : *ceiling < stated ? "; the stated limit is kept (written by Jungfraujoch, or given with --saturation)" : ""); if (adopt) experiment_.Detector().SaturationLimit(*ceiling); }