Conversation
- Add a microbenchmark that reads many fixed-width lines from a temp file using readLine().
- readLine() previously performed a syscall per byte, which is slow for large line-oriented reads. - BM_ReadLineFile/10000_mean runs 4000x faster
|
Can we do this without a global variable? I would feel much better about that. |
I assume you mean Can you please explain why is that not preferred here? Hmmm... I see it's potentially risky, when several threads operate on the same fd (but that code pattern would be ugly in the first place). |
In general, I suspect that these FIXMEs are not all sources of "easy wins". There is a bit of a https://en.wikipedia.org/wiki/Survivorship_bias sometimes where a FIXME might look easy enough, but if it was so easy someone would have fixed it by now. (That is certainly not always the case though, just to be clear.) |
|
Because of 2 it seems like this FIXME is unrealistic. So it's an architectural issue. |
|
FWIW the local state approach can still work if it is opt-in. Then, just the call sites where the entire life cycle of reads is known so safety can be judged can use it. |
|
I think the correct way would be to refactor the usage to some standard interface (I don't know much of C++ abstractions) if one exists. That would allow for cached operations on the fd, with optional "unpacking" into raw fd. Not having a safe, clean fd abstraction prevents cache optimizations that could be then unified across all read operations. |
|
We have those. It's called FdSource. |
Motivation
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.