frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

The Scalar Select Anti-Pattern

https://matklad.github.io/2025/05/14/scalar-select-aniti-pattern.html
47•goranmoomin•1y ago

Comments

castratikron•1y ago
As long as processing one event does not affect any of the other events in the batch. E.g. events are file IO, and processing one event causes another event's descriptor to get closed before that event can be processed.
wahern•1y ago
If the close routine on an event source, or the low-level (e.g. epoll) registration, deregistration, and dequeueing logic doesn't know how to keep polling and liveness state consistent between userspace and the kernel, they've got much bigger problems. This looks like Rust code so I would hope the event stream libraries are, e.g., keeping Rc'd file objects and properly managing reference integrity viz-a-viz kernel state before the application caller ever sees the first dequeued event in a cycle. This is a perennial issue with event loop libraries and buggy application code (in every language). One can't just deal with raw file descriptors, call the close syscall directly, etc, hoping to keep state consistent implicitly. There's an unavoidable tie-in needed between application's wrappers around low-level resources and the event loop in use.
taeric•1y ago
I'm not entirely clear on what the proposal is at the end? Seems that the long term answer as to "which of these implications to pursue" is "all of them?" Simply taking in a batch of instructions doesn't immediately change much? You still have to be able to do each of the other things. And you will still expect some dependencies between batches that could possibly interact in the same ways.

