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

Linux 7.3 Released

https://lwn.net/Articles/1101143/
132•cjd8•1h ago•49 comments

Rabbits were a medieval royal luxury in England until the Black Death

https://phys.org/news/2026-10-rabbits-medieval-royal-luxury-england.html
83•samizdis•1d ago•66 comments

Hybrid Reasoning Agents: LLM agents that think in latent space, act through text

https://arxiv.org/abs/2610.18861
384•allinonai•12h ago•187 comments

William Gibson and the trademarking of cyberspace

https://colo.to/cyberspace.html
176•Eric_Gullichsen•9h ago•62 comments

How to Train Your Robot

https://www.construction-physics.com/p/how-to-train-your-robot
18•crescit_eundo•3d ago•7 comments

There's never been a better time to go into math (by: 3blue1brown) [video]

https://www.youtube.com/watch?v=LKrwhjOI8Nc
362•mdp2021•1d ago•433 comments

If you don't run your own LLM proxy, how do you know whats going on?

https://jrdsgl.com/if-you-dont-run-your-own-llm-proxy-how-the-fuck-do-you-even-know-whats-going-on/
163•amrrs•12h ago•107 comments

Tmux and Claude Code: Sessions, Send-Keys, and the Ceiling

https://crystl.dev/guides/tmux-for-ai-agents/
19•ankitg12•3h ago•8 comments

Someone behind the software

https://karrisaarinen.com/posts/someone-behind-the-software/
438•tosh•16h ago•162 comments

Superlite: A Faster Alternatie to Superpowers

https://contextfirst.blog/superlite-hand-an-agent-a-spec/
92•iheatuchriswogu•7h ago•35 comments

Flatpak – An Insecurity Nightmare

https://oro.gay/posts/flatpak-an-insecurity-nightmare/
30•jannesan•4h ago•19 comments

Laptop Based on 6502 CPU

https://www.maddox.pro/?p=448
120•nanochess•3d ago•52 comments

Dogs seem to agree with humans that 'bouba' is round and 'kiki' is spiky

https://www.sciencealert.com/dogs-seem-to-agree-with-humans-that-bouba-is-round-and-kiki-is-spiky
233•gmays•1d ago•140 comments

RepRapMicron

https://github.com/VikOlliver/RepRapMicron/wiki
389•RobotToaster•19h ago•64 comments

The DNS Museum

https://dns.museum
68•zdw•2d ago•9 comments

Lant – The Forgotten Resource

https://sites.udel.edu/materialmatters/2018/04/11/lant-the-forgotten-resource/
5•kreyenborgi•3d ago•1 comments

How Quickly Can the DoD Rebuild and Recast the Munitions Industrial Base?

https://www.csis.org/analysis/how-quickly-can-dod-rebuild-and-recast-munitions-industrial-base
59•gmays•9h ago•64 comments

Free Pascal compiler now supports dynamic packages

https://www.getlazarus.org/dynamic/
161•sysrpl•14h ago•38 comments

Show HN: WhatsApp MCP running free on Cloudflare

https://github.com/finereli/whatsapp-mcp
107•zoozla•11h ago•52 comments

Verisign .com Domain Name Registry Consumer Class Action

https://www.hbsslaw.com/cases/verisign-com-domain-name-registry-consumer-class-action
95•greyface-•4h ago•42 comments

PalmOS Lemmings

https://github.com/ardiri/palmos-lemmings
126•memalign•15h ago•32 comments

I built a programming language that LLMs can't use

https://blog.picheta.me/post/killswitch-lang/
184•dom96•1d ago•126 comments

A new way to think about borrow checking (in reverse)

https://verdagon.dev/blog/reverse-borrow-checking
83•verdagon•21h ago•7 comments

DeepSeek V4.1 Flash 1017 (Max)

https://artificialanalysis.ai/models/deepseek-v4-1-flash-1017
136•theanonymousone•4h ago•44 comments

How Postgres DELETE can actually scale

https://www.dbos.dev/blog/scaling-deletions-in-postgres
15•KraftyOne•3d ago•1 comments

Java sealed classes and exhaustive pattern matching

https://neilmadden.blog/2026/04/24/java-sealed-classes-and-exhaustive-pattern-matching/
168•hnisjafx40•18h ago•129 comments

One parser, two bugs, many routers: Exploiting Broadcom WiFi across eCos, Linux

https://quentinkaiser.be/security/2026/10/16/one-parser-two-bugs/
77•zoobab•2d ago•18 comments

macOS 15.8.2 Breaks OpenGL

https://developer.apple.com/forums/verify-human/verify.html?next=/forums/thread/850550
255•Audiophilip•17h ago•285 comments

Open MicroManipulator – A sub-micrometer 3D motion control plattform

https://github.com/0x23/MicroManipulatorStepper
195•_Microft•21h ago•16 comments

"I'm on a war footing": Terry Tao and the crisis in math

https://www.nytimes.com/2026/10/16/us/math-ai-terence-tao.html
179•vinipolicena•2d ago•351 comments