Skip to content

fix(research): the partition scanner stops at 16,777,216 candidates by default and says so, from what the 28 real files of Revit 2023 and 2024 keep (#1833) - #2031

Merged
DrunkOnJava merged 4 commits into
mainfrom
research/1833-scan-candidates
Nov 15, 2026
Merged

DrunkOnJava merged 4 commits into
mainfrom
research/1833-scan-candidates

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

ScanOptions::default() now stops at 16,777,216 candidates (2^24), and PartitionScan::truncated says when a scan reached the cap. It was the one site of #1833 left: the research API's partition scanner, which kept every schema tag followed by two zero bytes with no limit.

Motivation

#1833 site R: a stream holds up to one candidate for every four of its bytes, and each takes about 250 bytes (160 inline, and three short strings), so a crafted stream could take about 67 GB of candidates from the 1 GiB the reader lets a stream inflate to. The comment on #1833 said a default cap needs the candidate totals of real files first, so that it never cuts a real scan. This is that measurement.

Measured (Measure 43663157788, probe_1833_scan_candidates, the 28 files of Revit 2023 and 2024 it read; the scanner returns nothing on other releases):

  • The most candidates in one file: 9,675,757 (the BIM4LCA timber office at building permit, 696 MB inflated, 59 streams).
  • The most in one stream: 6,531,651 (Autodesk's Snowdon Towers architectural sample).
  • The fullest stream holds 14.7% of the one-in-four-bytes maximum (the BIM4LCA office at permit). The median file holds one candidate for every 82 bytes, and the range is 57 to 171.
  • A candidate is 160 bytes inline (printed by the probe). The strings' heap is counted at 3 x 32 bytes and is not measured.

So the default is 2^24, 1.7 times the most any of them keeps. A real file at that figure takes about 2.4 GB of candidates today, so the cap does not make the research scan cheap; it stops a crafted stream at about 4 GB where it could take 67 GB.

Changes

  • src/research/partition_scanner.rs: DEFAULT_MAX_CANDIDATES (2^24) with the measurement in its doc comment, the default ScanOptions and arcwall_2023_only use it, PartitionScan::truncated (#[serde(default)]), a "Budget" section in the module docs.
  • examples/partition_scanner_json.rs: keeps the default cap unless --max-candidates or the new --no-cap is given (it set None when the flag was absent), and prints truncated.
  • probes/examples/probe_1833_scan_candidates.rs: the probe, which prints truncated too.
  • tests/partition_scanner.rs: a real-file check (einhoven_scan_says_when_it_reached_the_cap): Einhoven's default scan is not truncated, and with max_candidates 10 the scan is truncated and lists the first 10 candidates of the whole scan.
  • changelog.d/security/1833-scan-candidates-cap.md.

Testing

Measure 43664481547, unfiltered against the merge base, with samples, nordic, r2025 and holdout, and the probe run 43664485165 on the 2023 and 2024 files. Rows registered before they are read:

  1. Every export and every diagnostics.json is byte for byte the merge base's: nothing in the export or the CLIs calls the scanner. Held (run 43664481547, head 0dd5143c, the commit holding every src change; the later commit adds a test): 120 of 120 exports and 102 of 102 diagnostics.json identical to the merge base.
  2. The probe reports truncated=0 on all 28 files and the same candidate counts as run 43663157788. Held (run 43664485165, head 0dd5143c): truncated=0 on all 28 supported files, and release, scan, streams, inflated bytes, candidates, largest stream and fill are identical to run 43663157788 on all 33 models, the most candidates in a file still 9,675,757.
  3. same-project gates pass. Held on 0dd5143c: 15 samples held to their earlier saves, and the Areas on 4 saves and on the 2021 save; the semantic diff finds no difference in 42 models.
  • tools/check-local.sh: no local builds; rustfmt --check passes; CI runs the rest.

Audit-honesty checklist

  • The figures above are from the run named; the 250 bytes per candidate is arithmetic on the measured 160 plus an assumed 96 for the strings, and the changelog says "about".
  • A changelog fragment.
  • No emojis, private paths or jargon.

Legal and contribution hygiene

  • Apache-2.0; no Autodesk source; no fixtures.

Breaking changes

PartitionScan gains a field, and ScanOptions::default() now caps the scan. Both are in rvt::research (behind unstable-research). A caller that needs more than 2^24 candidates sets max_candidates to None.

Closes #1833: sites A to Q landed in #1835, #1847 and #1849, and this is R.

… keeps on each file, per stream and in all, for the default cap site R of #1833 needs (#1833)

ScanOptions::default() has no cap on candidates, and a default cap has to stay
above what real files keep. The probe prints, for each file on a release the
scanner supports (2023, 2024), the candidates per partition stream beside the
stream's inflated length, the largest share of the one-per-four-bytes maximum
any stream reaches, and the size of one candidate.
…y default and says so, from what the 28 real files of Revit 2023 and 2024 keep (#1833)

ScanOptions::default() had no cap on candidates, and a candidate is any schema
tag followed by two zero bytes, so a stream holds up to one for every four of
its bytes and each takes about 250 bytes of memory. Measure run 43663157788
counted what real files keep on the 28 files of Revit 2023 and 2024 it read:
at most 9,675,757 candidates in a file and 6,531,651 in a stream, and no stream
over 14.7% of the one-in-four-bytes maximum. The default is now 2^24, 1.7 times
the most any of them keeps, and PartitionScan::truncated says when a scan
reached it. The example keeps the default unless --max-candidates or --no-cap
is given.
…the candidates a whole scan lists first and says it was cut, and the default cap leaves Einhoven whole (#1833)

Nothing exercised PartitionScan::truncated or a cap reached on a real file.
Einhoven's scan with the default options is not truncated; with
max_candidates 10 it is, and its candidates are the first 10 of the whole scan.
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 15, 2026 02:12
@DrunkOnJava
DrunkOnJava merged commit afbaabb into main Nov 15, 2026
63 checks passed
@DrunkOnJava
DrunkOnJava deleted the research/1833-scan-candidates branch November 15, 2026 02:23
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.

Crafted files: eighteen readers do unbounded work or hold unbounded memory, two of them exponential

1 participant