-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: limit thread number to 1 when HDD is detected #269
Conversation
8fa1c14
to
80857ed
Compare
On HDD, multi-threaded du won't provide any performance benefit over the single-threaded one. Therefore, when HDD is detected on one of the files, limit the thread number to 1. This PR fixes issue #257.
80857ed
to
ca5b7a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. I have some requests and questions.
889da29
to
0ceed30
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to my request at #269 (comment), I also have more suggestions for improvement.
6b25983
to
42fee43
Compare
Co-authored-by: Khải <[email protected]>
dc077fd
to
f9d57b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before merging this, I need to try rewriting the dependency injections in the tests from passing functions to using a trait, like so:
pub trait Api {
type Disk: ?Sized;
fn get_disk_kind(&self, disk: &Self::Disk) -> DiskKind;
fn get_mount_point(&self, disk: &Self::Disk) -> &Path;
fn canonicalize(&self, path: &Path) -> io::Result<PathBuf>;
}
pub struct RealApi; // would implement real APIs
#[cfg(test)]
pub struct TestApi { /* ... */ } // would implement mocked APIs
Whilst I do not request you to implement this for me, you're welcomed to try if you are feeling generous enough. If you do not do it, then I will do this when I have free time.
However, while |
It's just an internal trait, not a user-facing public trait, so we don't need to make it modular. As for code simplicity, we are not passing any closures, we are passing a single instance of I feel that the names I chose are somewhat horrible though. If you have better names, feel free to use them. |
v0.11.0 has been released. |
On HDD, multi-threaded du won't provide any performance benefit over the single-threaded one. Therefore, when HDD is detected on one of the files, limit the thread number to 1.
Fixes #257