The buffer size if the default 5k, it means pop(nonblock) is called 5k times, but somehow it's not noticeably slower than a single pop(count: 5000) call, which I must say is surprising.
I profiled both, and SizedQueue#pop accounts for 0.31% and 0.08% of runtime respectively. So pop(count: 5000) is much faster as expected, but it doesn't matter much in this benchmark.
Most of the time is spent building the datagrams and sending the UDP packets
So even without pop(count:), the overhead of backgrounding sending the events has been pretty much been eliminated.
We should definitely use SizedQueue for Ruby 3.2+.
This is not meant to be merged.
thread condition
is the current batched sink usingMonitor
+Thread::ConditionVariable
.SizedQueue#pop(nonblock)
is doable using current Ruby3.2.0-dev
implementationSizedQueue#pop(count:)
uses https://github.com/ruby/ruby/pull/6257The buffer size if the default 5k, it means
pop(nonblock)
is called 5k times, but somehow it's not noticeably slower than a singlepop(count: 5000)
call, which I must say is surprising.I profiled both, and
SizedQueue#pop
accounts for0.31%
and0.08%
of runtime respectively. Sopop(count: 5000)
is much faster as expected, but it doesn't matter much in this benchmark.Most of the time is spent building the datagrams and sending the UDP packets
So even without
pop(count:)
, the overhead of backgrounding sending the events has been pretty much been eliminated.We should definitely use
SizedQueue
for Ruby 3.2+.