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

perf: GetField reduce allocations #1195

Merged
merged 1 commit into from
Nov 5, 2024
Merged

Conversation

M4tteoP
Copy link
Member

@M4tteoP M4tteoP commented Nov 5, 2024

One less alloc/op, but numbers can matter at scale.

Before:

goos: darwin
goarch: arm64
pkg: github.com/corazawaf/coraza/v3/internal/corazawaf
cpu: Apple M1 Pro
BenchmarkTxGetField-10    	 2294287	       582.5 ns/op	     448 B/op	       9 allocs/op
PASS
ok  	github.com/corazawaf/coraza/v3/internal/corazawaf	2.374s

BenchmarkCRSSimplePOST-10    	     902	   1276337 ns/op	  338771 B/op	    7220 allocs/op
PASS
ok  	github.com/corazawaf/coraza/v3/testing/coreruleset	2.054s

After:

goos: darwin
goarch: arm64
pkg: github.com/corazawaf/coraza/v3/internal/corazawaf
cpu: Apple M1 Pro
BenchmarkTxGetField-10    	 3306369	       355.6 ns/op	     400 B/op	       8 allocs/op
PASS
ok  	github.com/corazawaf/coraza/v3/internal/corazawaf	2.051s

BenchmarkCRSSimplePOST-10    	     874	   1262635 ns/op	  320807 B/op	    6418 allocs/op
PASS
ok  	github.com/corazawaf/coraza/v3/testing/coreruleset	2.034s

@M4tteoP M4tteoP requested a review from a team as a code owner November 5, 2024 12:00
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.46%. Comparing base (4ff1f76) to head (f0e9fec).
Report is 115 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1195      +/-   ##
==========================================
+ Coverage   82.72%   83.46%   +0.74%     
==========================================
  Files         162      166       +4     
  Lines        9080     9611     +531     
==========================================
+ Hits         7511     8022     +511     
- Misses       1319     1338      +19     
- Partials      250      251       +1     
Flag Coverage Δ
default 83.46% <100.00%> (+5.62%) ⬆️
examples 83.46% <100.00%> (+57.03%) ⬆️
ftw 83.46% <100.00%> (+36.09%) ⬆️
ftw-multiphase 83.46% <100.00%> (+33.92%) ⬆️
tinygo 83.46% <100.00%> (+8.06%) ⬆️

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.

@M4tteoP M4tteoP changed the title GetField reduce allocations perf: GetField reduce allocations Nov 5, 2024
@fzipi fzipi merged commit de409e3 into corazawaf:main Nov 5, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants