Skip to content

Read the Linux counter with read(2), not pread(2) - #9

Open
thomasklemm wants to merge 1 commit into
sferik:mainfrom
thomasklemm:pread-perf-fd
Open

thomasklemm wants to merge 1 commit into
sferik:mainfrom
thomasklemm:pread-perf-fd

Conversation

@thomasklemm

Copy link
Copy Markdown

When Linux can open the instruction counter, Duel's default instruction metric raises Errno::ESPIPE: Illegal seek because pread(2) cannot read the non-seekable perf fd. This reproduces on GitHub's ARM runners and AWS-backed x86 runners when counter access is enabled.

Use IO#sysread(8) to read the current count without Ruby's IO buffering. The test fake is now a pipe, so the existing count assertions catch positional reads without requiring hardware counters.

perf_event_open(2) returns a non-seekable descriptor, so pread(2)
raises ESPIPE whenever Linux can open the instruction counter. Use
sysread to read the current count without Ruby's IO buffering.

Use a pipe for the fake counter so the tests catch positional reads.

This branch has not been deployed

No deployments
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.

1 participant