Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves directory size computation performance by switching from a synchronous, recursive approach to an async, chunked method using concurrency.
- Replace calculate_size with SizeCalculator::total for asynchronous, cancelable directory size calculations.
- Introduce a new calculator module with chunking logic.
- Update logging messages and module imports accordingly.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| yazi-scheduler/src/prework/prework.rs | Replaced calculate_size with SizeCalculator::total and updated imports. |
| yazi-scheduler/src/file/file.rs | Updated file operations to use SizeCalculator::total and improved log formatting. |
| yazi-fs/src/lib.rs | Added the calculator module to the module flattening. |
| yazi-fs/src/fns.rs | Removed the deprecated calculate_size function. |
| yazi-fs/src/calculator.rs | Introduced a new async chunked directory size calculation mechanism. |
| yazi-config/src/keymap/key.rs | Modified string interpolation in the Display implementation for Key. |
Comments suppressed due to low confidence (2)
yazi-scheduler/src/prework/prework.rs:76
- Ensure that propagating errors using the '?' operator here is intended and that upstream error handling can appropriately manage errors from SizeCalculator::total.
let length = SizeCalculator::total(&task.target).await?;
yazi-scheduler/src/file/file.rs:321
- Verify that the direct error propagation using '?' aligns with the desired behavior for file trash operations, and consider handling errors more explicitly if needed.
task.length = SizeCalculator::total(&task.target).await?;
This was referenced Apr 28, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR greatly improves directory computation performance by dividing the task into chunks and reusing existing threads. Directory sorting and file trashing will be observably twice as fast.
By leveraging chunking, it now can produce real-time directory statistics reports. This means that for a large directory, you will be able to see the process of size changes in real-time, which is beneficial for the upcoming
fs.calc_size()API.The new implementation is still async cancelable, which is important for using
fs.calc_size()in spotters, as it will allow canceling a still-incomplete directory computation when quickly switching between files, thereby avoiding wasted resources.Benchmark
Run the benchmark script against a 10.16GB folder 5 times in release mode: