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...)

Keep Our Servers Running

https://blog.archive.org/2026/09/01/keep-our-servers-running-your-recurring-donation-goes-3x-this...
278•sonicrocketman•3h ago•64 comments

Making a Python interpreter in 1024 bytes

https://austinhenley.com/blog/python1024.html
192•azhenley•8h ago•70 comments

I'm a seeing-eye dog for a computer

https://claytonwramsey.com/blog/seeing-eye/
58•claytonwramsey•3d ago•40 comments

It took a year to ship WebAssembly in Anubis

https://anubis.techaro.lol/blog/2026/anubis-wasm/
238•xena•10h ago•119 comments

Ask HN: Fable hacked my piano, can I release the results?

106•jmpman•1d ago•57 comments

Ask HN: How do you manage skills files?

83•imadtaieber•11h ago•66 comments

Has anybody seen my keys? A key-hierarchy strategy for rack-level security

https://rfd.shared.oxide.computer/rfd/0301
20•cyb0rg0•5h ago•1 comments

Ask HN: Would you read a statistics textbook?

64•usernametaken29•1d ago•27 comments

Nitter and XCancel resume service after legal advice

https://github.com/zedeus/nitter/commit/1428b4c2b4246f92a7e5b2673438e5fb39fcc4a3
663•zImPatrick•13h ago•307 comments

Mmuko Boot Sequence – a tiny freestanding C kernel that boots in QEMU

https://github.com/obinexus/mmuko-boot
4•obinexus•3d ago•1 comments

GrapheneOS Overhauled Default Apps and Secure Clipboard

https://grapheneos.social/@GrapheneOS/117225539756835649
268•Cider9986•10h ago•191 comments

Babylonian Lamb Stew with Beets (1750–1730 BCE)

https://babylonian-collection.yale.edu/about/babylonian-cooking
133•yubblegum•3d ago•85 comments

Show HN: Engrim – A universal, local-first SQLite memory engine for AI CLIs

https://github.com/timgordontg/engrim
14•timgordontg•2h ago•1 comments

Harnessing the Universal Geometry of Embeddings

https://arxiv.org/abs/2505.12540
71•ur-whale•10h ago•25 comments

I refused to train the AI that could replace me

https://restofworld.org/2026/ai-training-jobs-expert-replacement/
60•colinprince•2h ago•47 comments

Show HN: GET Together – A social network where you don't need POST to Post

https://gettogether.dev
36•nchudleigh•5h ago•12 comments

Every Novel Is Boring–Until It Isn't

https://www.publicbooks.org/every-novel-is-boring-until-it-isnt/
49•samclemens•3d ago•33 comments

Signing TLS handshakes inside a TPM

https://bschaatsbergen.com/posts/go-tpm-tls/
20•bschaatsbergen•10h ago•15 comments

Switzerland's Federal Government Is Replacing Microsoft on 3k Computers

https://itsfoss.com/news/switzerland-replace-microssoft-pilot/
23•ivell•1h ago•10 comments

TiVo to charge money for skipping commercials in your own recordings

https://cordcuttersnews.com/tivo-plans-to-end-free-automatic-commercial-skipping-in-november-test...
38•dmitrygr•2h ago•9 comments

Research acceleration: The view inside OpenAI

https://openai.com/index/research-acceleration-view-inside-openai
157•iamsyr•16h ago•102 comments

Asahi Linux on M3

https://asahilinux.org/2026/09/m2-episode-1/
425•mdp2021•17h ago•257 comments

Show HN: Mador – Make any DOM reactive with a tiny 80-line Proxy state tuple

https://github.com/marsbos/mador
85•bosmarcel•10h ago•26 comments

An Alien Mind

https://openai.com/index/an-alien-mind/
393•tosh•14h ago•341 comments

Is mathematics about to enter the conservatory?

https://mbmccoy.dev/posts/mathematical-conservatory/
35•_alternator_•8h ago•58 comments

Black Hole of Los Alamos: Seller of surplus nuclear research materials (2011)

https://www.atlasobscura.com/places/black-hole-of-los-alamos
60•Bluestein•4d ago•15 comments

NetBSD 9.5 released and EOL for NetBSD-9

https://blog.netbsd.org/tnf/entry/netbsd_9_5_released_and
126•jaypatelani•15h ago•12 comments

The NX bit is not just about security

https://purplesyringa.moe/blog/guest/the-nx-bit-is-not-just-about-security/
60•torutofu•2d ago•34 comments

Please don't rearrange our shoes when we turn up, paramedics in Japan urge

https://www.theguardian.com/world/2026/aug/28/never-tidy-paramedics-shoes-japan-custom-etiquette
77•high_na_euv•3d ago•85 comments

Reverse engineering the storage format for an undocumented database

https://blog.glazer.ee/posts/converting-cronos/
45•pintprint•3d ago•4 comments