Skip to content

pfbufio, hotspot, php: introduce and use a pooled buffering reader#1393

Merged
christos68k merged 5 commits into
open-telemetry:mainfrom
fabled:tt-pfiobuf-search
May 19, 2026
Merged

pfbufio, hotspot, php: introduce and use a pooled buffering reader#1393
christos68k merged 5 commits into
open-telemetry:mainfrom
fabled:tt-pfiobuf-search

Conversation

@fabled
Copy link
Copy Markdown
Contributor

@fabled fabled commented May 4, 2026

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.

@fabled fabled force-pushed the tt-pfiobuf-search branch 3 times, most recently from ffec8f2 to de60f2f Compare May 4, 2026 12:58
…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.
@fabled fabled force-pushed the tt-pfiobuf-search branch from de60f2f to 62104b6 Compare May 4, 2026 13:16
@fabled fabled marked this pull request as ready for review May 4, 2026 13:22
@fabled fabled requested review from a team as code owners May 4, 2026 13:22
Comment thread interpreter/php/php.go Outdated
Comment thread libpf/pfbufio/reader.go Outdated
Comment thread libpf/pfbufio/reader.go
fn, ferr := r.source.ReadAt(p[n:n+int(toRead)], r.off)
r.off += int64(fn)
n += fn
return n, ferr
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@fabled fabled requested review from christos68k and florianl May 15, 2026 06:12
Comment thread libpf/pfbufio/reader.go
Comment thread libpf/pfbufio/reader.go Outdated
@fabled fabled requested a review from florianl May 18, 2026 07:49
@christos68k christos68k merged commit 2bbadfa into open-telemetry:main May 19, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants