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: Improve Performance, reduce heap allocations #1202

Merged
merged 20 commits into from
Nov 15, 2024

Conversation

soujanyanmbri
Copy link
Contributor

@soujanyanmbri soujanyanmbri commented Nov 7, 2024

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 ❤️

Before:

BenchmarkTxSetGet/Set-10         	26881494	        42.25 ns/op	      32 B/op	       1 allocs/op
BenchmarkTxSetGet/Get-10         	15812412	        76.35 ns/op	      48 B/op	       2 allocs/op

After:

BenchmarkTxSetGet/Set-10         	66049288	        18.02 ns/op	       0 B/op	       0 allocs/op
BenchmarkTxSetGet/Get-10         	25339977	        47.31 ns/op	      16 B/op	       1 allocs/op

@soujanyanmbri soujanyanmbri requested a review from a team as a code owner November 7, 2024 03:43
@soujanyanmbri soujanyanmbri changed the title Reduce heap allocation Reduce heap allocations Nov 7, 2024
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.48%. Comparing base (4ff1f76) to head (5016c9e).
Report is 129 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1202      +/-   ##
==========================================
+ Coverage   82.72%   83.48%   +0.76%     
==========================================
  Files         162      166       +4     
  Lines        9080     9621     +541     
==========================================
+ Hits         7511     8032     +521     
- Misses       1319     1338      +19     
- Partials      250      251       +1     
Flag Coverage Δ
default 83.48% <100.00%> (+5.64%) ⬆️
examples ?
ftw ?
ftw-multiphase ?
tinygo ?

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.

@soujanyanmbri soujanyanmbri changed the title Reduce heap allocations Perf: Improve Performance, reduce heap allocations Nov 7, 2024
@jcchavezs
Copy link
Member

also please post the results of the benchmarks

@soujanyanmbri
Copy link
Contributor Author

Before: 
BenchmarkTxSetGet/Set-10         	26881494	        42.25 ns/op	      32 B/op	       1 allocs/op
BenchmarkTxSetGet/Get-10         	15812412	        76.35 ns/op	      48 B/op	       2 allocs/op
After: 
BenchmarkTxSetGet/Set-10         	66049288	        18.02 ns/op	       0 B/op	       0 allocs/op
BenchmarkTxSetGet/Get-10         	25339977	        47.31 ns/op	      16 B/op	       1 allocs/op

This is after using the slice reuse
CC: @jcchavezs

Copy link
Member

@M4tteoP M4tteoP left a comment

Choose a reason for hiding this comment

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

Let's wait for @jcchavezs final approval, but LGTM, thanks!
Posting some more before/after benchmarks
Before:

BenchmarkCRSSimplePOST-10    	     872	   1312620 ns/op	  317136 B/op	    6415 allocs/op
BenchmarkCRSLargePOST-10    	      12	  97123340 ns/op	 1694983 B/op	    6646 allocs/op

After:

BenchmarkCRSSimplePOST-10    	     865	   1331177 ns/op	  316196 B/op	    6374 allocs/op
BenchmarkCRSLargePOST-10    	      12	  99717045 ns/op	 1492402 B/op	    6553 allocs/op

@soujanyanmbri soujanyanmbri requested a review from M4tteoP November 8, 2024 01:03
@jptosso
Copy link
Member

jptosso commented Nov 8, 2024

lgtm

@jcchavezs jcchavezs merged commit bbadbb6 into corazawaf:main Nov 15, 2024
8 checks passed
@jcchavezs
Copy link
Member

Thanks @soujanyanmbri !

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.

4 participants