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

Malware infects Android-based automotive head unit firmware

https://securelist.com/android-head-unit-malware/121106/
127•campuscodi•3h ago•51 comments

My favorite nonfiction books about cults, scams, and schemes

https://bookdna.com/best-books/nonfiction-about-cults-scams-and-schemes
72•bwb•2h ago•21 comments

How Complex Systems Fail

https://how.complexsystems.fail/
20•shortcrct•55m ago•1 comments

I spent $266 and four AI models to own my tablet. GLM-5.3 finished it in a day

https://ericpardee.github.io/fire-hd-ownership/
35•dr_pardee•1h ago•17 comments

Things I want in a modern relational query language

https://sporks.space/2026/08/19/things-i-want-in-a-modern-relational-query-language/
32•zdw•21h ago•23 comments

Slovakia finds Russian backdoor in traffic speed cameras

https://risky.biz/risky-bulletin-slovakia-finds-russian-backdoor-in-traffic-speed-cameras/
82•dredmorbius•1h ago•29 comments

To become a better writer, read as much as you can

https://nappertime.com/the-golden-rule-of-becoming-a-better-writer/
341•andsoitis•12h ago•215 comments

Hacker News in Uncompromised Detail

https://vale.rocks/posts/hacker-news
8•OuterVale•58m ago•4 comments

What Is a Harness?

https://earendil.com/posts/what-is-a-harness/
78•tosh•1h ago•48 comments

The End of an Athlon

http://www.os2museum.com/wp/the-end-of-an-athlon/
148•userbinator•10h ago•62 comments

I gave Qwen 3.8 27B a reverse-engineering job and it finished in 30 minutes

https://www.xda-developers.com/qwen-3-8-27b-reverse-engineering-job-frontier-model/
193•raybb•6h ago•93 comments

Show HN: Live 3D satellite tracker and the declassified Pentagon UFO archive

https://skylens.yantraai.app/
41•skylensspace•6h ago•20 comments

MartyPC is a cross-platform emulator of early PCs written in Rust

https://martypc.net/
161•boilerupnc•12h ago•57 comments

Why your local LLM feels dumber than it is

https://forum.level1techs.com/t/why-your-local-llm-feels-dumber-than-it-is/253917
428•felineflock•21h ago•176 comments

Death to px, long live ch

https://shkspr.mobi/blog/2026/08/death-to-px-long-live-ch/
33•Brajeshwar•2h ago•24 comments

The Art and Beauty of Blade Runner (2015)

https://nappertime.com/the-art-of-and-beauty-of-blade-runner/
141•cocacola1•15h ago•80 comments

JIT Compiling Code in 5μs

https://malisper.me/jit-compiling-code-in-5-us/
127•zX41ZdbW•10h ago•84 comments

Authoritarianism of Code

https://zedshaw.com/blog/2020-10-07-authoritarianism-of-code/
20•wqlander•1h ago•11 comments

Universal Housing

https://twitter.com/christianreber/status/2091532545577849008
10•tosh•44m ago•4 comments

Hister – A private, full content search index that you control

https://hister.org/
433•auraham•4d ago•96 comments

Fast and Hard Code

https://lucumr.pocoo.org/2026/8/22/fast-hard-code/
87•tosh•10h ago•52 comments

ElevenLabs, TwelveLabs, ThirteenLabs

https://quantumi.sh/public/labs.html
449•jemoka•1d ago•135 comments

typ.ing

https://typ.ing/
331•bookofjoe•5d ago•104 comments

Amiga-Inspired AROS Goes Bare Metal on Raspberry Pi

https://hackaday.com/2026/08/23/amiga-inspired-aros-goes-bare-metal-on-raspberry-pi/
15•mdp2021•1h ago•0 comments

Scrap (2006)

https://twitter.com/moxie/status/2091218652133732491
392•tosh•22h ago•213 comments

Blueprint for how to be self sufficient in a 1/4 acre backyard

https://www.reddit.com/user/CandescentgenyVet/comments/1vw9dcj/blueprint_for_how_to_be_self_suffi...
14•jamarna•58m ago•2 comments

Thinking in Python

https://thinkinginpython.com/
257•pjacotg•21h ago•54 comments

RF Cafe

https://www.rfcafe.com/
229•gregsadetsky•4d ago•44 comments

New MCP Roadmap

https://blog.modelcontextprotocol.io/posts/mcp-roadmap/
247•pentagrama•1d ago•148 comments

NanoGPT Speedrun Frontier

https://www.primeintellect.ai/research/nanogpt-speedrun
130•stared•17h ago•33 comments