5 ms·
If anyone is curious, one of the fastest multi-threaded queue implementations out there is the LMAX Disruptor. https://github.com/LMAX-Exchange/disruptor https
by bob1029 6y ago
If anyone is curious, one of the fastest multi-threaded queue implementations out there is the LMAX Disruptor.
https://github.com/LMAX-Exchange/disruptor https://github.com/LMAX-Exchange/disruptor
https://github.com/LMAX-Exchange/disruptor/wiki/Performance-Results https://github.com/LMAX-Exchange/disruptor/wiki/Performance-...
I've started using a variant of this in my .NET Core projects and have found the performance to be astonishing.
- pjmlp 6y agoJust curious, are you also making use of Span and Pipelines?
- exhaze 6y agoCan you give more context about your projects i.e. what makes them require a super high-performance queue?
- bob1029 6y agoThe type of project I am using this for is a centralized client/server UI architecture where 100% of user events are submitted to the queue for processing. This allows for very high throughput user interfaces if you are doing clever things on the server WRT caching of prior-generated content for other events (i.e. all login attempts for the same region will get the same final view). I found the abstraction this was originally developed for - processing of financial transactions with latency as the primary constraint - as an excellent analogue for UI event processing. Latency is also a huge concern when the user's eyeballs are in the loop.
- cma 6y agoAnd that use Java...
- dkersten 6y agoIf you control object pools yourself and don’t use GC, as the LMAX disrupted does as far as I remember, Java can be blazingly fast.
- cma 6y agoYou have to make sure all dependencies don't use GC as well right?
- dkersten 6y agoSure, but I'm assuming that if you're writing such high performance limited scope software like the LMAX disruptor, you have few dependencies (looking at their code, it appears that the disruptor code itself has no external dependencies and uses few of the standard library classes outside of NIO bytebuffers).
- MarkyC4 6y agoin LMAX-disruptor's case, they have no runtime dependencies: https://github.com/LMAX-Exchange/disruptor/blob/master/build.gradle#L55-L57 https://github.com/LMAX-Exchange/disruptor/blob/master/build...
- corysama 6y agoMartin Thompson has basically made a career out of writing Java in the style of embedded C because he found enterprise customers that need the performance of embedded C but, being enterprise, insist on absolutely everything being Java.
- afiori 6y agocalling external code from Java adds latency.
- SQueeeeeL 6y agoJonathan Blow warns against threaded queues in game development, as normally simulating your world isn't the bottleneck (rendering is) and it will just cause a fair bit of unexpected behavior/debugging
- Thaxll 6y agoIndeed, lot of games are actually single threaded.
- dkersten 6y agoIn recent years there has been a trend shift away from this, at least in the AAA engines, towards a job system. This makes sense: you have a thread per core and you create jobs to “go wide” when you can. See for example Unity’s Job system it’s the GDC talk by Naughty Dog from a few years ago. The big games will also prepare data for rendering in parallel (eg culling and sorting and whatnot, although much if this is also done on the GPU). (Going by GDC talks, the rendering teardown articles and just what I see online from Unity/Unreal. I don’t work in games myself)
- asdfasgasdgasdg 6y agoWhich makes total sense because single thread performance is growing more slowly these days. Used to be you'd double every couple of years but today the midrange is only about 50% faster single threaded than it was in '16. Now if you count all the cores you're still seeing things more than double over that time. Compare these similarly priced CPUs from today and a few years ago: i5-6500 and i5-10500. The latter is maybe 30-40% faster single threaded but has more than double the parallel throughput.
- Thaxll 6y agoIt's true but lot of the main area don't multi-thread well like AI and physics.
- asdfasgasdgasdg 6y ago
- jcelerier 6y agowould be nice to see updated benchmarks against the C++ queues - this LMAX queue seems to give 20-25 million messages per second on sandy bridge - the best 1P/1C C++ queue is around 250 million messages per second on a 9900K and I doubt a 9900K is 10 times more performant than a 2600K. > https://max0x7ba.github.io/atomic_queue/html/benchmarks.html https://max0x7ba.github.io/atomic_queue/html/benchmarks.html
- bob1029 6y agoI am more concerned about worst case latency than going into message rates measured in the billions per second. The load those events will generate far exceeds the load incurred by creating and processing them on the same physical host, so ill never be in a situation where 25 vs 250 million makes a difference. I am also interested in the productivity and safety afforded by high-level languages in this arena. Dealing with memory and threading at the same time is not something I like to do at a low-level.
- newobj 6y agoLMAX is optimizing latency, not throughput.
- griffiths 6y agoAre you using https://github.com/disruptor-net/Disruptor-net https://github.com/disruptor-net/Disruptor-net library port or something else?
- bob1029 6y agoThis is exactly what I am using.