Merged
Conversation
rejectBySize was calling fs.DirSize() for every file in trash, recursively walking directories. Since trash.File.Size is already populated during List() via os.Stat, use GetSize() from the Filterable interface instead. Falls back to DirSize only when size is unknown (0), which only happens for legacy history files. Also adds early return when both Size.Min and Size.Max are empty.
Title() and Description() were calling os.Stat() on every render of every visible list item. Since File.IsDir and File.Size are already populated during List(), use those cached values instead. Also remove the duplicate existence check in loadFileListCmd — files are already filtered by cli.filterFiles() before reaching the UI layer.
When multiple storage backends are configured (e.g., XDG + Legacy in auto strategy), List() now queries them concurrently using goroutines instead of sequentially. Results are collected via a buffered channel.
Contributor
Code Metrics Report
Details | | main (a73fb08) | #123 (97d3922) | +/- |
|---------------------|----------------|----------------|-------|
+ | Coverage | 42.2% | 42.6% | +0.3% |
| Files | 24 | 24 | 0 |
| Lines | 1835 | 1840 | +5 |
+ | Covered | 776 | 784 | +8 |
- | Code to Test Ratio | 1:1.5 | 1:1.5 | -0.1 |
| Code | 2720 | 2739 | +19 |
- | Test | 4238 | 4216 | -22 |
| Test Execution Time | 3s | 3s | 0s |Code coverage of files in pull request scope (38.3% → 38.9%)
Reported by octocov |
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.
WHAT
Eliminate redundant filesystem syscalls in the
gomi -brestore flow by using cached file metadata, removing duplicate existence checks, and parallelizing storage listing.WHY
Profiling showed
gomi -bspent 85% of CPU time in syscalls (system 0.47sof0.55stotal CPU). Three sources of waste were identified:rejectBySizecalledfs.DirSize()for every file — recursively walking directories to compute sizes, even thoughFile.Sizewas already populated duringList()viaos.Stat(). The default config setsMax: "10GB", so this ran on every invocation.Title()andDescription()calledos.Stat()on every render — BubbleTea re-renders visible items on each frame, causing V×2 stat calls per frame.File.IsDirfrom the initial List was sufficient.loadFileListCmdre-checked file existence —os.Stat()on every file, duplicating the check already done bycli.filterFiles().Storage backends listed sequentially — XDG and Legacy
List()calls ran one after another instead of concurrently.This PR also includes prior refactoring commits (design improvements from Phases 1-3).