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

Git for the US Code

https://lexifina.com/blog/git-for-the-us-code
170•alansaber•4h ago•83 comments

Artificial Analysis Intelligence Index v5.0

https://artificialanalysis.ai/methodology/intelligence-benchmarking
20•scooby7430•1h ago•6 comments

Genie 4

https://deepmind.google/blog/genie-4-a-new-generation-of-world-simulation/
825•acossta•14h ago•493 comments

Ghostty 1.4

https://ghostty.org/docs/install/release-notes/1-4-0
904•deaux•13h ago•281 comments

Ink droplets in motion snag top prize in Nikon Small World contest

https://arstechnica.com/science/2026/10/meet-the-2026-winner-of-nikons-small-world-photomicrograp...
163•_Microft•2d ago•25 comments

Survival LLM: AI assistant and emergency library that runs on your own computer

https://www.brangus.io/survival-llm
283•Luc•10h ago•123 comments

Tailscale SSH: Investigation and remediation update

https://tailscale.com/ssh-investigation-update
255•figmert•10h ago•127 comments

Early progress on accelerating drug development with Claude

https://www.anthropic.com/research/early-progress-drug-development
197•dataking•9h ago•173 comments

A Love Letter to the Super Dimension Fortress

https://brennan.day/a-love-letter-to-the-super-dimension-fortress/
40•jruohonen•3d ago•5 comments

MacOS Extensions Pack for the Apple Network Server v1.0

http://oldvcr.blogspot.com/2026/10/macos-extensions-pack-for-apple-network.html
10•classichasclass•3d ago•0 comments

Raspberry Pi Zero 3W and Pi 4 Model A spotted in device trees

https://bret.dk/raspberry-pi-zero-3-w-pi-4-model-a/
140•sthlmb•9h ago•62 comments

Reviewers rarely talk about reliability. Owners bring it up twice as often

https://www.bettascore.ai/research/reliability-reviewers-vs-owners
102•tsxng•8h ago•83 comments

New 14‑inch MacBook Pro with M6

https://www.apple.com/in/newsroom/2026/10/apple-introduces-the-new-14-inch-macbook-pro-with-m6/
330•beex•14h ago•419 comments

Python's experimental JIT to be removed

https://lwn.net/SubscriberLink/1102102/0c00e4d550f25f8c/
477•f311a•19h ago•254 comments

81 Jokes for the ZX81

https://spelk.press/gb/products/81-jokes-for-the-zx81
63•robin_reala•1d ago•5 comments

Assembly Nights (2021)

https://ratfactor.com/assembly-nights
43•andsoitis•2d ago•9 comments

SS United States to be sunk as largest artificial reef

https://divemagazine.com/scuba-diving-news/ss-united-states-to-be-sunk-as-worlds-largest-artifici...
118•geox•2d ago•80 comments

Code-execution flaw in UEFI firmware threatens most servers on planet Earth

https://arstechnica.com/security/2026/10/code-execution-flaw-in-uefi-firmware-threatens-most-serv...
92•DamnInteresting•9h ago•24 comments

New iMac with M6

https://www.apple.com/imac/
323•notfried•17h ago•400 comments

Moxnox 1.0: NT-Like, POSIX-Compatible OS Running Atop Btrfs

https://github.com/maharmstone/moxnox
49•SockThief•6h ago•8 comments

Classification of Finite Simple Groups Formalized in Lean

https://cfsg.axiommath.ai/
196•pfdietz•14h ago•52 comments

An examination of lost firefly species of the US and Canada

https://journaloflostspecies.org/index.php/jls/article/view/37/33
112•bryanrasmussen•3d ago•30 comments

What Happened to the Neanderthals?

https://www.nytimes.com/2026/10/26/science/what-happened-to-the-neanderthals.html
19•Hooke•1d ago•8 comments

Four Months of Zig

https://gracefulliberty.com/articles/four-months-of-zig/
105•ibobev•10h ago•59 comments

US Government is hiding a secret court ruling about how it spies on Americans

https://www.wired.com/story/the-us-government-is-hiding-a-secret-court-ruling-about-how-it-spies-...
889•helterskelter2•16h ago•317 comments

Artificial Analysis Intelligence Index v5

https://artificialanalysis.ai/articles/artificial-analysis-intelligence-index-v5
12•hn-aarvin•3h ago•3 comments

Radio-tagged Monarch butterflies

https://news.vt.edu/articles/2026/10/cmi-monarchs.html
46•rdmuser•12h ago•16 comments

Why Micron Is Suddenly Ditching 4F² DRAM as Rivals Double Down

https://hothardware.com/news/why-micron-is-suddenly-ditching-4f-dram
159•rbanffy•1d ago•24 comments

Hunger beats tenure: Advice for junior engineers

https://felixrieseberg.com/hunger-beats-tenure-advice-for-junior-engineers/
28•akavi•8h ago•9 comments

Nvidia and Micron Make Up 34% of America's Earnings Boom

https://www.wsj.com/finance/stocks/the-earnings-boom-is-heavily-reliant-on-just-a-handful-of-stoc...
137•JumpCrisscross•2d ago•29 comments