searcher: fix regression with `--line-buffered` flag
Before adoption: this commit came in with the history the project adopted, so no landing records it.
In my fix for #3184, I actually had two fixes. One was a tweak to how we read data and the other was a tweak to how we determined how much of the buffer we needed to keep around. It turns out that fixing #3184 only required the latter fix, found in commit d4b77a8d8967ce1bf701ec65ceb9a75e85e5f2e0. The former fix also helped the specific case of #3184, but it ended up regressing `--line-buffered`. Specifically, previous to 8c6595c215d1e24bed5b7b86e2b18f3c871439ef (the first fix), we would do one `read` syscall. This call might not fill our caller provided buffer. And in particular, `stdin` seemed to fill fewer bytes than reading from a file. So the "fix" was to put `read` in a loop and keep calling it until the caller provided buffer was full or until the stream was exhausted. This helped alleviate #3184 by amortizing `read` syscalls better. But of course, in retrospect, this change is clearly contrary to how `--line-buffered` works. We specifically do _not_ want to wait around until the buffer is full. We want to read what we can, search it and move on. So this reverts the first fix but leaves the second, which still keeps #3184 fixed and also fixes #3194 (the regression). This reverts commit 8c6595c215d1e24bed5b7b86e2b18f3c871439ef. Fixes #3194
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+17 added−19 removed
- other:+17 added−19 removed