Skip to content

Performance improvements#164

Merged
ogaca-dd merged 11 commits intomasterfrom
olivierg/improvePerformance
Aug 5, 2021
Merged

Performance improvements#164
ogaca-dd merged 11 commits intomasterfrom
olivierg/improvePerformance

Conversation

@ogaca-dd
Copy link
Copy Markdown
Contributor

This PR adds several performance improvements:

  • MetricSerializer: Improve double serialization by ~15%.
  • Improve the performance of BufferBuilder.Add by ~30%
  • Improve the performance of MetricSerializer by 110%
  • Simplify the code and improve the performance by ~15%

The overall improvement is ~ 70%.

Reviewing commit by commit is recommended.

This PR must be merged after #163.

Comment thread src/StatsdClient/Worker/ConcurrentQueueWithPool.cs Outdated
Base automatically changed from olivierg/BenchmarkDotNet to master June 21, 2021 11:30
@ogaca-dd ogaca-dd requested a review from truthbk July 29, 2021 08:41
Copy link
Copy Markdown
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

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

Looks good to me, just a couple of nits and a question.

I have a small difference of opinion with regard to ConcurrentQueueWithPool, not because the code therein doesn't make sense, it makes total sense, but because I think we have a class there that is doing two different things: pool and queue. We've already spoken about how these might make sense to be used together in a few scenarios, but I also feel it's initially a little misleading at a high-level (of course also something we could address with good docs). I definitely don't think we should change it here, just a thought of maybe something we might want to refactor in the future.

Nice stuff.

Comment thread src/StatsdClient/Worker/ConcurrentQueueWithPool.cs
Comment thread benchmarks/StatsdClient.Benchmarks/ServiceBenchmark.cs
Assert.True(queue.TryDequeueFromPool(out var v));
Assert.AreEqual(42, v);

Assert.False(queue.TryDequeueFromPool(out var _));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: a small comment here to explain how this call will return false and timeout because the task has not yet put 43 into the pool'd queue would be nice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have added a more detailed comment in the code.

@ogaca-dd
Copy link
Copy Markdown
Contributor Author

ogaca-dd commented Aug 5, 2021

@truthbk : I have added an implementation note for ConcurrentQueueWithPool.

@ogaca-dd ogaca-dd merged commit d8427c2 into master Aug 5, 2021
@ogaca-dd ogaca-dd deleted the olivierg/improvePerformance branch August 5, 2021 13:09
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.

3 participants