KEMBAR78
optimize performance of regex operations by bobcallaway · Pull Request #2603 · sigstore/rekor · GitHub
Skip to content

Conversation

bobcallaway
Copy link
Member

profiling Rekor yielded that we were doing a lot of regex allocations in the hot path; this change optimizes those down with pretty big results:

goos: darwin
goarch: arm64
pkg: github.com/sigstore/rekor/pkg/types/hashedrekord/v0.0.1
cpu: Apple M4 Pro
BenchmarkHashValidation/Old/SHA256-14             171613              5854 ns/op           18185 B/op        173 allocs/op
BenchmarkHashValidation/New/SHA256-14           36960652                31.70 ns/op           32 B/op          1 allocs/op
BenchmarkHashValidation/Old/SHA384-14             143301              9013 ns/op           29637 B/op        239 allocs/op
BenchmarkHashValidation/New/SHA384-14           29359563                41.33 ns/op           48 B/op          1 allocs/op
BenchmarkHashValidation/Old/SHA512-14             113379             10810 ns/op           34810 B/op        303 allocs/op
BenchmarkHashValidation/New/SHA512-14           22802001                51.42 ns/op           64 B/op          1 allocs/op
PASS
ok      github.com/sigstore/rekor/pkg/types/hashedrekord/v0.0.1 7.834s

Signed-off-by: Bob Callaway <bcallaway@google.com>
Signed-off-by: Bob Callaway <bcallaway@google.com>
@bobcallaway bobcallaway requested a review from a team as a code owner September 2, 2025 15:23
@codecov
Copy link

codecov bot commented Sep 2, 2025

Codecov Report

❌ Patch coverage is 24.13793% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 24.99%. Comparing base (488eb97) to head (e6362df).
⚠️ Report is 507 commits behind head on main.

Files with missing lines Patch % Lines
pkg/types/hashedrekord/v0.0.1/entry.go 33.33% 4 Missing and 2 partials ⚠️
pkg/types/alpine/v0.0.1/entry.go 20.00% 2 Missing and 2 partials ⚠️
pkg/types/jar/v0.0.1/entry.go 20.00% 2 Missing and 2 partials ⚠️
pkg/types/rekord/v0.0.1/entry.go 20.00% 2 Missing and 2 partials ⚠️
pkg/types/rpm/v0.0.1/entry.go 20.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2603       +/-   ##
===========================================
- Coverage   66.46%   24.99%   -41.47%     
===========================================
  Files          92      190       +98     
  Lines        9258    24548    +15290     
===========================================
- Hits         6153     6135       -18     
- Misses       2359    17622    +15263     
- Partials      746      791       +45     
Flag Coverage Δ
e2etests 46.60% <13.79%> (-0.96%) ⬇️
unittests 15.87% <24.13%> (-31.81%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bobcallaway bobcallaway enabled auto-merge (squash) September 2, 2025 15:38
@bobcallaway bobcallaway merged commit 5239bdb into sigstore:main Sep 2, 2025
16 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.

2 participants