Repository navigation
Conversation
jwalk 0.9's changelog says it is no longer maintained and points to dua-core, the walker its author now develops in dua-cli. dua-core asks before it reads each directory, so pks still skips hidden, gitignored and excluded directories without reading them. Each entry names the directory it's in, so once the walk is done, each file is matched to the package.yml nearest above it, from the package.yml files the walk found, with no stat of each directory for one. pks skips hidden entries, as jwalk did and packwerk's globs do. dua-core never follows symlinks. A symlink to a file still counts as the file, but pks no longer descends into a symlinked directory, as packwerk's globs don't either. jwalk followed links, and a link to a directory that contains it, such as `loop -> ..`, made pks list the same files and packs dozens of times. dua-core's workers stop once a few batches of entries wait for pks's loop, which happens each time the loop parses a package.yml. Until a release has Byron/dua-cli#413, a thread takes the entries as they come, so the walk takes as long as it did. On every fixture and four Rails apps, list-included-files, list-packs and list-references print the same as before.
Two restated the code under them, and three said more than they needed to.
Byron/dua-cli#413 merged as Options::queued_batches_per_worker, which keeps the default of two batches, so pks will set it once it is released.
- `--project-root` naming a file panicked on an `expect`, as dua-core yields a file root with no directory. It again ends in "No root pack found", as on `main`. - The walk takes rayon's number of threads, so `RAYON_NUM_THREADS` limits it, as it limited jwalk, which ran on rayon's pool. - `read_directory` skips a directory it can't make relative instead of unwrapping. dua-core's workers don't catch a panic, so one there would hang pks rather than abort it. - Directories are recorded before hidden names are skipped, so a file's directory is always known. That held only because `read_directory` skips hidden directories too. - Which package.yml each file belongs to is collected into a map of the right size. Growing it took about 80 ms on 118,000 files, against 27. - That resolution is now `package_ymls_of_directories`, with a unit test that gives it directories before their parents. Removing the sort by depth failed no test, since whether the walk yields a directory first varies from run to run. - The symlinked-directory test also links a directory with a name like a Ruby file's, which `exists()` in place of `is_file()` would list. - Comments that described jwalk's design are updated, and the thread that drains the walk is `draining`.
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
package.ymlafter the walk. Each entry dua-core yields names the directory it's in, and a file can come before its directory'spackage.yml. So the walk records the directories and thepackage.ymlfiles it finds, and once it's done, each included file gets thepackage.ymlnearest above it. pks no longer checks each directory for apackage.ymlwith astat.package.yml. I opened perf: let walk workers queue more batches ahead of the iterator Byron/dua-cli#413 to let them queue more, and it merged asOptions::queued_batches_per_worker, keeping the default of two batches. Once a release has it, pks can set it and drop the thread.RAYON_NUM_THREADSstill limits it, as it limited jwalk, which ran on that pool.Behavior change: symlinked directories
dua-core never follows symlinks, while jwalk did, as pks set
follow_links(true). So pks now does what packwerk'sDir.glob("**/*.{rb,rake,erb}")does with a symlinked directory:mainpacks/foo/loop -> ..So an app with a symlinked pack, or files under a symlinked directory, loses them. The CHANGELOG says so.
One smaller difference: files in a directory named
package.ymlbelonged to no pack onmain, socheckstopped with "Could not find pack for referencing file path". They now belong to the pack above it.Equivalence
I built
mainand this branch and comparedlist-included-files,list-packsandlist-references(sorted, with--no-cache) on every fixture and on four Rails apps, the largest with about 54,000 included files, 772 packs and 201,000 references.list-referencesnames each reference's pack, so it covers thepackage.ymleach file belongs to.list-referencesonapp_with_monkey_patchespanics on both, naming its two duplicate definitions in an order that varies from run to run onmaintoo.Performance
The time between the walk's "Beginning directory walk" and "Finished directory walk" debug logs, medians of 15 runs alternating between the binaries. The machine was busy throughout (load average 10 to 18), so the times are rough.
package.ymlafter the walk costs little. Collecting the matches into a map of the right size takes about 27 ms on 118,000 files, where growing the map took about 80.Test plan
cargo test(371 tests), withcargo fmt --checkandcargo clippy --all-targets --all-features -- -Dwarnings.tests/list_included_files_test.rs:maintoo);maintoo);loop -> ..aren't descended into (fails onmain);--project-rootnaming a file ends in "No root pack found", as onmain, rather than a panic.package.ymlresolution directories before their parents. Without the sort by depth it panics. Until now, removing the sort failed no test.read_directoryremoved,test_list_included_files_excludes_gitignoredandtest_check_ignores_violations_in_gitignored_filesfail, and withexists()in place ofis_file()for a symlink, the symlinked-directory test fails.Buildjobs build and run pks on every release target.