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

fix: sync map impl #1263

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: sync map impl #1263

wants to merge 1 commit into from

Conversation

piyushroshan
Copy link
Contributor

Thank you for contributing to Coraza WAF, your effort is greatly appreciated
Before submitting check if what you want to add to coraza list meets quality standards before sending pull request. Thanks!

Make sure that you've checked the boxes below before you submit PR:

Thanks for your contribution ❤️

@piyushroshan piyushroshan requested a review from a team as a code owner December 30, 2024 11:32
@piyushroshan
Copy link
Contributor Author

@fzipi Used loadOrStore for concurrentUpdates

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.69%. Comparing base (d5a0d6d) to head (cad794a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1263      +/-   ##
==========================================
- Coverage   81.69%   81.69%   -0.01%     
==========================================
  Files         169      169              
  Lines        9767     9766       -1     
==========================================
- Hits         7979     7978       -1     
  Misses       1537     1537              
  Partials      251      251              
Flag Coverage Δ
coraza.rule.case_sensitive_args_keys 81.65% <100.00%> (-0.01%) ⬇️
coraza.rule.multiphase_valuation 81.69% <100.00%> (-0.01%) ⬇️
coraza.rule.no_regex_multiline 81.63% <100.00%> (-0.01%) ⬇️
default 81.69% <100.00%> (-0.01%) ⬇️
examples+ 16.55% <0.00%> (+<0.01%) ⬆️
examples+coraza.rule.case_sensitive_args_keys 81.65% <100.00%> (-0.01%) ⬇️
examples+coraza.rule.multiphase_valuation 81.52% <100.00%> (-0.01%) ⬇️
examples+coraza.rule.no_regex_multiline 81.54% <100.00%> (-0.01%) ⬇️
examples+memoize_builders 81.64% <100.00%> (-0.01%) ⬇️
examples+no_fs_access 80.97% <100.00%> (-0.01%) ⬇️
ftw 81.69% <100.00%> (-0.01%) ⬇️
memoize_builders 81.78% <100.00%> (-0.01%) ⬇️
no_fs_access 81.13% <100.00%> (-0.01%) ⬇️
tinygo 81.65% <100.00%> (-0.01%) ⬇️

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.

@piyushroshan
Copy link
Contributor Author

Benchmarks: Current

go test -bench=. ./internal/corazawaf
goos: linux
goarch: amd64
pkg: github.com/corazawaf/coraza/v3/internal/corazawaf
cpu: xxx   
BenchmarkAddTransformationUnique-24      5506352               354.0 ns/op
BenchmarkAddTransformationSame-24       24820352               167.9 ns/op
BenchmarkTxGetField-24                   3960561               298.3 ns/op           400 B/op          8 allocs/op
BenchmarkTransactionCreation-24            82832             16021 ns/op
BenchmarkTransactionTimestamped-24      13426234                76.43 ns/op
BenchmarkMacro/%{tx.a}-24               34545536                37.93 ns/op
BenchmarkMacro/%{tx.a}_%{tx.b}-24       10972236               111.2 ns/op
BenchmarkMacro/goodbye_world-24         317328151                3.847 ns/op
PASS
ok      github.com/corazawaf/coraza/v3/internal/corazawaf       18.292s

Before sync map

go test -bench=. ./internal/corazawaf
goos: linux
goarch: amd64
pkg: github.com/corazawaf/coraza/v3/internal/corazawaf
cpu: xxx    
BenchmarkAddTransformationUnique-24       223730             80598 ns/op
BenchmarkAddTransformationSame-24       10833765               121.9 ns/op
BenchmarkTxGetField-24                   3806456               378.3 ns/op           400 B/op          8 allocs/op
BenchmarkTransactionCreation-24            94303             17960 ns/op
BenchmarkTransactionTimestamped-24      15407229                79.22 ns/op
BenchmarkMacro/%{tx.a}-24               29172850                36.42 ns/op
BenchmarkMacro/%{tx.a}_%{tx.b}-24       11480709               119.7 ns/op
BenchmarkMacro/goodbye_world-24         301710660                3.767 ns/op
PASS
ok      github.com/corazawaf/coraza/v3/internal/corazawaf       29.150s

@fzipi
Copy link
Member

fzipi commented Dec 30, 2024

Now I'm getting:

Current

❯ go test -bench=. ./internal/corazawaf
goos: darwin
goarch: amd64
pkg: github.com/corazawaf/coraza/v3/internal/corazawaf
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkAddTransformationUnique-16    	 3311302	       614.1 ns/op
BenchmarkAddTransformationSame-16      	19567063	       633.8 ns/op
BenchmarkTxGetField-16                 	 1000000	      1145 ns/op	     400 B/op	       8 allocs/op
BenchmarkTransactionCreation-16        	   48079	     25621 ns/op
BenchmarkTransactionTimestamped-16     	 4050920	       339.2 ns/op
BenchmarkMacro/%{tx.a}-16              	13499713	        89.01 ns/op
BenchmarkMacro/%{tx.a}_%{tx.b}-16      	 3840274	       341.4 ns/op
BenchmarkMacro/goodbye_world-16        	157292704	         7.671 ns/op
PASS
ok  	github.com/corazawaf/coraza/v3/internal/corazawaf	31.043s

Previous

❯ go test -bench=. ./internal/corazawaf
goos: darwin
goarch: amd64
pkg: github.com/corazawaf/coraza/v3/internal/corazawaf
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkTxGetField-16                	 1377608	       868.5 ns/op	     400 B/op	       8 allocs/op
BenchmarkTransactionCreation-16       	   36501	     32750 ns/op
BenchmarkTransactionTimestamped-16    	 4094943	       291.6 ns/op
BenchmarkMacro/%{tx.a}-16             	12492490	        94.61 ns/op
BenchmarkMacro/%{tx.a}_%{tx.b}-16     	 3729914	       318.2 ns/op
BenchmarkMacro/goodbye_world-16       	162130626	         7.388 ns/op
PASS
ok  	github.com/corazawaf/coraza/v3/internal/corazawaf	10.590s

@fzipi
Copy link
Member

fzipi commented Dec 30, 2024

I was lazy and just did checkout the last commit before the merge. Should I add the benchmarks only to the old commits?

@piyushroshan
Copy link
Contributor Author

piyushroshan commented Dec 30, 2024

Need to copy the two functions BenchmarkAddTransformationUnique and BenchmarkAddTransformationSame to old commit and run.
Also use before the sync.map merge commit id.

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