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 BuildBidderNameHashSet #4026

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

Conversation

linux019
Copy link
Contributor

Pprof identified big amount of allocations caused by each call to CoreBidderNames on each auction request
By storing result of CoreBidderNames into a single variable number of allocations reduced 4x

go test -benchmem -v -bench=Bench ./openrtb_ext/. |prettybench

Before:

BenchmarkBuildBidderNameHashSet
PASS
benchmark                             iter      time/iter   bytes alloc         allocs
---------                             ----      ---------   -----------         ------
BenchmarkBuildBidderNameHashSet-18   50244    22.66 μs/op    21333 B/op   12 allocs/op
ok      github.com/prebid/prebid-server/v2/openrtb_ext  1.415s

After:

BenchmarkBuildBidderNameHashSet
PASS
benchmark                              iter       time/iter   bytes alloc        allocs
---------                              ----       ---------   -----------        ------
BenchmarkBuildBidderNameHashSet-18   152774   7813.00 ns/op    10312 B/op   3 allocs/op
ok      github.com/prebid/prebid-server/v2/openrtb_ext  1.309s

@SyntaxNode
Copy link
Contributor

SyntaxNode commented Oct 30, 2024

The coreBidderNames slice can be altered by calls to SetAliasBidderName during startup. Could you please confirm all calls to the optimized BuildBidderNameHashSet occur after any potenital call to SetAliasBidderName ?

.. or to be safe, is it possible for SetAliasBidderName to reset the state of the optimized builder?

@linux019
Copy link
Contributor Author

main() calls LoadBidderInfoFromDisk

bidderInfos, err := config.LoadBidderInfoFromDisk(bidderInfoPath)

Next is creates a HTTP server where a call to auction endpoint triggers BuildBidderNameHashSet
Yes if new changes will call SetAliasBidderName this cached set needs to be rebuilt.

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