fix(clean): reduce Python bytecode output spam#672
Open
sebastianbreguel wants to merge 3 commits intotw93:mainfrom
Open
fix(clean): reduce Python bytecode output spam#672sebastianbreguel wants to merge 3 commits intotw93:mainfrom
sebastianbreguel wants to merge 3 commits intotw93:mainfrom
Conversation
Filter out __pycache__ directories that contain no .pyc/.pyo files at scan time. These empty dirs produce 0 B output lines that spam the terminal when running mo clean. Closes tw93#633
Add miniconda3, anaconda3, miniforge3, mambaforge, and site-packages to the find prune list in scan_project_cache_root. These directories contain thousands of __pycache__ dirs from installed packages that should not be cleaned, and traversing them causes 10-15 minute scans.
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
Fixes the output spam and performance issue when
mo cleanencounters many__pycache__directories.Users reported 3000+ lines of
Python bytecode cache · X, 1 dirs, 0 Boutput and 10-15 minute runtimes (#633). The root causes were: (1) empty__pycache__dirs left from previous cleanups still being processed, and (2) the scan traversing conda/pipsite-packagestrees with thousands of package__pycache__dirs.Changes
1. Skip empty
__pycache__dirs at scan timescan_project_cache_rootnow checks whether each__pycache__directory contains.pycor.pyofiles before including it in the results. Empty dirs (left over from previous cleanups or created by tooling) are silently skipped.2. Prune conda and site-packages from scan tree
Added
miniconda3,anaconda3,miniforge3,mambaforge, andsite-packagesto thefindprune list. These directories contain__pycache__dirs from installed Python packages — cleaning them would break installed packages, and traversing them was the main cause of 10-15 minute scan times.Visual preview
Before (from #633):
After:
Only projects with actual bytecode files produce output.
What changed
lib/clean/caches.sh__pycache__inscan_project_cache_root; add conda/site-packages to prune listtests/clean_system_caches.batsTest plan
bats tests/clean_system_caches.bats— all 18 tests pass (2 new + 16 existing)__pycache__dirs excluded from scan resultsCloses #633