frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

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•8mo ago

Comments

castratikron•8mo 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•8mo 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•8mo 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•8mo 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•8mo 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•8mo ago
in CPU's - pipelining!
jchw•8mo 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...)

Apple is fighting for TSMC capacity as Nvidia takes center stage

https://www.culpium.com/p/exclusiveapple-is-fighting-for-tsmc
551•speckx•10h ago•341 comments

Pocket TTS: A high quality TTS that gives your CPU a voice

https://kyutai.org/blog/2026-01-13-pocket-tts
168•pain_perdu•20h ago•32 comments

Inside The Internet Archive's Infrastructure

https://hackernoon.com/the-long-now-of-the-web-inside-the-internet-archives-fight-against-forgetting
237•dvrp•1d ago•56 comments

Linux boxes via SSH: suspended when disconected

https://shellbox.dev/
105•messh•5h ago•76 comments

Ask HN: How can we solve the loneliness epidemic?

370•publicdebates•8h ago•666 comments

JuiceFS is a distributed POSIX file system built on top of Redis and S3

https://github.com/juicedata/juicefs
102•tosh•6h ago•59 comments

CVEs affecting the Svelte ecosystem

https://svelte.dev/blog/cves-affecting-the-svelte-ecosystem
139•tobr•7h ago•26 comments

Go-legacy-winxp: Compile Golang 1.24 code for Windows XP

https://github.com/syncguy/go-legacy-winxp/tree/winxp-compat
64•Oxodao•3d ago•18 comments

Briar keeps Iran connected via Bluetooth and Wi-Fi when the internet goes dark

https://briarproject.org/manual/fa/
98•us321•5h ago•30 comments

Data is the only moat

https://frontierai.substack.com/p/data-is-your-only-moat
69•cgwu•6h ago•17 comments

Claude is good at assembling blocks, but still falls apart at creating them

https://www.approachwithalacrity.com/claude-ne/
153•bblcla•1d ago•123 comments

Photos capture the breathtaking scale of China's wind and solar buildout

https://e360.yale.edu/digest/china-renewable-photo-essay
486•mrtksn•15h ago•385 comments

Show HN: OpenWork – an open-source alternative to Claude Cowork

https://github.com/different-ai/openwork
120•ben_talent•1d ago•24 comments

My Gripes with Prolog

https://buttondown.com/hillelwayne/archive/my-gripes-with-prolog/
17•azhenley•1h ago•6 comments

Aviator (YC S21) is hiring to build multiplayer AI coding platform

https://www.ycombinator.com/companies/aviator/jobs
1•ankitdce•4h ago

First impressions of Claude Cowork

https://simonw.substack.com/p/first-impressions-of-claude-cowork
127•stosssik•1d ago•75 comments

Use of Bayesian methodology in clinical trials of drug and biological products [pdf]

https://www.fda.gov/media/190505/download
41•brendanashworth•17h ago•15 comments

Why senior engineers let bad projects fail

https://lalitm.com/post/why-senior-engineers-let-bad-projects-fail/
101•SupremumLimit•2h ago•92 comments

A Unique Performance Optimization for a 3D Geometry Language

https://cprimozic.net/notes/posts/persistent-expr-memo-optimization-for-geoscript/
24•Ameo•4d ago•2 comments

Show HN: Gambit, an open-source agent harness for building reliable AI agents

https://github.com/bolt-foundry/gambit
16•randall•1h ago•2 comments

What a Programmer Does (1967)[pdf]

http://archive.computerhistory.org/resources/text/Knuth_Don_X4100/PDF_index/k-9-pdf/k-9-u2769-1-B...
14•nz•4d ago•3 comments

Claude Cowork runs Linux VM via Apple virtualization framework

https://gist.github.com/simonw/35732f187edbe4fbd0bf976d013f22c8
91•jumploops•1d ago•30 comments

Supply Chain Vuln Compromised Core AWS GitHub Repos & Threatened the AWS Console

https://www.wiz.io/blog/wiz-research-codebreach-vulnerability-aws-codebuild
84•uvuv•8h ago•14 comments

Found: Medieval Cargo Ship – Largest Vessel of Its Kind Ever

https://www.smithsonianmag.com/smart-news/archaeologists-say-theyve-unearthed-a-massive-medieval-...
119•bookofjoe•10h ago•27 comments

How I learned everything I know about programming

https://agentultra.com/blog/how-i-learned-everything-i-know/index.html
40•speckx•5h ago•26 comments

Tldraw pauses external contributions due to AI slop

https://github.com/tldraw/tldraw/issues/7695
29•pranav_rajs•1h ago•6 comments

Show HN: Control Claude permissions using a cloud-based decision table UI

https://github.com/rulebricks/claude-code-guardrails
11•sidgarimella•7h ago•5 comments

25 Years of Wikipedia

https://wikipedia25.org
423•easton•12h ago•363 comments

Design and Implementation of Sprites

https://fly.io/blog/design-and-implementation/
127•sethev•9h ago•96 comments

An Unfolding Scientific Revolution in Cosmology

https://economicsfromthetopdown.com/2026/01/15/an-unfolding-scientific-revolution-in-cosmology/
4•empiko•1h ago•0 comments