Skip to content

MzMLFile::load: keep remote input on the serial path (fix for #10728) - #10752

Merged
timosachsenberg merged 1 commit into
claude/eager-babbage-nt68klfrom
claude/pr-10728-accidental-merge-1tejef
Oct 27, 2026
Merged

timosachsenberg merged 1 commit into
claude/eager-babbage-nt68klfrom
claude/pr-10728-accidental-merge-1tejef

Conversation

@timosachsenberg

Copy link
Copy Markdown
Contributor

Description

Stacked on #10710 (base: its branch claude/eager-babbage-nt68kl).

#10728 was merged without the fix proposed in its review. This PR applies that diff unchanged.

Problems in MzMLFile::load on remote input:

  1. The serial fallback resets the map and calls setLoadedFileType(filename) and setLoadedFilePath(filename) for every input. That undoes the remote branch above it, which sets setLoadedFileType(FileTypes::MZML) and setLoadedNetFilePath. For a URL, setLoadedFileType(filename) sniffs the content and throws FileNotFound.
  2. With 2 or more threads, loadParallelIndexed_ also runs on URLs. It reads byte ranges through std::ifstream, which cannot open a URL.

Fix:

  • Remote input always takes the streaming parse.
  • The document identifier (loaded file type and path) is set once, in the serial branch.
  • The parallel path overwrites the whole map on success and leaves it untouched when it returns false, so the early map.reset() is no longer needed.

#10728 had no CI because Build and Test runs only for PRs into develop, so the failure didn't show there. It will show on #10710's CI at c540724.

Checklist


Generated by Claude Code

… identifier

#10728 was merged without the fix from its review: the serial fallback reset
the map and called setLoadedFileType(filename)/setLoadedFilePath(filename)
unconditionally, undoing the remote branch above it. For a URL,
setLoadedFileType(filename) sniffs the content and throws FileNotFound, so
every s3:// load failed (and every http(s)/ftp load once #10727 is in), and
MzMLFile_test's "load from HTTP URL" section got FileNotFound instead of the
expected ParseError. With 2+ threads, loadParallelIndexed_ also ran on URLs,
which it cannot read (std::ifstream on the URI).

Now remote input always takes the streaming parse, and the document
identifier is set once, in the serial branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0149aXmaayHbZ6MkxFhfzX1D
@jpfeuffer

Copy link
Copy Markdown
Contributor

Why would it not work on remotes that support range requests?

Copy link
Copy Markdown
Contributor Author

The approach would work with ranged reads. The implementation from #10728 doesn't: loadParallelIndexed_ reads the header, the tail and every chunk through std::ifstream. On s3:// with 2 or more threads, it finds the index through S3 range reads (IndexedMzMLDecoder::findIndexListOffset). Then std::ifstream cannot open the URI, and the first read throws "Short read in indexed mzML".

This PR only restores what remote loads did before #10728: the serial streaming parse. That fixes the regression, where every s3:// load threw FileNotFound, even with one thread.

Parallel remote loads would be a follow-up rather than part of this fix:

  • S3: the pieces exist. The chunk reads could use S3InputSource::readRange, as the index lookup already does. Two costs to measure first:
    • Each readRange call opens the object again.
    • Every chunk (at least 1 MB, up to 4 per thread) becomes its own request. The chunk size and the 32-thread cap were tuned on a local NUMA node, not against S3 latency.
  • HTTP/HTTPS/FTP: there is no range reader. [FEATURE,IO] Read XML from HTTP, HTTPS and FTP with libcurl #10727 streams these sequentially, and reads the index only from local files and S3. This would need ranged reads in HTTPInputSource, plus a fallback for servers that don't support range requests.

Generated by Claude Code

@timosachsenberg
timosachsenberg merged commit 8752b37 into claude/eager-babbage-nt68kl Oct 27, 2026
3 checks passed
@timosachsenberg
timosachsenberg deleted the claude/pr-10728-accidental-merge-1tejef branch October 27, 2026 15:26
poshul pushed a commit that referenced this pull request Oct 29, 2026
* Replace Xerces with libxml2 on OpenMS 3.7 develop

* Document develop integration validation and remaining CI blocker

* [TEST] Adapt imzML parse-error tests to the current loadSpectraIndex signature

develop added the MSExperiment output to ImzMLFile::loadSpectraIndex; the
two malformed-input sections from the libxml2 branch still used the old
three-argument form and no longer compiled after the merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [PERF] libxml2 adapter: decode Latin-1 in bulk, pass UTF-8 names and attributes through

Reading mzML spent much of its time converting text rather than parsing:

- OpenMS writes ISO-8859-1 declarations, which libxml2 decodes byte by
  byte. The adapter now detects such a declaration (or an enforced
  Latin-1 encoding, using libxml2's own name table), forces UTF-8, passes
  ASCII chunks through unchanged and converts the rest word-wise itself.
- Attributes are kept as UTF-8 slices of the parser buffer in a reusable
  XMLAttributes::NativeStore. UTF-16 values are produced only on access;
  the XMLHandler attribute helpers copy the UTF-8 value directly.
  Element names and character data reuse conversion buffers, so a parse
  no longer allocates per element or attribute.
- New opt-in hooks tryOnStartElementUTF8/tryOnEndElementUTF8 (same contract
  as tryOnCharactersUTF8) let MzMLHandler take UTF-8 tag names without the
  UTF-8 -> UTF-16 -> UTF-8 round trip.
- MzMLHandler drops character data outside <binary> before scanning it,
  scans <binary> payloads branch-free, and compares tags and accessions
  against string_view literals instead of strlen-ing C strings.

On a 196 MB DDA-like mzML (Linux, 4 cores) full loads take 0.91 s instead
of 1.56 s and metadata-only loads 0.84 s instead of 1.39 s; zlib-compressed
arrays 1.13 s instead of 1.66 s. Decoded data are identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [PERF] XMLFile: decompress gzip/bzip2/zip input on a read-ahead thread

Inflating outer-gzip mzML costs about as much as parsing it, and both ran
serially. A helper thread now fills a small queue of 256 KiB blocks while
the parser consumes earlier ones; stream exceptions are rethrown to the
caller and an early stop (EndParsingSoftly) shuts the helper down.

While it runs, the parsing thread starts OpenMP regions with one thread
fewer: idle OpenMP workers spin between the handlers' decoding regions and,
on all cores, starve the helper (no gain at all otherwise).

196 MB mzML.gz: full load 0.94 s instead of 1.76 s, metadata-only 0.96 s
instead of 1.64 s, i.e. as fast as the uncompressed file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] vcpkg: require libxml2 2.13.5, a version the registry knows

"version>=" must name an entry of the vcpkg version database. There is no
2.13.0 port, so every vcpkg-based CI job (all build-and-test jobs and the
Linux/Windows wheels) stopped in "vcpkg install". 2.13.5 is the oldest
available release meeting the 2.13 minimum; the baseline still selects
the newer libxml2 it pins.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] XMLFile: accept large attributes like Xerces, clean libxml2 diagnostics