In a sense, this is no different than how your processor is dealing with instructions coming in. You will have some instructions that can be run without waiting on previous ones. You will have some that can complete quickly. You will have some that are stalled on other parts of the system. (I'm sure I could keep wording an instruction to match each of the implications.)

To that end, part of your program has to deal with taking off "whats next" and finding how to prepare that to pass to the execution portion of your program. You can make that only take in batches, but you are almost certainly responsible for how you chunk them moreso than whatever process is sending the instructions to you? Even if you are handed clear batches, it is incumbent on you to batch them as they go off to the rest of the system.

lmz•1y ago
I guess the proposal is "instead of fetching and acting on one event at a time, consider fetching all available events and look for opportunities to optimize which ones you process (e.g. by prioritization or by skipping certain events if superseded by newer ones)".
taeric•1y ago
I mean, I got that. But you could as easily say "instead of fetching and acting on one event at a time, fetch and triage/route instructions into applicable queues."

In particular, there is no guarantee that moving to batches changes any of the problems you may have from acting on a single one at a time. To that end, you will have to look into all of the other strategies sooner or later.

Following from that, the problem is not "processMessage" or whatever. The problem is that you haven't broken "processMessage" up into the constituent "receive/triage/process/resolve" loop that you almost certainly will have to end up with.

malkia•1y ago
in CPU's - pipelining!
jchw•1y ago
I believe something similar is going on internally in Windows with event queues. It coalesces and prioritizes input events when multiple of them pile up before you're able to pop new events off of the queue. (For some events, e.g. pointer events, you can even go and query frames that were coalesced during input handling.) On the application/API end, it just looks like a "scalar select" loop, but actually it is doing batching behavior for input events!

(On the flip side, if you have a Wayland client that falls behind on processing its event queue, it can crash. On the whole this isn't really that bad but if you have something sending a shit load of events it can cause very bad behavior. This has made me wonder if it's possible, with UNIX domain sockets, to implement some kind of event coalescing on the server-side, to avoid flooding the client with high-precision pointer movement events while it's falling behind. Maybe start coalescing when FIONREAD gets to some high watermark? No idea...)

What algorithm did Windows XP use to choose your initial user picture?

https://devblogs.microsoft.com/oldnewthing/20260909-00/?p=112683
81•soheilpro•2h ago•32 comments

Show HN: The same nine streaming subscriptions cost $702/year more than in 2021

https://honestlyranked.com/guides/streaming-price-increases/
58•honestlyranked•1h ago•45 comments

DeepSeek v4.1 Flash

https://twitter.com/deepseek_ai/status/2097930608790167907
445•Liwink•5h ago•226 comments

iPhone Duo

https://www.apple.com/iphone-duo/
1233•thecosmicfrog•17h ago•2162 comments

Stockfish 19

https://stockfishchess.org/blog/2026/stockfish-19/
65•atiedebee•2d ago•35 comments

Show HN: What if the speed of light was 5 km/h?

https://rivendell.dmitrybrant.com/relativity/
381•dmitrybrant•9h ago•157 comments

Larger Pacific Striped Octopus

https://en.wikipedia.org/wiki/Larger_Pacific_striped_octopus
78•olalonde•1d ago•41 comments

Shopify acquires Tailwind

https://tailwindcss.com/blog/tailwind-is-joining-shopify
1050•EdwinHoksberg•22h ago•405 comments

What do Visa and Mastercard do? An intro to card networks

https://tautology.town/2026/06/01/card-networks.html
554•evakhoury•1d ago•334 comments

Object storage is all you need

https://www.tigrisdata.com/blog/object-storage-all-need/
7•jpsaccount•1d ago•1 comments

Growing proof that autonomous cars save lives

https://spectrum.ieee.org/are-self-driving-cars-safe
360•bookofjoe•18h ago•629 comments

Show HN: Art – draw one stroke, let symmetry complete it

https://mrdee.in/mandala/
18•cyb0rg0•4d ago•6 comments

Mathematicians want proof OpenAI didn't use their work

https://www.theverge.com/ai-artificial-intelligence/993263/where-does-openai-get-mathematics-trai...
12•kevcampb•12m ago•0 comments

Thanks to Siri Recaps, your Apple Watch is always listening

https://www.techradar.com/health-fitness/smartwatches/thanks-to-siri-recaps-your-apple-watch-is-a...
15•geox•55m ago•1 comments

Samsung Debuts zHBM Prototype, Stacking Memory Directly on AI Accelerators

https://www.thelec.net/news/articleView.html?idxno=12835
29•peter_d_sherman•3d ago•4 comments

No Man's Sky Cosmos

https://www.nomanssky.com/cosmos-update/
403•Limb•19h ago•408 comments

GPT-6 Astra, looped transformers, and hidden reasoning

https://magazine.sebastianraschka.com/p/gpt-6-astra-looped-transformers-and
447•ModelForge•20h ago•143 comments

PlayStation cancels Kojima's PHYSINT, Xbox steps in

https://twitter.com/hideo_kojima_en/status/2097877506401681753
19•HatchedLake721•56m ago•3 comments

AirPods 5

https://www.apple.com/newsroom/2026/09/apple-introduces-airpods-5-with-best-in-class-open-ear-act...
462•awad•17h ago•393 comments

Open Source Durable Objects for Postgres

https://solidobjects.dev/blog/introducing-solidobjects
25•cardmagic•1d ago•8 comments

iPhone 18 Pro and iPhone 18 Pro Max

https://www.apple.com/newsroom/2026/09/apple-debuts-iphone-18-pro-and-iphone-18-pro-max/
370•meetpateltech•17h ago•407 comments

Automattic's board forces CEO Matt Mullenweg into leave of absence

https://techcrunch.com/2026/09/09/automattics-board-forces-ceo-matt-mullenweg-into-leave-of-absence/
307•LeoPanthera•11h ago•210 comments

All grown-ups were once children, but only few of them remember it

https://mathstodon.xyz/@tao/117244102901892965
194•yurivish•7h ago•144 comments

Show HN: Compute polynomials twice as fast

https://thomasahle.com/fast-polynomials/
96•thomasahle•1d ago•34 comments

Aardman (Wallace and Gromit) Is Selling Its Original Movie Puppets

https://gizmodo.com/aardman-is-selling-its-original-movie-puppets-this-month-2000807968
56•Gaishan•3d ago•11 comments

Training a 3.8B LLM to 0.384 CORE for $998

https://hugovergnes.github.io/little-lm-3-8b/
87•Anon84•9h ago•14 comments

Desert Ant Labs: local, fast models that run on device

https://desertant.com/blog/introducing-desert-ant-labs/
454•willwhitedc•23h ago•97 comments

Qwen 3.8 follows GPT-5.5 Pro reasoning prefills

https://gist.github.com/wsxiaoys/e0286dc6bb624ff5fdf49e7f4c528ba3
221•wsxiaoys•18h ago•85 comments

I think I hate the internet

https://strategictree.bearblog.dev/i-think-i-hate-the-internet/
83•saikatsg•5h ago•66 comments

Factoring RSA 260

https://cognition.com/blog/factoring-rsa-260
102•samyok•15h ago•11 comments