-
Notifications
You must be signed in to change notification settings - Fork 816
Optimise ring.DoBatch() #1624
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
Optimise ring.DoBatch() #1624
Conversation
b1a830d
to
e365728
Compare
Nice set of optimisations! Sorry I've been so nit picky. Once small concern: we're now taking a (read) lock in a loop. Not super concerned about consistency (the ring might update mid processing a batch) but do you think this will impact CPU usage? |
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Trade-off is we do more lock/unlock operations. Signed-off-by: Bryan Boreham <[email protected]>
…-place Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
Signed-off-by: Bryan Boreham <[email protected]>
9ef6279
to
454b37a
Compare
The benchmarks show that CPU overall comes down. Profiling suggests that I have addressed review comments; PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I've given a shot at optimising this a little while ago but couldn't get any gains, this is a nice approach!
Signed-off-by: Bryan Boreham <[email protected]>
ring.DoBatch
contributes 20% of the memory allocation in my production distributors.I started looking at this and realised the existing benchmark was not exercising the functionality - the
cas()
didn't update the ring so it was actually empty, and some test fixture code was also quite far up the profile.Having fixed all that and made the benchmark call the higher-level function
DoBatch()
, the numbers before are:after:
The
ReadRing
function signatures have changed a bit, which may impact downstream projects using this code.