Review follow-ups for the libxml2 SAX reader:

- Set XML_PARSE_HUGE with an explicit entity amplification budget, as the
  mzIdentML and spectrum DOM readers already do. Without it libxml2 rejects
  attribute values over 10 MB and nesting deeper than 256 levels, which
  Xerces read (e.g. large UserParam values in idXML/featureXML).
- Strip libxml2's trailing line break from parse and validation messages;
  OpenMS appends the location itself.
- Reserve a core for the decompression thread only when OpenMP uses all
  cores; a lower thread count chosen by the caller is left alone.
- Decode element names and text with StringManager::convert instead of a
  second, non-validating UTF-8 decoder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [TEST] FileInfo_15: expect libxml2's wording of the mzIdentML schema error

The XSD validator now is libxml2. It reports the same single error for the
invalid PeptideEvidence@post value ']' on line 327, but words it
differently and gives column 0 (Xerces: 183). The whitelist term keyed on
Xerces' column no longer matched, so the line with the machine-specific
input path was compared literally.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [PERF] mzML cvParams: hash-indexed CV lookups, fewer allocations and string compares

MzMLHandler work per cvParam, the most frequent element:

- ControlledVocabulary keeps an unordered index next to its ordered term
  map (whose iteration order is unchanged); getTerm, exists and the
  ancestry walk of isChildOf use it instead of tree lookups. Copies
  rebuild the index, moves keep it. A load ran about 580 lookups per
  spectrum.
- cvParamToValue creates the string DataValue only for values that stay
  strings, not before replacing it with a number.
- cvParam/userParam attributes are read into reused buffers; the
  binaryDataArray branch computes isChildOf once instead of twice.
- handleCVParam_ compares "MS:nnnnnnn" accessions as numbers (fixed width)
  instead of memcmp'ing 347 same-length strings.
- XMLAttributes::index rejects names by their first byte before decoding.

196 MB mzML, best of 9: metadata-only loads 0.80-0.82 s instead of
0.89-0.91 s, full loads 0.95-0.96 s instead of 1.06 s; decoded data are
identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] Windows: open XML input via to_path, build UTF-8 literal tests with /utf-8

