Repository navigation
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
Conversation
… 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
marked this pull request as ready for review
November 15, 2026 02:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ScanOptions::default()now stops at 16,777,216 candidates (2^24), andPartitionScan::truncatedsays 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):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 defaultScanOptionsandarcwall_2023_onlyuse it,PartitionScan::truncated(#[serde(default)]), a "Budget" section in the module docs.examples/partition_scanner_json.rs: keeps the default cap unless--max-candidatesor the new--no-capis given (it setNonewhen the flag was absent), and printstruncated.probes/examples/probe_1833_scan_candidates.rs: the probe, which printstruncatedtoo.tests/partition_scanner.rs: a real-file check (einhoven_scan_says_when_it_reached_the_cap): Einhoven's default scan is not truncated, and withmax_candidates10 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:
diagnostics.jsonis byte for byte the merge base's: nothing in the export or the CLIs calls the scanner. Held (run 43664481547, head0dd5143c, the commit holding everysrcchange; the later commit adds a test): 120 of 120 exports and 102 of 102diagnostics.jsonidentical to the merge base.truncated=0on all 28 files and the same candidate counts as run 43663157788. Held (run 43664485165, head0dd5143c):truncated=0on 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.same-project gatespass. Held on0dd5143c: 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 --checkpasses; CI runs the rest.Audit-honesty checklist
Legal and contribution hygiene
Breaking changes
PartitionScangains a field, andScanOptions::default()now caps the scan. Both are inrvt::research(behindunstable-research). A caller that needs more than 2^24 candidates setsmax_candidatestoNone.Closes #1833: sites A to Q landed in #1835, #1847 and #1849, and this is R.