Hi dogstaters! 👋
Our website makes extensive use of dogstatsd-ruby to the point we had to optimise it for performance, and we'd like to discuss the possibility of upstreaming some of it.
During performance investigations, we found out that dogstatsd-ruby serialises metrics immediately whenever we make any metric calls, such as @dogstats.increment, and this behaviour has been increasing our app latency. To work around it, we created a wrapper object that intercept those metric calls and instead of performing them immediately, stores their arguments in an internal array and only makes the actual calls to dogstatsd-ruby after the HTTP response is sent, saving us ~20ms in latency.
Thus we'd like to propose a patch to make dogstatsd-ruby even more lightweight by delaying metric serialisation until flush time. For the multi-threaded case, serialisation would happen on the sender thread, and for the single-threaded case, it would still happen on the main thread, but only when flushing, which could be done after response.
What do you think?
✨ ✨ ✨
Hi dogstaters! 👋
Our website makes extensive use of dogstatsd-ruby to the point we had to optimise it for performance, and we'd like to discuss the possibility of upstreaming some of it.
During performance investigations, we found out that dogstatsd-ruby serialises metrics immediately whenever we make any metric calls, such as
@dogstats.increment, and this behaviour has been increasing our app latency. To work around it, we created a wrapper object that intercept those metric calls and instead of performing them immediately, stores their arguments in an internal array and only makes the actual calls to dogstatsd-ruby after the HTTP response is sent, saving us ~20ms in latency.Thus we'd like to propose a patch to make dogstatsd-ruby even more lightweight by delaying metric serialisation until flush time. For the multi-threaded case, serialisation would happen on the sender thread, and for the single-threaded case, it would still happen on the main thread, but only when flushing, which could be done after response.
What do you think?
✨ ✨ ✨