Repository navigation
[TH-9449] fix(harness): answer Dileep's P3 comments on #273, #275, #277 and #285 - #293
Merged
khushalsonawat merged 13 commits intoNov 11, 2026
Conversation
- A folder is charged once across the walk's two passes. The side pass charged every folder again, so the folder charge grew to about twice what os.walk holds. - The estimate's sizes name the Python they were measured on (3.12, the hosted kit venv's), and a test fails when that venv's Python changes. The str size is 3.11's, which is high on 3.12 and 3.13. - A held-budget stop while joining logs "passed its memory budget", and says the rows found are dropped. - The unused per-file join constant is dropped. A fan-out test (one entry, 200 hubs, 20,000 leaves) holds the join's charge without its base. TH-9449 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com> (cherry picked from commit 7c8bf7569bed979cf85ebbb0780d5264aa305183) Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
Dileep's P3: on Python 3.11 os.walk is recursive and has no `stack` local, so the watcher read nothing and the bound test passed vacuously. The watcher now reads `stack` by key, so a missing one fails loudly, and both stack tests are skipped below 3.12 with that reason. TH-9511 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com> (cherry picked from commit b755aab5aa761d115b00fd0bf004df2aef780db7) Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
Dileep's P3: inside one folder the look never read the clock, so a folder of millions of entries ran to the end of its listing past the deadline. It now reads the clock every 4,096 entries (_LOOK_CLOCK_EVERY) and stops as "clock". An empty source still never reads it. TH-9525 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com> (cherry picked from commit 228c33d8f558c749c6df9caf7c8e66bed74532f7) Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
Dileep's P3 nit: sorting the files changed nothing, since only their count and agent.py's are used. The line is dropped, and the comment says why the folders alone are sorted. TH-9514 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com> (cherry picked from commit 9daa22e839b4800ea4f75a3415619b120e7b2941) Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
The change review of the in-folder clock (two reviewers, cleared) found the test never covered links, never passed the 64 MiB bound, and didn't pin where the clock is read. Two tests are added, and the first one now asserts the exact count held at the 4,096th entry. TH-9525 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
The change review's Low: inside the loop the generator's frame always exists. TH-9511 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
…ils without it The change review (round 1, a High) found that dropping _JOIN_PER_FILE let the join's real rise pass its charge, on a fan-out whose leaves each import one shared module. The author's test had leaves that imported nothing, so they shared CPython's empty tuple and hid the cost. The constant is back at 64, and the fan-out test's leaves import a shared module, so the test fails with the constant at 0. TH-9449 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
… the venv line The change review's Lows: the folder-charge test had no dot folder, so a side pass that skipped them went unseen; and the Dockerfile check was a substring, so a later line re-creating the venv on another Python passed. The tree gains .github/workflows and app/.hidden/x, and the check finds the one line that makes /opt/alk-venv. TH-9449 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
… growth Change review B (round 1): at 20,201 files the join's import table sat just below its resize at 21,846, its cheapest point. The test now has 110 hubs of 199 importing leaves (22,002 files). It passes with the per-file charge at 64 and fails at 48, 32 and 0. TH-9449 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
…t go at a budget stop Change review round 2 (A, Lows): a constant of 56 still passed the one-entry fan-out. A second shape, two entries over the same hubs, is dearer (about 59.5 bytes a file) and fails at 56. The venv check now counts every line that makes /opt/alk-venv, and the budget-stop test checks the facts are let go before the empty result is built. TH-9449 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
cdileep23
approved these changes
Nov 11, 2026
…names out of comments Dileep's P3s on this PR: - With each subfolder charged once, a wide folder's own names, which os.walk holds while the walk is in it, were no longer covered by the old double charge: 50,200 empty folders charged 10.44 MB against a 12.59 MB peak. Each folder's listing is now charged once, when the walk reaches it, before any name is filtered out. A test of 30,000 empty folders holds the walk's peak under the charge. - The new tests' docstrings and comments no longer name the reviewer or the review; the reasons stay. TH-9449 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
…before the filter The one-reviewer check of the listing charge cleared, with two Mediums: - Building one tuple of every name held a slot a name while os.walk still held the listing, so 250,000 files charged 18.26 MB against a 19.06 MB peak. The two lists are summed apart. - Nothing held "before any name is filtered out". The wide-folder test now covers folders, files and links to a folder (listed as folders, then left out), and a charge moved after the filter fails it. Also: the first-pass test is computed once per folder, and two older test docstrings no longer name the reviewer. TH-9449 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
…nto feat/TH-9449-dileep-p3-followups Signed-off-by: khushalsonawat <khushalsonawat@gmail.com> # Conflicts: # tests/harness/test_scan_walk.py
khushalsonawat
merged commit Nov 11, 2026
fe73f07
into
feat/TH-8804-source-subfolder
11 checks passed
This was referenced Nov 11, 2026
khushalsonawat
added a commit
that referenced
this pull request
Nov 11, 2026
…ate-names-from-code test_scan_walk.py: both sides appended tests at the end (this branch's template-name tests, Signed-off-by: khushalsonawat <khushalsonawat@gmail.com> #293's folder-charge tests); both kept.
15 of 16 tasks
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.
Description
Answers Dileep's nine P3 comments on #273, #275, #277 and #285, which merged before the fixes were ready. Everything is in the scan's bounds and its tests.
Type of Change
Changes, comment by comment
#273 (scan walk memory budget)
scan_walk.py:932, folders charged twice. The side pass now charges only the folders the first pass never entered: side folders, and folders below one. Each folder is charged once (883ace6a). On 50,200 empty folders the charge halves, from 14.46 MB to 7.23 MB. Tested bytest_each_folder_is_charged_once_across_the_two_passes, which includes dot folders.:215, sizes from the wrong Python._SIZES_MEASURED_ON), and that the str header is 3.11's, so it runs high on 3.12 and 3.13.test_the_estimates_sizes_were_measured_on_the_hosted_kits_pythonfails if the Dockerfile's one line that makes/opt/alk-venvnames another Python.test_the_estimate_rounds_each_object_up_to_its_blockalready fails on 3.14, where the tuple is larger.test_scan_walk.pyis insdk-smoke.yml's list, so CI runs it.:1476, a budget stop while joining logged "edge budget". It now has its ownexcept, which logs "passed its memory budget" and lets the facts go before the empty result; the rows found are dropped there.:228,_JOIN_PER_FILEuntested. The constant stays at 64. Two fan-out shapes, each about 22,000 files whose leaves import one shared module, check the join's real rise against its per-file charges without_JOIN_BASE:The two-entry shape needs about 59.5 B a file, so the test passes at 64 and fails at 56, 48, 32 and 0. A first attempt dropped the constant, and the change review showed that under-charged the join.
:1579, memory outside the budget. Recorded under "Known limits" below.#275
6.
test_framework_detection.py:1759, the watcher read nothing on 3.11. It now readsos.walk'sstackby key, so a missing one fails loudly. Both stack tests are skipped below 3.12, with the reason, because before 3.12os.walkrecurses and has no list to watch.#277
7.
agent_scan.py:182, no clock inside one folder._LOOK_CLOCK_EVERY). In a 250,000-entry folder past the deadline, the overrun drops from 1.1 s to 18 ms for dangling links, and from 95 ms to 2 ms for empty folders.scan_timed_out(return 0) rather thanscan_source_missing(return 1).agent_scan.py:150, a cost with no floor. As Dileep allowed, this is left as a follow-up: one shared folder-cost helper with fix(harness): bound the framework check's walk by the folders it lists (TH-9511) #275's floor, for fix(harness): bound the scan walk by what it holds, merge its two readers, test its untested branches (TH-9449, TH-9450, TH-9451) #273's hazard look, fix(harness): bound the framework check's walk by the folders it lists (TH-9511) #275 and this look. Recorded in "Known limits".#285
9.
scan_walk.py:1547,files.sort()changed nothing. Dropped; the comment says only the folders need an order.Contract:
scan-parts.md1.3m (#273's folder charge, and the per-file join charge named) and 1.3n (#277's clock).Testing
All runs on Python 3.12.3, the hosted image's minor version.
test_scan_walk,test_agent_scan,test_framework_detection,test_scan_ai,test_scan_folders,test_scan_documentandtest_authoring_entrypoint_find_agents. 605 passed.files.sort()to_hazardpasses, since the order can't matter._JOIN_PER_FILEunder-charged the join, so the constant is kept. Round 2 cleared.edf7bea6), fix(harness): bound the scan's first look for a file (TH-9525) #277's added tests (c8883737), and the contract wording.Known limits
describe_entry's reader has no held budget. Only_DESCRIBE_BYTESbounds it: 700 files of 200 unique dotted imports each peaked at 349 MB in one description. This isn't a regression.os.walk's file and subfolder names for the current folder aren't charged; only the folders still to visit are. On 50,200 sibling folders the walk is charged 7.23 MB against a traced peak of 8.82 MB. This isn't a regression, and the contract already lists one folder's listing as not bounded.fileandlimitdepends on the checkout root's length. One shared helper with fix(harness): bound the framework check's walk by the folders it lists (TH-9511) #275's floor is a follow-up (comment 8).Related Issues
Refs: TH-9449, TH-9511, TH-9514, TH-9525