12 ms·
Game Programming Patterns: Event Queue (2014)
- wokwokwok 6y agoAn aggregate of the previous posts: https://news.ycombinator.com/item?id=23205511 https://news.ycombinator.com/item?id=23205511 This gets posted very often. ...it has some interesting content, to be fair, but I think there not much left to rehash again. It hasn’t changed since 2014.
- cableshaft 6y agoSeen the site before, but this is the first time I saw this particular topic linked, and it managed to highlight a solution to a problem I was having, which is how to handle a tutorial without putting a ton of hooks for a tutorial throughout the code, so I'm pretty grateful it was posted today.
- the_af 6y agoFor many of us, this is the first time we've seen it posted on HN.
- mindcrime 6y agoIt hasn’t changed since 2014. I'm pretty sure there are a lot of HN users today who weren't here in 2014.
- wokwokwok 6y agoffs. Read the link before you post. Posted in 2014, 2014, 2014, 2014, 2013, 2017, 2018, 2019, 2020. --> https://hn.algolia.com/?dateRange=all&page=0&prefix=false&query=gameprogrammingpatterns.com&sort=byDate&type=story https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu... Some kind of link from this gets posted every 2-3 months or so, since it came out. I appreciate you haven't seen it before... but.... this gets posted a lot here. The previous (635 point) thread was literally 3 months ago (https://news.ycombinator.com/item?id=23203699 https://news.ycombinator.com/item?id=23203699).
- prerok 6y agoWell, I've missed it. There are times I read HN on daily basis and times when I skip for weeks or even months, so I appreciate the reposting. Especially because it is an interesting read. There are a lot of articles being posted and so even if there were a feature "here is what you missed" I would not have used it :)
- aussieguy1234 6y agoIt's the first time I've seen it
- siscia 6y agoOne think that would make wonder is a company wide event queue. Just imagine all the things that it would be possible to make automatic if all the events that happens inside a business environment where in a queue. And don't even think about how it would be great if the same queue were open to outside providers.
- capableweb 6y agoSolid idea, worth thinking more about. A FIFO queue of tasks that anyone can grab from at any time. Main drawback is that each task would have to have a proper description, context and definition of done, otherwise it's bound to fail. Once you have those, any tool would do. But usually those three things are the hard part, not the tool/technology.
- janekm 6y agoI once had the idea for a global event queue, to enable new types of application interaction. Then twitter came out and I thought "oh well, that basically does what I was thinking of". Didn't quite turn out that way when they messed up the APIs, and then IFTTT did a better version of that concept...
- ojhughes 6y agoEnterprise Service Bus had this goal, and it mostly failed as a standard due to its complexity. Arguably, HATEOS has a similar goal by making APIs universally discoverable
- the_af 6y agoA similar concept lives on in the form of event streaming and pub/sub. I'm not sure how HATEOAS is related though? This is about publishing and subscribing to events (or streams of data), not about API discovery or "resources" as documents. Or did you mean something else?
- Galanwe 6y agoThat's called an ESB (enterprise software bus), a lot of companies have that, and there's a lot of softwares already on that space (IBM has quite a good market share there). Some companies do roll their own though, I've seen quite a few implementing ESBs on top of 0mq for instance. My previous company was doing trading and made the outgoing orders available on the ESB. It's was quite handy since all teams could subscribe to the trade topic and do their own processing: trade checks, accounting, risk, etc. It's a bit old school though, I mainly see old corporations with that architecture. The thing is, it ages quite badly most the time. Fast forward 5 years, and every single team is publishing stuff on the ESB "cause it's super easy to publish and consume data from the ESB". Before you know it, you have a full team dedicated to scaling and maintaining the monster.
- bob1029 6y agoIf 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.
- Const-me 6y agoGood article. I’d like to add that similar queues are widely used in all multimedia, not just games. This library https://github.com/Const-me/Vrmac/tree/master/VrmacVideo https://github.com/Const-me/Vrmac/tree/master/VrmacVideo uses queues to coordinate 3 threads, one decoding video by pumping V4L2 kernel queues, another one decoding audio and playing it with ALSA, and the main thread rendering frames with GLES. Two of my queues are thin wrappers around mq_send / mq_receive Linux APIs.
- phreack 6y agoThis is why I love game programming. You think that's what you're learning and then find out the same techniques are useful all over.
- nogabebop23 6y agonot to be overly pendantic but events and messages mean pretty different things and have different applications. Same thing with queues and buses. I suspect the author knows more about this than me but plays a little fast and loose in their explanations. I feel it's important to have disipline in our vocabulary so that people learning the material can participate in more advanced discussions as they grow. That said, I really appreciate the overall content and using the context of games for broadly applicable concepts is a great way to promote them (and funny as generally commercial games have some of the loosest "structure" of any code I've seen).
- mindcrime 6y agonot to be overly pendantic but events and messages mean pretty different things and have different applications. Same thing with queues and buses. I agree with what you say. But I'd add the suggestion that this depends on the context to some extent. For example, in the world of hardware and electrical circuits, a "bus" and a "queue" have almost no connection at all. But in the world of enterprise software, an "enterprise service bus" is often thought of as basically "a bunch of queues and a message router". Of course that's imprecise as well, since it ignores orchestration... which just goes to show even more how fuzzy some of these terms are in practice. I feel it's important to have disipline in our vocabulary so that people learning the material can participate in more advanced discussions as they grow. I generally agree, but I think this may be a case where "that ship has sailed." :-(
- billfruit 6y agoon a related topic, I have often wondered if studying Discrete System/Event Simulation help with game design and implementation? Does DES have some deep magical tricks or it is just plain commensense type of discipline?
- dbatten 6y agoReminds me of the excellent post about the architecture of multi-player in the original Age of Empires game: https://www.gamasutra.com/view/feature/131503/1500_archers_on_a_288_network_.php https://www.gamasutra.com/view/feature/131503/1500_archers_o... You had high-ping 28.8k internet, and you wanted to be able to have immersive battles in a world with hundreds of units controlled by several players. There's no way you could send real-time information about the status of every object in the game. So they didn't. They made the game simulation completely deterministic and then simply shipped user input around on the network. User input was processed on a slight (couple hundred milliseconds) delay (to allow for network transmission speeds) and executed simultaneously in "game time" on everybody's machine, so the simulation stayed in perfect sync. Voila, no worrying about lag.
- PaulStatezny 6y agoStarCraft 2, the modern "king of RTS games" so to speak, still uses that model! Determinism based on user input, plus a deliberate lag (~150ms?) in handling user input to allow time for player inputs to be received.
- AnotherGoodName 6y agoAnd the original Starcraft 1 was the pioneer of the technique fwiw. They even let you set the input delay in the options to account for lag.
- hinkley 6y agoAren't we saying that all of the popular 'Real Time Strategy" games are in fact turn-based, but there are 7 turns per second?
- MattRix 6y agoHah, nope. A delay of 150ms doesn't mean that events only happen every 150ms. Also even if events were sent in 150ms chunks, the offset of time within that chunk would still matter. With that said, most games do have a maximum tick rate, so in a very misleading way you could say they are turn-based ;)
- skapadia 6y agoOverall this is a great description of queues and why they are used.
- bionhoward 6y agoAnybody using the Actor Model for games these days?