Windows CI (first run of the libxml2 reader there):

- XMLFile::parse_ opened files with std::filesystem::u8path, which throws on
  the code-page file names OpenMS passes around on Windows (File::exists
  accepts them through to_path). TOPP_FileConverter_nonascii aborted with
  0xc0000409. Use to_path, which takes UTF-8 and falls back to the code page.
- StringManager_test, XMLHandler_test and XMLParserBackend_test spell UTF-8
  text as narrow literals; MSVC encoded them in the build machine's code page
  (cp1252: "Grüße β ??"), so comparisons failed and a missing lookup
  segfaulted. Compile these three with /utf-8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] XMLFile: keep the 64 KiB parse chunk on the heap

The libxml2 reader read input into a 64 KiB stack array; Xerces kept its
buffers on the heap. Readers run deep in call stacks and on OpenMP worker
threads, with 1 MB stacks on Windows. FragmentIndex_test, whose single
test function holds ~90 FragmentIndex objects (7 KB each) and loads the
modification and enzyme databases from that frame, crashes on Windows CI
on this branch (develop: passes); a stack overflow is consistent with it.
One allocation per parsed file, no measurable cost.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* fix: warn about same-file parent name mismatches while loading OBO files

checkName_() runs while loadFromOBO() is still filling terms_, so it must not
look ids up via index_, which is only rebuilt once loading finishes.

Also find libxml2's own package config first in OpenMSConfig.cmake for static
installations, as the build does, and drop the stale validation section from
the migration notes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [DOC] Install: libxml2 >= 2.13 is not packaged on several current distributions

Builds without vcpkg take libxml2 from the system. Ubuntu 24.04 and
Debian 13 ship 2.9.14, and RHEL, AlmaLinux and Rocky Linux 10 ship 2.12.5,
so the configure fails there. Name the minimum version and required
features, and point to vcpkg or a source build. The Dockerfile is no
longer a pure Ubuntu-packages build; say that it builds libxml2 itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L7rXfNq24PfjvsEM7cwX4h

* [TEST] DecompressingInputStream_test: include <algorithm> and Exception.h

GCC and Clang on Linux did not find std::min(initializer_list),
std::copy_n and the Exception namespace through the other includes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L7rXfNq24PfjvsEM7cwX4h

* [FIX] Remote mzML: no bogus I/O rate; reuse the whole decompression buffer

