Commit 7ad61f9
committed
Cache file names in fill_todo
Background:
While working with cargo, I've noticed that it takes ~30s to cargo clean -p with large enough target directory (~200GB).
With a profiler, it turned out that most of the time was spent retrieving paths for removal in https://github.com/rust-lang/cargo/blob/eee4ea2f5a5fa1ae184a44675315548ec932a15c/src/cargo/ops/cargo_clean.rs#L319 (and not actually removing the files).
Change description:
In call to .sort_by, we repetitively parse the paths to obtain file names for comparison. This commit caches file names in PathWrapper object, akin to #135 that did so for dir info.
For my use case, a cargo build using that branch takes ~14s to clean files instead of previous 30s (I've measured against main branch of this directory, to account for changes made since 0.3.1). Still not ideal, but hey, we're shaving 50% of time off for a bit heavier memory use.1 parent 49ee1e9 commit 7ad61f9
1 file changed
+23
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
| 334 | + | |
333 | 335 | | |
334 | 336 | | |
335 | 337 | | |
336 | | - | |
| 338 | + | |
337 | 339 | | |
338 | 340 | | |
339 | 341 | | |
| |||
348 | 350 | | |
349 | 351 | | |
350 | 352 | | |
351 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
352 | 358 | | |
353 | 359 | | |
354 | 360 | | |
355 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
356 | 367 | | |
357 | 368 | | |
358 | 369 | | |
| |||
927 | 938 | | |
928 | 939 | | |
929 | 940 | | |
930 | | - | |
931 | | - | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
932 | 945 | | |
933 | | - | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
934 | 949 | | |
935 | | - | |
| 950 | + | |
936 | 951 | | |
937 | 952 | | |
938 | 953 | | |
| |||
943 | 958 | | |
944 | 959 | | |
945 | 960 | | |
946 | | - | |
| 961 | + | |
947 | 962 | | |
948 | 963 | | |
949 | 964 | | |
| |||
0 commit comments