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

HackerRank open sourced its ATS. My resume scored 90/100. Oh wait 74. No – 88

https://danunparsed.com/p/hackerrank-open-source-ats
277•sambellll•6h ago•84 comments

GLM 5.2 beats Claude in our benchmarks

https://semgrep.dev/blog/2026/we-have-mythos-at-home-glm-52-beats-claude-in-our-cyber-benchmarks/
760•jms703•13h ago•363 comments

Dissecting Apple's Sparse Image Format (ASIF)

https://schamper.dev/dissecting-apples-sparse-image-format-asif/
41•supermatou•15h ago•0 comments

Age verification is just a precursor to automated attribution of speech

https://nonogra.ph/age-verification-is-just-a-precursor-to-attribution-of-speech-06-29-2026
337•arkhiver•4h ago•182 comments

Herdr: Agent multiplexer that lives in your terminal

https://github.com/ogulcancelik/herdr
41•mzehrer•3h ago•14 comments

Lore – Give your coding agent the decisions your team made

https://github.com/itsthelore/rac-core
25•tcballard•3h ago•19 comments

Historical memory prices 1960-2026

https://dam.stanford.edu/memory-prices.html
279•vga1•13h ago•99 comments

5k menus from the New York Public Library’s Buttolph Collection (1880-1920)

https://pudding.cool/2026/06/menu-story/
360•xbryanx•17h ago•92 comments

I used Claude Code to get a second opinion on my MRI

https://antoine.fi/mri-analysis-using-claude-code-opus
413•engmarketer•15h ago•541 comments

We found a bug in the hyper HTTP library

https://blog.cloudflare.com/hyper-bug/
17•Pop_-•3d ago•0 comments

Replacing Systemd with OpenRC in Debian

https://danielcordova.me/blog/debian-openrc/
3•nogajun•1h ago•0 comments

Knowledge Distillation of Black-Box Large Language Models (2024)

https://arxiv.org/abs/2401.07013
87•babelfish•9h ago•14 comments

Deciphering basmala

https://blog.plover.com/lang/bismillah.html
51•lordgrenville•4d ago•18 comments

Show HN: Zanagrams

https://zanagrams.com/
265•pompomsheep•16h ago•61 comments

US Grid Constraints: Towards 40GW+ of Behind-the-Meter Datacenter by 2028?

https://newsletter.semianalysis.com/p/us-grid-constraints-towards-40gw
4•felixdoerp•9m ago•0 comments

Tokenmaxxing is dead, long live tokenmaxxing

https://12gramsofcarbon.com/p/agentics-tech-things-tokenmaxxing
142•theahura•15h ago•173 comments

The Forgotten Castles of the Garamantes

https://www.wildmanlife.com/the-forgotten-castles-of-the-garamantes/
23•bookofjoe•4d ago•2 comments

The Baffling World of Masayoshi Son's Presentations (2020)

https://www.bloomberg.com/news/features/2020-06-23/golden-geese-and-unicorns-inside-the-eccentric...
57•phaser•2d ago•20 comments

The KIDS Act would require age checks to get online

https://www.eff.org/deeplinks/2026/06/kids-act-would-require-age-checks-get-online
444•bilsbie•19h ago•355 comments

Model Training as Code

https://aleph-alpha.com/en/blog/model-training-as-code/
71•peterBlue75•3d ago•14 comments

Professor denounces mass AI fraud on an exam at Brown

https://english.elpais.com/education/2026-06-28/ai-fraud-at-brown-university-academic-integrity-i...
375•geox•15h ago•500 comments

TOP500 at ISC’26: We have a New Number 1 Supercomputer

https://chipsandcheese.com/p/top500-at-isc26-we-have-a-new-number
105•rbanffy•12h ago•66 comments

Working around dragons with the Lemote Yeeloong laptop and OpenBSD

http://oldvcr.blogspot.com/2026/06/working-around-dragons-with-lemote.html
107•zdw•14h ago•30 comments

Librepods: AirPods liberated

https://github.com/librepods-org/librepods
359•rbanffy•12h ago•124 comments

The Boeing 747 begins its final descent

https://www.theatlantic.com/magazine/2026/07/boeing-747-retirement/687304/
182•dbl000•3d ago•251 comments

A way to exclude sensitive files issue still open for OpenAI Codex

https://github.com/openai/codex/issues/2847
201•pikseladam•19h ago•129 comments

Daisugi, the Japanese technique of growing trees out of other trees (2020)

https://www.openculture.com/2020/10/daisugi.html
130•MaysonL•15h ago•43 comments

Examining circuit boards from the Space Shuttle's I/O Processor

https://www.righto.com/2026/06/space-shuttle-io-processor-boards.html
104•pwg•15h ago•23 comments

More evidence is consistent with possible ancient life on Mars (2025)

https://www.cbc.ca/radio/quirks/more-evidence-of-life-on-mars-but-still-no-life-1.7649645
81•pseudolus•19h ago•78 comments

Idler Magazine

https://www.idler.co.uk/
19•tomjakubowski•3d ago•3 comments