- MzMLHandler reported the load rate from File::fileSize(), which is -1 for
  remote URIs (develop's #9262), so S3 loads logged an absurd rate. It now
  reports none when the size is unknown.
- DecompressingInputStream refilled only the end of its input buffer after
  the buffer was consumed; it now starts at the front again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L7rXfNq24PfjvsEM7cwX4h

* [DOC] Install: without a preset, OPENMS_USE_VCPKG=ON uses the vcpkg submodule's toolchain

CMakeLists.txt picks vcpkg/scripts/buildsystems/vcpkg.cmake when the
submodule is initialized and no toolchain file is given. An explicit
toolchain is only needed without the submodule (source tarballs).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* [FIX] mzML: name CV-typed binary data arrays in one shared helper, for indexed reads too

MzMLHandler named arrays typed by a child term of MS:1000513 (binary data
array), e.g. ion mobility arrays (MS:1003008), after the term; the
indexed decoder (MzMLSpectrumDecoder) did not, so on-disc and indexed
reads lost these names and with them the ion mobility data.

MzMLHandlerHelper::handleBinaryDataArrayCVParam() now names these
arrays (and marks absorbance intensities), and MzMLHandler relies on it.
Both paths therefore agree, including the precedence of MzMLHandler:
the last array term wins. Accessions missing from the bundled CV stay
unidentified instead of throwing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* MzMLSpectrumDecoder: store m/z and intensity array meta data in the spectrum, as MzMLHandler does

Indexed reads dropped the meta data of the default arrays, e.g. the
absorbance flag of an intensity array (MS:1000515 with UO:0000269), so
writing such a spectrum back to mzML used the wrong intensity unit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* MzMLFile::load: parallel load of indexed mzML with OpenMP (#10728)

Uncompressed indexed mzML without load filters is split at spectrum offsets
from the index into byte-balanced chunks (at least 1 MB, up to 4 per
thread, at most 32 threads). Each chunk is parsed with the document header
and closing tags by a normal MzMLHandler, so metadata and peaks are parsed
exactly as in the serial load; chromatograms form one extra chunk. Parts are
concatenated in document order.

Single-threaded, compressed, unindexed, small or filtered loads, and any
index/document count mismatch, keep the serial streaming parse.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Timo Sachsenberg <[email protected]>

* MzMLFile::load: keep remote input on the serial path and its document identifier (#10752)

#10728 was merged without the fix from its review: the serial fallback reset
the map and called setLoadedFileType(filename)/setLoadedFilePath(filename)
unconditionally, undoing the remote branch above it. For a URL,
setLoadedFileType(filename) sniffs the content and throws FileNotFound, so
every s3:// load failed (and every http(s)/ftp load once #10727 is in), and
MzMLFile_test's "load from HTTP URL" section got FileNotFound instead of the
expected ParseError. With 2+ threads, loadParallelIndexed_ also ran on URLs,
which it cannot read (std::ifstream on the URI).

Now remote input always takes the streaming parse, and the document
identifier is set once, in the serial branch.


Claude-Session: https://claude.ai/code/session_0149aXmaayHbZ6MkxFhfzX1D

Co-authored-by: Claude <[email protected]>

* [FIX] IndexedMzMLDecoder::findIndexListOffset: no error output for a file without index

MzMLFile probes every uncompressed mzML for an index before a parallel load
(#10728) and in hasIndex(), so ordinary mzML loads printed 'Could not find
element indexListOffset' when OpenMP had two or more threads. -1 is the
documented result for a missing index; IndexedMzMLHandler, the caller that
needs one, now reports it instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [CLEANUP] Remove leftovers of the Xerces migration

- CI: the Xerces-removal guard (tools/ci/check_no_xerces.py, its tests and the
  build step) and -DCMAKE_DISABLE_FIND_PACKAGE_XercesC, which nothing looks for
  any more.
- doc/xml_libxml2_migration.md: notes of the fork's migration (guard commands,
  links to its benchmark reports); the PR description has the current state.
- Xerces API shapes no caller uses: InputStream::getContentType(),
  CompressedInputSource's char16_t* constructor and getSystemId(), and the
  global XMLCh alias of the test framework (tests use char16_t).
- Stale Xerces mentions: the Xerces valgrind suppression, the devcontainer's
  dependency list, and comments that compared with Xerces.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [DOC] cmake_findExternalLibs: say which libxml2 installations lack a usable package config

Only libxml2's CMake build installs libxml2-config-version.cmake and exported
targets. Its autotools and meson builds (distribution packages) install an
unversioned libxml2-config.cmake, which find_package(LibXml2 2.13 CONFIG)
rejects, so the FindLibXml2 module is used for them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

---------

Co-authored-by: Oliver <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Oliver Kohlbacher <[email protected]>
poshul pushed a commit that referenced this pull request Oct 29, 2026
* Replace Xerces with libxml2 on OpenMS 3.7 develop

* Document develop integration validation and remaining CI blocker

* [TEST] Adapt imzML parse-error tests to the current loadSpectraIndex signature

develop added the MSExperiment output to ImzMLFile::loadSpectraIndex; the
two malformed-input sections from the libxml2 branch still used the old
three-argument form and no longer compiled after the merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [PERF] libxml2 adapter: decode Latin-1 in bulk, pass UTF-8 names and attributes through

Reading mzML spent much of its time converting text rather than parsing:

- OpenMS writes ISO-8859-1 declarations, which libxml2 decodes byte by
  byte. The adapter now detects such a declaration (or an enforced
  Latin-1 encoding, using libxml2's own name table), forces UTF-8, passes
  ASCII chunks through unchanged and converts the rest word-wise itself.
- Attributes are kept as UTF-8 slices of the parser buffer in a reusable
  XMLAttributes::NativeStore. UTF-16 values are produced only on access;
  the XMLHandler attribute helpers copy the UTF-8 value directly.
  Element names and character data reuse conversion buffers, so a parse
  no longer allocates per element or attribute.
- New opt-in hooks tryOnStartElementUTF8/tryOnEndElementUTF8 (same contract
  as tryOnCharactersUTF8) let MzMLHandler take UTF-8 tag names without the
  UTF-8 -> UTF-16 -> UTF-8 round trip.
- MzMLHandler drops character data outside <binary> before scanning it,
  scans <binary> payloads branch-free, and compares tags and accessions
  against string_view literals instead of strlen-ing C strings.

On a 196 MB DDA-like mzML (Linux, 4 cores) full loads take 0.91 s instead
of 1.56 s and metadata-only loads 0.84 s instead of 1.39 s; zlib-compressed
arrays 1.13 s instead of 1.66 s. Decoded data are identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [PERF] XMLFile: decompress gzip/bzip2/zip input on a read-ahead thread

Inflating outer-gzip mzML costs about as much as parsing it, and both ran
serially. A helper thread now fills a small queue of 256 KiB blocks while
the parser consumes earlier ones; stream exceptions are rethrown to the
caller and an early stop (EndParsingSoftly) shuts the helper down.

While it runs, the parsing thread starts OpenMP regions with one thread
fewer: idle OpenMP workers spin between the handlers' decoding regions and,
on all cores, starve the helper (no gain at all otherwise).

196 MB mzML.gz: full load 0.94 s instead of 1.76 s, metadata-only 0.96 s
instead of 1.64 s, i.e. as fast as the uncompressed file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] vcpkg: require libxml2 2.13.5, a version the registry knows

"version>=" must name an entry of the vcpkg version database. There is no
2.13.0 port, so every vcpkg-based CI job (all build-and-test jobs and the
Linux/Windows wheels) stopped in "vcpkg install". 2.13.5 is the oldest
available release meeting the 2.13 minimum; the baseline still selects
the newer libxml2 it pins.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] XMLFile: accept large attributes like Xerces, clean libxml2 diagnostics

Review follow-ups for the libxml2 SAX reader:

- Set XML_PARSE_HUGE with an explicit entity amplification budget, as the
  mzIdentML and spectrum DOM readers already do. Without it libxml2 rejects
  attribute values over 10 MB and nesting deeper than 256 levels, which
  Xerces read (e.g. large UserParam values in idXML/featureXML).
- Strip libxml2's trailing line break from parse and validation messages;
  OpenMS appends the location itself.
- Reserve a core for the decompression thread only when OpenMP uses all
  cores; a lower thread count chosen by the caller is left alone.
- Decode element names and text with StringManager::convert instead of a
  second, non-validating UTF-8 decoder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [TEST] FileInfo_15: expect libxml2's wording of the mzIdentML schema error

The XSD validator now is libxml2. It reports the same single error for the
invalid PeptideEvidence@post value ']' on line 327, but words it
differently and gives column 0 (Xerces: 183). The whitelist term keyed on
Xerces' column no longer matched, so the line with the machine-specific
input path was compared literally.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [PERF] mzML cvParams: hash-indexed CV lookups, fewer allocations and string compares

MzMLHandler work per cvParam, the most frequent element:

- ControlledVocabulary keeps an unordered index next to its ordered term
  map (whose iteration order is unchanged); getTerm, exists and the
  ancestry walk of isChildOf use it instead of tree lookups. Copies
  rebuild the index, moves keep it. A load ran about 580 lookups per
  spectrum.
- cvParamToValue creates the string DataValue only for values that stay
  strings, not before replacing it with a number.
- cvParam/userParam attributes are read into reused buffers; the
  binaryDataArray branch computes isChildOf once instead of twice.
- handleCVParam_ compares "MS:nnnnnnn" accessions as numbers (fixed width)
  instead of memcmp'ing 347 same-length strings.
- XMLAttributes::index rejects names by their first byte before decoding.

196 MB mzML, best of 9: metadata-only loads 0.80-0.82 s instead of
0.89-0.91 s, full loads 0.95-0.96 s instead of 1.06 s; decoded data are
identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] Windows: open XML input via to_path, build UTF-8 literal tests with /utf-8

Windows CI (first run of the libxml2 reader there):

- XMLFile::parse_ opened files with std::filesystem::u8path, which throws on
  the code-page file names OpenMS passes around on Windows (File::exists
  accepts them through to_path). TOPP_FileConverter_nonascii aborted with
  0xc0000409. Use to_path, which takes UTF-8 and falls back to the code page.
- StringManager_test, XMLHandler_test and XMLParserBackend_test spell UTF-8
  text as narrow literals; MSVC encoded them in the build machine's code page
  (cp1252: "Grüße β ??"), so comparisons failed and a missing lookup
  segfaulted. Compile these three with /utf-8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] XMLFile: keep the 64 KiB parse chunk on the heap

