Cache filename for sorting in fill_todo#181
Conversation
27ece42 to
79928b0
Compare
| // filename from `DirEntry` here, we store it proactively (we still | ||
| // have to heap allocate it). |
There was a problem hiding this comment.
"still"? afaict this adds an allocation. So it's surprising that allocating an extra OsString is still cheaper than getting the filename from the path later.
If you keep the whole DirEntry you could call file_name_ref on cfg(unix) to avoid that allocation too.
There was a problem hiding this comment.
It is a bit surprising, but the benchmark is quite clear on the results. It's one allocation vs potentially tens/hundreds/thousands of iterations of components, which seemingly isn't cheap, perf.-wise.
file_name_ref is unstable, as far as I can see?
There was a problem hiding this comment.
file_name_ref is unstable, as far as I can see?
Right, too bad.
Regarding the overhead, maybe wait until my rust PR lands and then benchmark again? The file_name optimization looks like it just might give us that 20% speedup too.
There was a problem hiding this comment.
Fair enough, once it gets into nightly, I'll benchmark it against a previous nightly to see if there's a big difference.
|
With rust-lang/rust#148084 landed:
Still seems worth landing (~600ms vs ~730ms). |
|
Are those results comparable to the previous ones, i.e. did we get a speedup from the path changes and this PR will provide additional ones on top? |
|
This should be the difference with/without your PR with 0.3.3 of glob: It looks like your changes helped, but this PR provides an additional improvement of around 10-15%. |
|
Thanks, it helps arguing the compile time impact. Also not as big as it looked from micro-benchmarks, but so it goes. |
7d385ab to
5b4c530
Compare
Alternative to #144.
This reduces the duration to glob
**/*.rsin a rustc checkout on my PC from ~1000ms to ~820ms: