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

Quad9 (DNS Resolver) to Exit France

https://quad9.net/news/blog/au-revoir-france/
639•farrokhi•5h ago•240 comments

eMudhra to exit global SSL/TLS certificate business

https://emudhra.com/en/press-release/emudhra-to-exit-global-ssl-tls-certificate-business
801•bo0tzz•6h ago•564 comments

OpenShell – A safe, private runtime for fleets of autonomous AI agents

https://github.com/NVIDIA/OpenShell
135•niemandhier•2h ago•67 comments

Getting ready to operate GNU Taler in Germany

https://www.taler.net/en/news/2026-13.html
126•dewey•4h ago•35 comments

Show HN: Run full iOS 16.5 firmware on Android Devices

https://github.com/oosexgang/hackios-xnu-kernel
214•aghuang•4h ago•70 comments

Show HN: UI micro interactions prompts for AI

https://www.typeui.sh/micro-interactions
40•elwingo1•1h ago•15 comments

AI and the Enclosure of the Scientific Commons

https://arxiv.org/abs/2610.27251
33•jrepinc•1h ago•10 comments

Award-Winning AI Literature

https://jamesyu.org/award-winning-ai-literature/
33•jamesjyu•1h ago•18 comments

What Is Gridifcation

https://musicalform.substack.com/p/what-is-gridifcation
328•gumby•3d ago•160 comments

Jailbreaking the Switch 2

https://pepsipu.com/blog/2026-10-switch2-jailbreak-ns2jb/
594•ledoge•12h ago•216 comments

Hedra is a 3D open world game I wrote from scratch while in highschool

https://github.com/maxilevi/project-hedra/tree/pre-ai
44•maxilevi•1h ago•10 comments

A farewell to Arc browser

https://arc.net/
163•suhdonghwi•3h ago•122 comments

Show HN: Turn regular JavaScript into a neural net

https://chenglou.me/handwired/
14•chenglou•1d ago•4 comments

Tell HN: I unknowingly broke the PHP RCE embargo. I am sorry.

142•petecooper•10h ago•36 comments

Dungeon Generation in the Gnomish Mines of NetHack

https://www.boristhebrave.com/2026/10/18/dungeon-generation-in-the-gnomish-mines-of-nethack/
88•ibobev•3d ago•10 comments

AI analysis of CT scans finds 42.9% of patients have coronary inflammation

https://www.biograph.com/newsroom/biograph-completes-first-u.s.-study-with-caristo-diagnostics%E2...
41•brandonb•2h ago•22 comments

Google cleared 300 hectares of Finnish forest

https://www.techspot.com/news/114100-google-cleared-300-hectares-finnish-forest-data-center.html
297•wetwater•4h ago•197 comments

What’s getting pwned right now

https://pwn.watch/
277•mrkd•6h ago•135 comments

Mini brain organoids 'reading' Braille key step towards biohybrid computing

https://www.frontiersin.org/news/2026/10/16/mini-brain-organoids-reading-braille-biohybrid-comput...
20•CharlesW•4h ago•10 comments

A complete bypass of eMudhra’s 1FA OTP login system

https://mastodon.catgirl.cloud/@49016/117475976434068995
73•tensegrist•1h ago•19 comments

Faster than earcut: triangulating 3.7M map polygons in 489 ms

https://globus.software/blog/2026/10/16/cutting-map-polygons/
179•molind•10h ago•35 comments

Show HN: agent-usage-guard – a Claude Code mod to protect your usage window

https://github.com/rbartoli/agent-usage-guard
13•zzyyxx332211•2h ago•6 comments

Show HN: Uberblok – an interactive museum of ZFS internals

https://uberblok.storagebits.workers.dev/
49•storagebits•1d ago•13 comments

MPs moving to restrict gambling ads in Canada

https://www.cbc.ca/news/investigates/gambling-ads-restrictions-canada-9.7388888
185•Teever•5h ago•94 comments

The Last Museum: Semantic search across 5.8M artworks from major museums

https://lastmuseum.com/
81•surprisetalk•7h ago•25 comments

Show HN: Build a world on your phone, explore it in XR on Vision Pro and Quest

https://3d.camilleworld.com/play/
7•suejunghuh0•1h ago•1 comments

WorldTUI: I trained a 360M model to pretend to be a terminal

https://simedw.com/2026/10/21/world-model-terminal/
459•alphax314•17h ago•148 comments

Startup taps underwater volcano as energy source in "proof point" test

https://arstechnica.com/science/2026/10/startup-taps-underwater-volcano-as-energy-source-in-proof...
106•wffurr•3d ago•43 comments

VMMouse for NT 3.x: QEMU/VMware mouse integration driver

https://github.com/rhargreaves/vmmouse-nt3
40•kiyouta•4d ago•9 comments

Security Disclosure

https://blog.railway.com/p/security-disclosure-wednesday-october-21st
571•passenger•22h ago•330 comments