Shopify / statsd-instrument

A StatsD client for Ruby apps. Provides metaprogramming methods to inject StatsD instrumentation into your code.
http://shopify.github.io/statsd-instrument
MIT License
574 stars 97 forks source link

Optimize DatagramBuilder #358

Closed casperisfine closed 1 year ago

casperisfine commented 1 year ago

Fix: https://github.com/Shopify/statsd-instrument/issues/357

Pull various tricks such as inlining, minimizing allocations etc.

$ ruby --yjit benchmark/send-metrics-to-dev-null-log
Warming up --------------------------------------
StatsD metrics to /dev/null log (branch: optimize-datagram-builder-2, sha: 9d5d918)
                        18.068k i/100ms
Calculating -------------------------------------
StatsD metrics to /dev/null log (branch: optimize-datagram-builder-2, sha: 9d5d918)
                        179.351k (± 3.1%) i/s -    903.400k in   5.041855s

Comparison:
StatsD metrics to /dev/null log (branch: optimize-datagram-builder-2, sha: 9d5d918):   179351.3 i/s
StatsD metrics to /dev/null log (branch: main, sha: e39f8ec):   156222.9 i/s - 1.15x  slower