Skip to content

[TH-9449] fix(harness): answer Dileep's P3 comments on #273, #275, #277 and #285 - #293

Merged
khushalsonawat merged 13 commits into
feat/TH-8804-source-subfolderfrom
feat/TH-9449-dileep-p3-followups
Nov 11, 2026
Merged

khushalsonawat merged 13 commits into
feat/TH-8804-source-subfolderfrom
feat/TH-9449-dileep-p3-followups

Conversation

@khushalsonawat

Copy link
Copy Markdown
Member

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

  • Bug fix
  • Tests

Changes, comment by comment

#273 (scan walk memory budget)

  1. 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 by test_each_folder_is_charged_once_across_the_two_passes, which includes dot folders.

  2. :215, sizes from the wrong Python.

    • The comment now says the sizes are 3.12's, the hosted kit venv's (_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_python fails if the Dockerfile's one line that makes /opt/alk-venv names another Python.
    • test_the_estimate_rounds_each_object_up_to_its_block already fails on 3.14, where the tuple is larger.
    • test_scan_walk.py is in sdk-smoke.yml's list, so CI runs it.
  3. :1476, a budget stop while joining logged "edge budget". It now has its own except, which logs "passed its memory budget" and lets the facts go before the empty result; the rows found are dropped there.

  4. :228, _JOIN_PER_FILE untested. 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:

    • with one entry, the import table has just grown;
    • with two entries, the second search's seen set grows while that table is full.

    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.

  5. :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 reads os.walk's stack by key, so a missing one fails loudly. Both stack tests are skipped below 3.12, with the reason, because before 3.12 os.walk recurses and has no list to watch.

#277
7. agent_scan.py:182, no clock inside one folder.

  • The source look reads the clock every 4,096 entries (_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.
  • New tests cover a huge folder of empty folders (with the exact count held when the clock stops it), a huge folder of links, and a folder past the 64 MiB bound.
  • One behaviour change: a source whose own folder holds 4,096 or more entries and no regular file, past the deadline, now ends scan_timed_out (return 0) rather than scan_source_missing (return 1).
  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.md 1.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.

Known limits

Related Issues

Refs: TH-9449, TH-9511, TH-9514, TH-9525

- 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>
@khushalsonawat khushalsonawat self-assigned this Nov 11, 2026

@cdileep23 cdileep23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the comments.

Comment thread src/fi/alk/harness/scan_walk.py Resolved
Comment thread tests/harness/test_scan_walk.py Resolved
…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
khushalsonawat merged commit fe73f07 into feat/TH-8804-source-subfolder Nov 11, 2026
11 checks passed
@khushalsonawat
khushalsonawat deleted the feat/TH-9449-dileep-p3-followups branch November 11, 2026 12:31
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.
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.

2 participants