Open iRevive opened 4 days ago
Side note: If I'm not mistaken, all queues (unbound, bound, dropping, etc) are multi-producer/multi-consumer. If so, is there any plan to provide other specialized variants, such as multi-producer/single-consumer?
The dropping queue's normalized (per operation) allocation is 3x more than the bounded queue.
The bounded queue uses Async
to wrap an underlying unsafe queue, whereas the dropping queue is entirely implemented with Concurrent
via Ref
and immutable data structures. So some disparity is expected ...
If so, is there any plan to provide other specialized variants, such as multi-producer/single-consumer
This is an FS2 Channel
:)
The dropping queue's normalized (per operation) allocation is 3x more than the bounded queue.
The bounded queue uses
Async
to wrap an underlying unsafe queue, whereas the dropping queue is entirely implemented withConcurrent
viaRef
and immutable data structures. So some disparity is expected ...
So, the other way around is to implement async-variant, right?
I've been benchmarking otel4s BatchSpanProcessor.scala and noticed a heavy memory consumption.
One of the suspects is the dropping queue. Switching to
Queue.bounded
dropped memory usage by 30-40%.I added dropping queue to the benchmarks and run a few:
The dropping queue's normalized (per operation) allocation is 3x more than the bounded queue.
JFR data
Bounded queue:
Dropping queue:
Affected queues
The dropping queue is backed by the
AbstractQueue
. The circular buffer and bounded queue (concurrent-based variant) also useAbstractQueue
, so they should show heavy-memory usage symptoms, too.