Repository navigation
refactor: read a directory's listing in chunks - #1528
Merged
Merged
Conversation
skip-changelog: test only
skip-changelog: internal restructuring, no observable change
Each chunk keeps its own name buffer, and an entry records its chunk in u32 offsets, so a listed entry shrinks from 32 to 24 bytes. skip-changelog: internal restructuring, no observable change
8 tasks done
A mutant that empties every listed name made the walk re-enter each directory without end, exhausting the mutation runner's memory. skip-changelog: no observable change
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.
Refs #1461
Step one of the wide-directory redesign: read a directory's listing in chunks. This is a structural change with no observable effect. Later steps sort and judge each chunk while the next one is being read, then merge the chunks.
listing::read_chunks(dir, emit)hands a directory's entries toemitasChunks, at mostCHUNK_ENTRIES(8192) at a time, as it reads them. It applies on every platform (LinuxRawDir, other UnixDir, Windowsread_dir).Listedentry records its chunk andu32offsets into it, so it is self-contained across chunks and shrinks from 32 to 24 bytes.Listing::readcollects the chunks and sorts them together, so nothing outsidelisting.rschanges.Output is byte-identical: same md5 for
./docsand./on a 1.6M-item tree.Timings
These are paired medians on ZFS with other agents running, load 10-34.
./docs(1.57M entries) vsrg./*vsrg./docs./*./**/*.mdNeutral within noise. Where a wide directory's time goes (instrumented,
./docs):getdentstakes about 350ms, pushing entries about 25ms, sorting about 55ms, and judging about 200ms. Sort and judge are what the later steps hide behind the read.E2E Verification
packages/python/e2e-attestations/<branch>.jsonreceipt written ifpackages/pythonchanged (just e2e-attest-python)packages/ts/e2e-attestations/<branch>.jsonreceipt written ifpackages/tschanged (just e2e-attest-ts)uv run maturin develop --release,cargo build --release -p dirsql --features cli,testing-conventions e2e attest 'uv run python -m pytest tests/e2e/glob_speed_one_level_test.py tests/e2e/glob_speed_recursive_test.py tests/e2e/glob_speed_depth_bound_test.py tests/e2e/glob_speed_gitignore_test.py tests/e2e/glob_speed_dotfiles_test.py tests/e2e/glob_speed_matchers_test.py tests/e2e/glob_speed_node_modules_test.py tests/e2e/glob_speed_symlink_test.py tests/e2e/stat_speed_test.py tests/e2e/query_contract_test.py -q',just e2e-attest-ts,cargo test --workspace --features cli./docs/, a 12ms native case, at load 15; it passed on rerun and in the full rerun. ts passed; cargo workspace all passed.Changelog / Migrations
skip-changelogtrailer: internal restructuring, no observable change.Merge with main (2026-10-19)
Diragain, soread_into(nowDiron every Unix) takes aChunker;RawDirandENTRY_BUFFERare gone.Listing::holdsstays.judgenow skips an entry with an empty name. An in-diff mutant that empties every name made the walk re-enter each directory forever and killed the mutation runner../**/*.md1.018x,./**/{a,b}*.md1.006x (neutral). Python e2e subset passed, 29 tests.