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

Hurried Announcement: Alessandro Masullo GRH

https://math216.wordpress.com/2026/11/20/hurried-announcement-alessandro-masullo-grh/
2022•jasondavies•14h ago•937 comments

Levent Alpöge claims proof of the Generalized Riemann Hypothesis [pdf]

https://alpo.ge/remark.pdf
2614•iamronaldo•19h ago•1798 comments

Inkling 2 Mini

https://thinkingmachines.ai/news/inkling-2-mini/
968•jasondavies•13h ago•180 comments

ClawDOS – An AI coding agent for DOS

http://ricapar.net/ClawDOS/
56•Ricapar•3h ago•15 comments

NINLIVE: The Nine Inch Nails live archive

https://ninlive.com/
252•CharlesW•10h ago•64 comments

We promoted developers into architects without informing them

https://manidoraisamy.com/developer-to-architect.html
422•QueensGambit•15h ago•234 comments

Clojure will affect the way you think about programming (2017)

https://eli.thegreenplace.net/2017/clojure-the-perfect-language-to-expand-your-brain/
84•sammatilda•6h ago•29 comments

Unforced Navier-Stokes Singularity and the Generalized Riemann Hypothesis

https://terrytao.wordpress.com/2026/11/20/unforced-euler-singularity-unforced-navier-stokes-singu...
442•archon1410•16h ago•181 comments

Surprisingly Adorable Insect Portraits

https://amateurphotographer.com/latest/these-astonishing-insect-portraits-reveal-a-hidden-world-y...
31•NordStreamYacht•2h ago•7 comments

Sir Brian May adds new dimension to Hera asteroid

https://www.esa.int/articles/about-us/directorates/operations/space-safety/hera/sir-brian-may-add...
101•mooreds•10h ago•21 comments

Language Models Can Rewrite Their Own Weights

https://arxiv.org/abs/2611.21885
406•lwhsiao•17h ago•118 comments

Valkey kills the skiplist, cuts sorted set overhead by up to 43%

https://valkey.io/blog/from-skiplist-to-b+tree/
125•reconditerose•3d ago•47 comments

Ask HN: I have been unemployed for 2y. 15 years of experience, US. What to do?

162•LetThingsBeDiff•10h ago•137 comments

Worlds largest beaver dam in Northern Alberta

https://substack.com/@canadianreturnee/note/c-319574497
20•bookofjoe•1d ago•6 comments

DreamCoder: Coding harness and IDE from the author of Mastering Emacs

https://www.masteringemacs.org/article/announcing-dreamcoder
206•facundo_olano•13h ago•57 comments

Fewer slides, more dragons

https://www.breakingchange.blog/p/fewer-slides-more-dragons
25•firloop•2d ago•7 comments

Catching Crumbs from the Table [pdf]

https://gwern.net/doc/fiction/science-fiction/2000-chiang.pdf
6•gchamonlive•9h ago•1 comments

Finite-time blow-up for the Navier–Stokes equations

https://github.com/tristanbuckmaster/navier-stokes/
285•trotro•17h ago•88 comments

Nasdaq erases all 2026 gains as AI sell-off dampens Anthropic’s second day

https://www.theguardian.com/business/2026/nov/20/global-stock-markets-slump-anthropic-ipo-ai-sell...
301•cdrnsf•19h ago•569 comments

3-legged Persian leopard's 150-mile journey highlights Caucasus border hazards

https://news.mongabay.com/short-article/2026/11/three-legged-persian-leopards-150-mile-journey-hi...
20•rguiscard•3d ago•3 comments

Vibecoding an inference chip

https://ankitg.me/blog/vibecoding-inference-chip/
143•ankitvgupta•15h ago•61 comments

Microsoft's SideWinder Strategic Commander was a failed attempt

https://www.rockpapershotgun.com/microsofts-sidewinder-strategic-commander-was-a-failed-attempt-t...
6•Tomte•3d ago•2 comments

Show HN: Tinnitus frequency finder and audio notch tool

https://trynotched.com/find
171•brianrhea•3d ago•114 comments

Backblaze Notice at Collection and Privacy Policy

https://www.backblaze.com/company/policy/privacy
186•meysamazad•6h ago•57 comments

Why the Airbus A321XLR often gets stuck climbing for first few hours of flight

https://simpleflying.com/airbus-a321xlr-often-stuck-climbing-1st-few-hours-flight/
116•edward•1w ago•80 comments

Slopstrap – Make your site look hastily vibecoded

https://slopstrap.mikelacher.com/
245•mlacher•18h ago•42 comments

Serious cyberattack thought backed by wealthy operators

https://www.ruv.is/english/2026-11-20-serious-cyberattack-thought-backed-by-wealthy-operators-493411
80•Bender•10h ago•41 comments

The stochastic parrots have apparently proved the Riemann Hypothesis

https://scottaaronson.blog/?p=10344
284•stratos123•13h ago•249 comments

Winedroid – run Android apps without Android (WASM demo)

https://winedroid.soham.sh/demo/
135•sohzm•13h ago•42 comments

I can’t believe it’s 1

https://aperiodical.com/2026/11/i-cant-believe-its-1/
67•ColinWright•4d ago•65 comments