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

Optimize request signing #2

Closed
wants to merge 6 commits into from

Conversation

dbemiller
Copy link
Contributor

@dbemiller dbemiller commented Sep 18, 2017

Minimizes new allocations inside the request signature. Consider this a work in progress... I'm just chipping away at it whenever I find myself waiting for someone.

This was based on Sweeney's advice that we use sync.Pool to ease garbage collector pressure. The primary goal is minimizing allocations per request... but that usually corresponds to faster speed improvements too.

Benchmark before changes:

Number of mallocs: 30

dbemiller-mac:azure dbemiller$ go test -bench=.
BenchmarkSignature-8   	  300000	      4275 ns/op
PASS
ok  	github.com/Prebid-org/prebid-cache/azure	1.345s
dbemiller-mac:azure dbemiller$ go test -bench=.
BenchmarkSignature-8   	  300000	      4247 ns/op
PASS
ok  	github.com/Prebid-org/prebid-cache/azure	1.335s
dbemiller-mac:azure dbemiller$ go test -bench=.
BenchmarkSignature-8   	  300000	      4366 ns/op
PASS
ok  	github.com/Prebid-org/prebid-cache/azure	1.373s

Benchmark after changes:

Number of mallocs: 19

dbemiller-mac:azure dbemiller$ go test -bench=.                      
BenchmarkSignature-8   	  500000	      2953 ns/op
PASS
ok  	github.com/Prebid-org/prebid-cache/azure	1.522s
dbemiller-mac:azure dbemiller$ go test -bench=.                    
BenchmarkSignature-8   	  500000	      2938 ns/op
PASS
ok  	github.com/Prebid-org/prebid-cache/azure	1.513s
dbemiller-mac:azure dbemiller$ go test -bench=.                       
BenchmarkSignature-8   	  500000	      2951 ns/op
PASS
ok  	github.com/Prebid-org/prebid-cache/azure	1.519s

@dbemiller dbemiller closed this Oct 4, 2017
@dbemiller dbemiller deleted the optimize-request-signing branch May 30, 2018 15:44
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.

1 participant