The libxml2 reader read input into a 64 KiB stack array; Xerces kept its
buffers on the heap. Readers run deep in call stacks and on OpenMP worker
threads, with 1 MB stacks on Windows. FragmentIndex_test, whose single
test function holds ~90 FragmentIndex objects (7 KB each) and loads the
modification and enzyme databases from that frame, crashes on Windows CI
on this branch (develop: passes); a stack overflow is consistent with it.
One allocation per parsed file, no measurable cost.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* fix: warn about same-file parent name mismatches while loading OBO files

checkName_() runs while loadFromOBO() is still filling terms_, so it must not
look ids up via index_, which is only rebuilt once loading finishes.

Also find libxml2's own package config first in OpenMSConfig.cmake for static
installations, as the build does, and drop the stale validation section from
the migration notes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [DOC] Install: libxml2 >= 2.13 is not packaged on several current distributions

Builds without vcpkg take libxml2 from the system. Ubuntu 24.04 and
Debian 13 ship 2.9.14, and RHEL, AlmaLinux and Rocky Linux 10 ship 2.12.5,
so the configure fails there. Name the minimum version and required
features, and point to vcpkg or a source build. The Dockerfile is no
longer a pure Ubuntu-packages build; say that it builds libxml2 itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L7rXfNq24PfjvsEM7cwX4h

