perf(uninstall): optimize pkg receipt scan (#798)#799
Merged
Conversation
Pre-filter pkgutil --files output through grep before bash processing, replace per-file subshell fork with inline case matching, add inner loop timeout. Reduces scan time from ~19s to ~2s on systems with many installed packages (e.g. Microsoft Office with 50K+ files per package). Related: tw93#798
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
pkgutil --filesoutput throughgrepbefore bash processing — eliminates 50K+ line buffers for large packages like Microsoft Office_mole_pkg_receipt_app_rootsubshell fork ($()) with inlinecasematching — removes ~50K fork/exec syscallsbreak 2so the 8s scan deadline is honored even during large file list processingPerformance
pkg_receipt_nonstandard_app_pathsMeasured on macOS arm64 with 39 non-Apple packages installed (including Microsoft Word 50K files, Excel 44K files, Powerpoint 33K files).
Context
Investigation into #798 (
mo uninstallappears to hang). This function runs before the scan spinner starts, so the user sees no feedback for its entire duration. On systems with many installed packages, this created a perceived hang of 10-20 seconds.This is a performance optimization, not necessarily the complete fix for #798. If the reported hang is an actual infinite stall (not just slow), further investigation is needed into
run_with_timeout/set -einteraction or terminal raw-mode issues.