tail:Fix tail -f sparse file growth handling#12080
Conversation
|
GNU testsuite comparison: |
| return Ok(false); | ||
| }; | ||
|
|
||
| let result = (|| -> UResult<bool> { |
There was a problem hiding this comment.
make this a named function?
There was a problem hiding this comment.
I'm not even sure there was a need for that in the first place... this is a weird JS idiom that popped up after I noped out of there. The new added function looks fine tho.
Merging this PR will degrade performance by 3.11%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | du_max_depth_balanced_tree[(6, 4, 10)] |
25 ms | 25.8 ms | -3.11% |
Comparing mattsu2020:tail_12015 (628aee0) with main (45a48a1)
Footnotes
-
46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Co-authored-by: xtqqczze <45661989+xtqqczze@users.noreply.github.com>
Summary
Fixes tail -f behavior when a followed sparse file grows by a very large amount, such as via truncate -s 1P.
The follow path previously used BytesChunkBuffer::new(u64::MAX), which consumed all newly readable bytes into memory before printing. For sparse file holes, those bytes are read as NULs, so a large logical size increase could cause tail to consume excessive memory and get killed.
This changes follow-mode output to read one chunk to detect whether new data exists and preserve header behavior, then stream the remaining data directly to stdout with io::copy.
Fixes #12015.
Validation