Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANSI parser speedup #3237

Merged
merged 2 commits into from
Mar 16, 2025
Merged

ANSI parser speedup #3237

merged 2 commits into from
Mar 16, 2025

Conversation

DrJosh9000
Copy link
Contributor

Description

Significant speed savings:

❯ benchstat ansi-parser-{maps,arrays}.txt
goos: darwin
goarch: arm64
pkg: github.com/buildkite/agent/v3/process
cpu: Apple M1 Max
              │ ansi-parser-maps.txt │       ansi-parser-arrays.txt        │
              │        sec/op        │   sec/op     vs base                │
ANSIParser-10           2322.3µ ± 0%   565.3µ ± 1%  -75.66% (p=0.000 n=30)

Context

The secret redactor was sped up a bit by switching away from a map, and I remembered this used maps too.

Changes

  • Add a benchmark
  • Rename feed to Write in case we want to e.g. io.Copy or MultiWriter into it
  • Use [256]*ansiParserState instead of map[byte]ansiParserState

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go fmt ./...)

@DrJosh9000 DrJosh9000 changed the title Ansi parser speedup ANSI parser speedup Mar 13, 2025
Copy link
Member

@pda pda left a comment

Choose a reason for hiding this comment

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

Nice!

@DrJosh9000 DrJosh9000 merged commit 16173e8 into main Mar 16, 2025
1 check passed
@DrJosh9000 DrJosh9000 deleted the ansi-parser-speedup branch March 16, 2025 23:00
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.

2 participants