* [TEST] DecompressingInputStream_test: include <algorithm> and Exception.h

GCC and Clang on Linux did not find std::min(initializer_list),
std::copy_n and the Exception namespace through the other includes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L7rXfNq24PfjvsEM7cwX4h

* [FIX] Remote mzML: no bogus I/O rate; reuse the whole decompression buffer

- MzMLHandler reported the load rate from File::fileSize(), which is -1 for
  remote URIs (develop's #9262), so S3 loads logged an absurd rate. It now
  reports none when the size is unknown.
- DecompressingInputStream refilled only the end of its input buffer after
  the buffer was consumed; it now starts at the front again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L7rXfNq24PfjvsEM7cwX4h

* [FEATURE] XMLFile: read HTTP, HTTPS and FTP URLs with libcurl

develop read these URLs through Xerces' network transport (#9262), which
the libxml2 reader no longer has. HTTPInputSource streams the resource with
libcurl's multi interface, driven from readBytes(), so at most one transfer
step is buffered. XMLFile reads it through the read-ahead thread, as it does
S3 objects and compressed local files, which overlaps network waits with
parsing.

- gzip and bzip2 content is decompressed (DecompressingInputStream), and
  HTTP transfer compression is decoded by libcurl.
- Redirects are followed, but only to HTTP(S) and FTP. HTTP 4xx/5xx are
  errors; 404/410 and missing FTP or file resources are FileNotFound.
- A transfer slower than 1 byte/s for two minutes fails instead of hanging.
- InputStream::cancel() lets the read-ahead thread stop a blocked read when
  a parse ends early (e.g. a metadata-only load), instead of waiting for a
  stalled server. libcurl's poll is woken up for it.
- The protocol restriction uses only protocols the libcurl build supports,
  and a transfer whose URL or restriction cannot be set does not start.
- CMake requires libcurl 7.66, for curl_multi_poll().
- file:// URLs are accepted by HTTPInputSource, so its class test reads
  local files through libcurl without network access.

The MzMLFile test checks that an unreachable server is a load error, and
loads OPENMS_TEST_HTTP_URL when it is set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L7rXfNq24PfjvsEM7cwX4h

* [DOC] Install: without a preset, OPENMS_USE_VCPKG=ON uses the vcpkg submodule's toolchain

CMakeLists.txt picks vcpkg/scripts/buildsystems/vcpkg.cmake when the
submodule is initialized and no toolchain file is given. An explicit
toolchain is only needed without the submodule (source tarballs).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* [FIX] Remote input: no credentials of the URL in log and error messages

A URL can carry credentials: user info (ftp://user:password@host/...,
s3://key:secret@bucket/...) or a token in the query of a presigned URL.
HTTPInputSource::redactURL() drops user info, query and fragment and
leaves local file names unchanged. HTTPInputSource, S3InputSource,
XMLFile's parse errors, XMLHandler's messages and the ParseError of
MzMLFile::load() use it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* [FIX] mzML: name CV-typed binary data arrays in one shared helper, for indexed reads too

MzMLHandler named arrays typed by a child term of MS:1000513 (binary data
array), e.g. ion mobility arrays (MS:1003008), after the term; the
indexed decoder (MzMLSpectrumDecoder) did not, so on-disc and indexed
reads lost these names and with them the ion mobility data.

MzMLHandlerHelper::handleBinaryDataArrayCVParam() now names these
arrays (and marks absorbance intensities), and MzMLHandler relies on it.
Both paths therefore agree, including the precedence of MzMLHandler:
the last array term wins. Accessions missing from the bundled CV stay
unidentified instead of throwing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* MzMLSpectrumDecoder: store m/z and intensity array meta data in the spectrum, as MzMLHandler does

Indexed reads dropped the meta data of the default arrays, e.g. the
absorbance flag of an intensity array (MS:1000515 with UO:0000269), so
writing such a spectrum back to mzML used the wrong intensity unit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* MzMLFile::load: parallel load of indexed mzML with OpenMP (#10728)

Uncompressed indexed mzML without load filters is split at spectrum offsets
from the index into byte-balanced chunks (at least 1 MB, up to 4 per
thread, at most 32 threads). Each chunk is parsed with the document header
and closing tags by a normal MzMLHandler, so metadata and peaks are parsed
exactly as in the serial load; chromatograms form one extra chunk. Parts are
concatenated in document order.

Single-threaded, compressed, unindexed, small or filtered loads, and any
index/document count mismatch, keep the serial streaming parse.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Timo Sachsenberg <[email protected]>

* MzMLFile::load: keep remote input on the serial path and its document identifier (#10752)

#10728 was merged without the fix from its review: the serial fallback reset
the map and called setLoadedFileType(filename)/setLoadedFilePath(filename)
unconditionally, undoing the remote branch above it. For a URL,
setLoadedFileType(filename) sniffs the content and throws FileNotFound, so
every s3:// load failed (and every http(s)/ftp load once #10727 is in), and
MzMLFile_test's "load from HTTP URL" section got FileNotFound instead of the
expected ParseError. With 2+ threads, loadParallelIndexed_ also ran on URLs,
which it cannot read (std::ifstream on the URI).

Now remote input always takes the streaming parse, and the document
identifier is set once, in the serial branch.


Claude-Session: https://claude.ai/code/session_0149aXmaayHbZ6MkxFhfzX1D

Co-authored-by: Claude <[email protected]>

* [FEATURE] HTTPInputSource: range reads, so IndexedMzMLDecoder reads the index over HTTP

objectSize() (HEAD) and readRange() (range request) mirror S3InputSource's, and
IndexedMzMLDecoder uses them for HTTP/HTTPS/FTP URLs as it does for s3://.
From a server that ignores the range (200 instead of 206), readRange() skips
to the offset itself. The transfer options and the error mapping are shared by
the stream and the new single requests.

HTTPInputSource_test now also runs a small HTTP server on 127.0.0.1: plain,
gzip and bzip2 resources, HTTP 404, MzMLFile::load, objectSize, byte ranges
(also from a server that ignores them) and the index of an indexed mzML.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] IndexedMzMLDecoder::findIndexListOffset: no error output for a file without index

MzMLFile probes every uncompressed mzML for an index before a parallel load
(#10728) and in hasIndex(), so ordinary mzML loads printed 'Could not find
element indexListOffset' when OpenMP had two or more threads. -1 is the
documented result for a missing index; IndexedMzMLHandler, the caller that
needs one, now reports it instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] No URL credentials in Arrow and libcurl diagnostics or binary-data parse errors

poshul's review of #10710 (reproduced on this branch):
- Arrow's status messages repeat the URI they were given, e.g. for an invalid
  port, so S3InputSource exposed the access key, secret and query token although
  it redacted the name it shows itself. HTTPInputSource::redactURLs() redacts
  every URL inside such a text; S3InputSource passes Arrow's diagnostics and
  HTTPInputSource libcurl's error messages through it.
- MzMLHandler, MzXMLHandler and ImzMLHandler threw ParseErrors for undecodable
  binary data with the file name as given, and MzMLFile::load rethrows those
  unchanged. They now use the redacted name.

Tests: redactURLs() on Arrow-style messages; an S3 URI with credentials and an
invalid port; MzMLFile::load of corrupt binary data from a URL with a password
and a token (fails without the handler fix).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] HTTPInputSource: decompress gzip transfer compression as the stream is read

libcurl decoded Content-Encoding itself, and it decodes everything one
curl_multi_perform() receives at once. For highly compressed content the
write callback then buffered far more than one transfer step: a 128 MiB
XML document served with Content-Encoding: gzip (190 KiB on the wire)
was buffered completely in makeStream(), raising the peak RSS from 36 to
294 MiB.

The stream now asks for gzip itself (Accept-Encoding: gzip) with libcurl's
content decoding off. The compressed body is recognized by its magic bytes
and decompressed by DecompressingInputStream as the parser reads, as a
.gz resource is. The same document now reads with a peak RSS of 38 MiB.

The test server serves /encoded/ paths with gzip transfer compression when
the client accepts it; HTTPInputSource_test checks the content and that it
is decompressed by the stream, and MzMLFile::load of such a URL.

Also: TEST_FALSE for a boolean check, and [in] tags for all documented
parameters of HTTPInputSource.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* [CLEANUP] Remove leftovers of the Xerces migration

- CI: the Xerces-removal guard (tools/ci/check_no_xerces.py, its tests and the
  build step) and -DCMAKE_DISABLE_FIND_PACKAGE_XercesC, which nothing looks for
  any more.
- doc/xml_libxml2_migration.md: notes of the fork's migration (guard commands,
  links to its benchmark reports); the PR description has the current state.
- Xerces API shapes no caller uses: InputStream::getContentType(),
  CompressedInputSource's char16_t* constructor and getSystemId(), and the
  global XMLCh alias of the test framework (tests use char16_t).
- Stale Xerces mentions: the Xerces valgrind suppression, the devcontainer's
  dependency list, and comments that compared with Xerces.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JajmMxMmR16NiPzK3mVX2r

* [FIX] S3InputSource: finalize S3 at exit also when no object was opened

The exit handler that finalizes Arrow's S3 APIs was registered only after the
first S3 filesystem was made. A URI that failed before that (e.g. an invalid
port, as in S3InputSource_test since b145d05) left S3 initialized but never
finalized: Arrow warned at exit, and on macOS the test crashed at exit
(SEGFAULT after PASSED).

The handler must run before the statics that Arrow creates with its first S3
client are destroyed, so it is registered after them. ensureS3Initialized()
now makes that first client right after the initialization (anonymous, it
does not connect) and registers the handler then, once, whatever the URI.

S3InputSource_test also checks an S3 server that cannot be reached: a client
is made after the first one, and the process still exits cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* [FIX] HTTPInputSource::objectSize: a GET of the first byte instead of HEAD

A presigned URL (e.g. of S3 or GCS) is signed for one request method, usually
GET, and refuses a HEAD request (403), so objectSize() failed for it and the
index of an indexed mzML could not be read. For HTTP(S), objectSize() now
requests the first byte (Range: bytes=0-0) and stops the transfer at the
first byte of the body:
- 206: the size from Content-Range ("bytes 0-0/<size>")
- 416: the same ("bytes */<size>"), for an empty resource
- 200 (a server that ignores the range): Content-Length
- other 4xx/5xx: errors as before (404/410: FileNotFound)
FTP and file URLs, also after a redirect from HTTP to FTP, keep a request
without body (SIZE).

The test server gains a redirect (/moved/, with a body), a URL presigned for
GET (/signed/: 403 for HEAD or without the signature), an empty resource and
Content-Range in its 416. Tests: objectSize() of each, a redirect for
makeStream(), readRange() of a presigned URL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

* [FIX] Remote input: both compression layers over HTTP; no URL parts in Arrow and libcurl messages

Two findings of poshul's review of c0524b1:

1. A server can send a compressed resource (.mzML.gz, .mzML.bz2) with gzip
   transfer compression. makeStream() decoded by magic bytes once, so it
   removed only the transfer compression and handed the parser gzip or bzip2
   bytes. The response's Content-Encoding is now collected (ResponseHeader,
   shared with objectSize()'s Content-Range). With gzip transfer compression,
   makeStream() decompresses that layer first, then the resource's own
   compression by its magic bytes, as for a local file. A small
   PeekingInputStream gives the decompressed stream the peek() for that;
   every layer still decompresses as the stream is read.

2. Arrow can repeat a part of the URI on its own, e.g. "Invalid S3
   connection scheme 'MY_SECRET_SCHEME'" for ?scheme=MY_SECRET_SCHEME, which
   redactURLs(text) cannot recognize. New HTTPInputSource::redactURLs(text,
   url) also replaces the user name, password, query values and fragment of
   the URL (as given and percent-decoded) with "***" where they are a whole
   word of the text. All Arrow messages of S3InputSource and all libcurl
   messages of HTTPInputSource go through it.

Tests:
- The test server sends .mzML.gz and .mzML.bz2 with gzip transfer
  compression (new test files MzMLFile_6_uncompressed.mzML.gz.gz and
  .mzML.bz2.gz); makeStream() and MzMLFile::load of both match the local
  files. The check that OpenMS, not libcurl, decodes the transfer compression
  is now behavioural: corrupt transfer-compressed data is a ParseError
  (libcurl would report an IOException).
- redactURLs(text, url): a query value on its own, user info as given and
  decoded, the fragment, whole words only, nothing for URLs without such
  parts or local file names.
- S3InputSource_test: the reproduction (an invalid scheme value) is not in
  the message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AWyp5bGPCCbyzyBucWrYkb

---------

Co-authored-by: Oliver <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Oliver Kohlbacher <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants