Skip to content

perf(uninstall): optimize pkg receipt scan (#798)#799

Merged
tw93 merged 1 commit intotw93:mainfrom
xronocode:fix/pkg-receipt-scan-perf
Apr 27, 2026
Merged

perf(uninstall): optimize pkg receipt scan (#798)#799
tw93 merged 1 commit intotw93:mainfrom
xronocode:fix/pkg-receipt-scan-perf

Conversation

@xronocode
Copy link
Copy Markdown
Contributor

Summary

  • Pre-filter pkgutil --files output through grep before bash processing — eliminates 50K+ line buffers for large packages like Microsoft Office
  • Replace per-file _mole_pkg_receipt_app_root subshell fork ($()) with inline case matching — removes ~50K fork/exec syscalls
  • Add inner loop timeout check with break 2 so the 8s scan deadline is honored even during large file list processing

Performance

Metric Before After
pkg_receipt_nonstandard_app_paths ~19s ~2s

Measured 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 uninstall appears 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 -e interaction or terminal raw-mode issues.

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
@xronocode xronocode requested a review from tw93 as a code owner April 26, 2026 17:03
@tw93 tw93 merged commit 946dd26 into tw93:main Apr 27, 2026
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