-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
manifold-scheduler-pool can be a bottleneck on higher loads #479
Comments
I've been looking into Netty does not use this timer internally tho', it turns out that in practice it's better to leverage the same tasks queue that's used for all I/O tasks. I think that it would be a decent improvement to move connection/request etc timeouts to Netty's executor. The same way it's done for WebSocket handshake timeout handling, here. The harder part is testing & benchmarking. If you're volunteering to measure performance improvements on 100k+/sec, - I'm more than glad to help with the implementation. Regarding Manifold itself, I assume that the scheduler there aims to be a general purpose scheduler. It's hard to make a general purpose implementation that works well in I/O bounded context, tailored solution might be ar order of magnitude better. So, I would say that "better peformance for Aleph timeouts" and "better Manifold scheduler" are 2 separate tasks. Having a scheduler with a single thread to execute callbacks might be tough not only from performance/thoughtput point of view, one of the problems we've spotted a while ago in our projects. |
I would propose to put the content of this issue on a cljdoc article. |
What are you thinking? Something to implement for people who need faster timers? |
Yes, something along those lines.
|
Feel free to mark this as a minor issue, and I don't have a generic solution right now, just throwing around some ideas.
manifold-scheduler-pool that is used whenever
manifold.time/in
is used (and transitively for allmanifold.deferred/timeout!
) is based on Java'sScheduledThreadPoolExecutor
. That executor uses blocking queues and is not terribly efficient when facing 100k+/sec scheduling rate and grows a sizeable tail in the queue. Aleph is quite trigger-happy about creating timeouts, especially when you use a client and set:pool-timeout
,:connection-timeout
, and the other similar parameters.The immediate solution I came up with is replacing the default scheduler with Netty's HashedTimerWheel, which uses JCTools' lockless MPSC queue under the hood. No extra dependencies are needed since Netty is already there; however, this approach cannot be blindly applied to Manifold itself as people might use it without Aleph (and Netty). Perhaps, we could detect on pool initialization whether Netty is present and create a more efficient executor then? I don't know.
Anyway, here's a hack for those who might run into a similar problem:
The text was updated successfully, but these errors were encountered: