Skip to content

perf(reports): avoid plain JSON escape forks - #1374

Merged
Chemaclass merged 3 commits into
mainfrom
1369-json-escape
Oct 2, 2026
Merged

Chemaclass merged 3 commits into
mainfrom
1369-json-escape

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

Background

Closes #1369.

Writing JSON reports forks sed and tr for every filename, test name, and failure message, even for plain text. Escape ordinary values in the current shell and retain the existing control-character fallback.

Changes

  • Add a dedicated escape return slot and use it directly in the writer.
  • Keep the stdout escape helper for existing callers.
  • Cover empty values, quotes, backslashes, tabs, CR/LF, ANSI sequences, other control bytes, Unicode, and large strings against the existing behavior.
  • Add a process regression which detects stripping and tr calls for plain fields.

Performance

A sequential JSON report for 100 passing tests improved from 3,580 ms to 2,315 ms, a 35% reduction. Plain fields launch no stripping or tr process. Report schema and counters are unchanged.

Benchmarks use macOS arm64 and Bash 3.2.57, with medians of five alternating baseline and branch runs after one warm-up. The same external harness and fixtures run against main at 860c797a48e34be20b019a70f58c0e06d15c8d33. Timings stay out of normal tests.

Validation

make sa, make lint, Linux make test, macOS make test/parallel and make test/strict, and the full standalone-artifact suite on macOS pass. Parallel checks use four jobs. macOS full runs use TEST_SCRIPTS=tests/ to avoid the existing Bash 3.2 process-substitution descriptor limit.

The full source suite passes on GNU Bash 3.00.0 in sequential, parallel, simple, simple-parallel, and strict modes, using the same shell selection as CI. The standalone artifact also passes the focused provider, reporting, output, and fork regressions with Bash 3.0 first in PATH.

Checklist

  • I updated the CHANGELOG.md to reflect the new feature or fix.
  • Documentation does not need changes; the CLI and public API are unchanged.

@Chemaclass Chemaclass added the enhancement New feature or request label Oct 2, 2026
@Chemaclass Chemaclass self-assigned this Oct 2, 2026
@Chemaclass
Chemaclass merged commit f33a9ac into main Oct 2, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the 1369-json-escape branch October 2, 2026 13:08
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.

Avoid per-field processes when escaping plain JSON report values

1 participant