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

John Carmack on the mistakes around Quake that ruined id software

https://twitter.com/ID_AA_Carmack/status/2069799283369345247
289•shadowtree•1h ago•133 comments

RubyLLM: A Ruby framework for all major AI providers

https://rubyllm.com/
203•doener•3h ago•25 comments

We’re making Bunny DNS free

https://bunny.net/blog/were-making-bunny-dns-free/
671•dabinat•8h ago•214 comments

For Most of the World, Open-Source AI Is the Only Way Forward

https://techstrong.ai/articles/for-most-of-the-world-open-source-ai-is-the-only-way-forward/
82•CrankyBear•2h ago•47 comments

CAPTCHAs have failed for 20 years

https://www.browserbase.com/blog/why-captchas-are-getting-harder
45•harsehaj•1h ago•34 comments

Computer use in Gemini 3.5 Flash

https://blog.google/innovation-and-ai/models-and-research/gemini-models/introducing-computer-use-...
19•swolpers•26m ago•1 comments

The Xteink X4 E-Ink Reader

https://blog.omgmog.net/post/xteink-x4-e-ink-reader/
29•felixdoerp•1h ago•7 comments

PR spam today looks like email spam in the early 2000s

https://www.greptile.com/blog/prs-on-openclaw
45•dakshgupta•3h ago•39 comments

I taught a bucket to speak Git

https://www.tigrisdata.com/blog/objgit/
32•xena•1h ago•3 comments

Show HN: Nub – A Bun-like all-in-one toolkit for Node.js

https://github.com/nubjs/nub
120•colinmcd•3h ago•26 comments

Krea 2: SOTA open-weights 12B image model

https://www.krea.ai/blog/krea-2-technical-report
196•mattnewton•1d ago•24 comments

Running Windows Games on a Hobby OS with Wine

https://astral-os.org/posts/2026/04/03/wine-on-astral.html
51•avaliosdev•3h ago•16 comments

Genuinely, my all-time favourite image: Mamenchisaurus hochuanensis

https://svpow.com/2026/06/04/genuinely-my-all-time-favourite-image-mamenchisaurus-hochuanensis/
51•surprisetalk•2d ago•18 comments

A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding

https://labs.iximiuz.com/tutorials/ssh-tunnels
163•signa11•4d ago•30 comments

Show HN: Monolisa v3 – a typeface for developers and creatives

https://www.monolisa.dev/
97•bebraw•2d ago•20 comments

Boffin claims Microsoft's "quantum leap" is invalid due to "basic Python errors"

https://www.theregister.com/research/2026/06/24/boffin-claims-microsofts-supposed-quantum-leap-do...
84•connorboyle•2h ago•35 comments

Show HN: Pure Effect – Reproduce production bugs on your laptop without a DB

https://pure-effect.org
38•tie-in•3d ago•7 comments

Haystack: Open-Source AI Framework for Production Ready Agents, RAG

https://haystack.deepset.ai/
67•doener•6h ago•20 comments

Show HN: peerd – AI agent harness that runs entirely in your browser

https://github.com/NotASithLord/peerd
21•NotASithLord•1d ago•10 comments

Founding a company in Germany: €9600, 152 days and I still can't send an invoice

https://paolino.me/founding-a-company-in-germany/
461•earcar•5h ago•537 comments

Edsger Dijkstra's Library (Housed and Archived in Leuven, Belgium)

https://www.dijkstrascry.com/inventory
21•rramadass•2h ago•4 comments

Raspberry Pi Pico W as USB Wi-Fi Adapter

https://gitlab.com/baiyibai/pico-usb-wifi
231•byb•14h ago•110 comments

Systems optimization should be part of CI/CD

https://ucbskyadrs.github.io/blog/levi/
21•ttanv•4h ago•2 comments

Journalism is rearranging the deckchairs. It needs to reinvent itself

https://werd.io/journalism-is-rearranging-the-deckchairs-it-needs-to-reinvent-itself/
7•benwerd•2h ago•3 comments

Pull request limits are cutting down the noise

https://github.blog/open-source/maintainers/how-pull-request-limits-are-cutting-down-the-noise/
7•ingve•5d ago•1 comments

Statistics that live in your SQL

https://kolistat.com/blog/the-stats-duck-v0-6-0/
113•caerbannogwhite•2d ago•15 comments

OpenAI and Broadcom unveil LLM-optimized inference chip

https://openai.com/index/openai-broadcom-jalapeno-inference-chip/
131•meetpateltech•4h ago•49 comments

Ashby (YC W19) Is Hiring EMEA Engineers Who Can Design

https://www.ashbyhq.com/careers?ashby_jid=87b96eef-edc1-4de4-adb6-d460126d02f8&utm_source=hn
1•abhikp•10h ago

Minimus container images are now free

https://images.minimus.io/
106•dimastopel•5h ago•60 comments

François Englert (1932 – 2026)

https://home.cern/francois-englert-1932-2026/
53•toomuchtodo•3d ago•3 comments