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

MiniMax M3.1 Flash

https://www.minimax.io/blog/minimax-m31f
338•jtg•7h ago•150 comments

I built a drone with only one motor [video]

https://www.youtube.com/watch?v=Ndftcft6XhU
327•hakonjdjohnsen•14h ago•60 comments

OpenBSD 8.0 release will have inteldrm/radeondrm/amdgpu drivers from Linux 6.18

https://bsd.network/@brynet/117407035545900963
58•doener•2h ago•9 comments

Wine ported to OpenBSD

https://marc.info/?l=openbsd-ports&m=179236125692175
482•iamnothere•10h ago•162 comments

RuneScape Bench: MMOs for Agents [video]

https://www.youtube.com/watch?v=cNm4zyUtWj0
136•evakhoury•2d ago•54 comments

Putting Linux on my RTX Spark laptop because I don't have a Microsoft account

https://josie.lol/blog/linux-rtx-spark
148•pfeifferj•2h ago•64 comments

It's still ok to enjoy programming

https://chriskiehl.com/article/it-is-still-ok-to-enjoy-programming
398•goostavos•2d ago•379 comments

Android apps running native on macOS

https://github.com/kksimp/Mac.apk
234•flocked•7h ago•108 comments

One Hash Bloom Filters

https://calabro.io/ohbf
21•jcalabro•2h ago•1 comments

Timestral: Mistral's time-series foundation models

https://mistral.ai/news/timestral/
528•groar•13h ago•97 comments

Starcraft: Ashfall

https://starcraft-shooter-2026.pages.dev/
266•debo_•22h ago•92 comments

The fire retardant in the seafood chain

https://insideclimatenews.org/news/14102026/ethoxyquin-fire-retardant-in-seafood-chain/
95•gumby•2d ago•31 comments

Drupal is now light-years ahead of its reputation

https://dri.es/state-of-drupal-presentation-september-2026
14•scottfalconer•2h ago•8 comments

Alternatives to animal testing are finally taking off

https://spectrum.ieee.org/alternatives-to-animal-testing
308•rbanffy•12h ago•91 comments

Ask HN: How to deal with shipping AI-written code you don't understand?

221•rzk•12h ago•361 comments

Credit where credit is due

https://thefloatingcontinent.com/blog/credit-is-due/
53•evakhoury•3d ago•34 comments

Agentic Monitoring

https://benjamincongdon.me/blog/2026/10/19/Agentic-Monitoring/
21•bcongdon•8h ago•2 comments

The reverts will continue until morale improves

http://peter.eisentraut.org/blog/2026/10/09/the-reverts-will-continue-until-morale-improves
176•hans_castorp•5h ago•30 comments

Evidence (YC S21) Is Hiring Software Engineers

https://evidence.dev/jobs
1•hughess•6h ago

The End of Rationing

https://sanketsaurav.com/writing/end-of-rationing
21•sanketsaurav•4h ago•11 comments

Weball: Play Katamari on Websites

https://www.funwithcomputervision.com/weball/
4•croes•1d ago•1 comments

Launch HN: Laminar (YC S24) – RL-trained model that finds errors in agent traces

44•skull8888888•7h ago•22 comments

Ukraine claims first drone evacuation of wounded soldier

https://www.nbcnews.com/world/ukraine/ukraine-first-drone-evacuation-wounded-soldier-frontlines-h...
51•yzydserd•8h ago•65 comments

Chicago O'Hare digs up 50-ton boulder under airfield, asks public for name ideas

https://simpleflying.com/chicago-ohare-digs-up-50-ton-boulder-public-names/
94•Stratoscope•21h ago•79 comments

Let's Encrypt is adding two additional remote perspectives for domain validation

https://community.letsencrypt.org/t/lets-encrypt-is-adding-two-additional-remote-perspectives-for...
237•gslin•12h ago•76 comments

Plex vulnerabilities being exploited in the wild to drop a cryptominer

http://www.boredhackerblog.info/2026/10/plex-vulnerabilities-being-exploited-in.html
138•mindracer•10h ago•63 comments

Mercury 3: Diffusion at scale

https://www.inceptionlabs.ai/blog/introducing-mercury-3
211•cmrdporcupine•6h ago•82 comments

The Annotated VT100 Firmware (2022)

https://vt100.net/dec/vt100/rom/
61•Aleksandr_NFA•21h ago•3 comments

CERN and Mistral sign a statement of intent to establish a strategic partnership

https://home.cern/cern-and-mistral-join-forces-to-accelerate-ai-for-science/
308•kensai•8h ago•57 comments

Detecting model weight tampering in GPU memory (Rome attacks)

https://stealthium.io/blog/hands-off-detecting-model-weight-tampering
15•rafaeldavidtin•9h ago•1 comments