pfbufio, hotspot, php: introduce and use a pooled buffering reader#1393
Merged
Conversation
ffec8f2 to
de60f2f
Compare
…ader Introduce a new pooled buffering reader that can search strings from the stream. The buffered reader uses a io.ReaderAt along with an offset and size to limit the stream so its suitable to access ELF sections and segments without creating additional segment reader wrappers.
florianl
reviewed
May 4, 2026
christos68k
reviewed
May 6, 2026
| fn, ferr := r.source.ReadAt(p[n:n+int(toRead)], r.off) | ||
| r.off += int64(fn) | ||
| n += fn | ||
| return n, ferr |
Member
There was a problem hiding this comment.
Here too, we can in theory return io.EOF (ReadAt may return it with fn > 0). Not sure if this is currently a problem (hard to trace all callers).
Contributor
Author
There was a problem hiding this comment.
Here it is the correct thing to do. See https://pkg.go.dev/io#Reader
If EOF was encountered during Read it should return the EOF error. It can return nil also, but it is only required if there was no real error, and the short read was due to would block condition e.g. reading from socket where there was less data available immediately.
Since this portion is reading directly to target buffer. Return n > 0 and io.EOF here is the right thing to do.
Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
florianl
reviewed
May 15, 2026
christos68k
approved these changes
May 15, 2026
florianl
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce a new pooled buffering reader that can search strings from the stream. The buffered reader uses a io.ReaderAt along with an offset and size to limit the stream so its suitable to access ELF sections and segments without creating additional segment reader wrappers.
A step toward removing mmap as the code currently relies on having the full ELF section/segment available.