Skip to content

perf(runner): read failing-test body once for Source: context#807

Merged
Chemaclass merged 1 commit into
mainfrom
perf/failure-source-context-single-read
Jul 15, 2026
Merged

perf(runner): read failing-test body once for Source: context#807
Chemaclass merged 1 commit into
mainfrom
perf/failure-source-context-single-read

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Profiling a failing test surfaced quadratic fork behaviour: get_failure_source_context re-read the test file with a sed -n Np fork per line and a grep fork per line to find the function's closing brace, so the fork count grew with the function length.

💡 Changes

  • Read the function body in a single bash read loop and detect the closing brace by trimming whitespace — no per-line sed/grep forks (a 20-line body dropped from ~46 to ~2 forks).
  • Output is byte-identical; failure snapshots unchanged; regression test added. No behaviour change.

get_failure_source_context re-read the test file with a 'sed -n Np' fork for
every line of the function body and a 'grep' fork to detect the closing brace,
so fork count grew with function length (a 20-line body cost ~46 forks). Read
the body in a single bash 'read' loop and detect the closing brace by trimming
whitespace — no per-line forks (~46 -> ~2). Output is byte-identical (failure
snapshots unchanged).

No behaviour change.
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 15, 2026
@Chemaclass Chemaclass self-assigned this Jul 15, 2026
@Chemaclass Chemaclass merged commit 3c16995 into main Jul 15, 2026
37 checks passed
@Chemaclass Chemaclass deleted the perf/failure-source-context-single-read branch July 15, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant