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

Anthropic’s Nasdaq debut

https://www.reuters.com/business/finance/anthropics-historic-debut-put-ais-promise-peril-wall-st-...
836•wslh•7h ago•1599 comments

Pancreatic cancer halted by virus injection in three patients

https://www.newscientist.com/article/2528235-pancreatic-cancer-halted-by-virus-injection-in-three...
482•cybermango•6h ago•70 comments

Synology Security Advisory

https://www.synology.com/en-uk/security/advisory/Synology_SA_26_21
74•choult•1h ago•36 comments

Claude solves two open problems in the physics of black holes

https://www.anthropic.com/research/claude-black-hole-physics
347•cybermango•6h ago•155 comments

How to CAD Almost Anything

https://ocw.mit.edu/courses/res-16-002-how-to-cad-almost-anything-january-iap-2024/
76•o4c•2d ago•13 comments

RegExr: Temporarily Offline

https://regexr.com/
26•somebudyelse•1h ago•16 comments

The 98% Slot Machine: How Paid Advertising Became an Extraction Tax

https://globalcommercegraph.com/writing/the-ninety-eight-percent-slot-machine
176•dev1one1•5h ago•90 comments

Garage Door Spam

https://blog.harrison.page/garage-door-spam/
722•harrisonpage•3d ago•307 comments

Should governments slow frontier AI? Jacob Coxon and Robin Hanson debate [video]

https://www.youtube.com/watch?v=lwfewYL7X0o
64•sandslash•5h ago•119 comments

Show HN: Cornhole News – A Hacker News inspired site for news across the Midwest

https://cornholenews.news
179•cornholemedia•8h ago•88 comments

Someone reported java4shell bug in September 2026

https://github.com/openjdk/jdk/pull/32781
347•notmine1337•12h ago•90 comments

UK government forced to admit it issued Apple a secret encryption order

https://macanorak.com/uk-government-forced-to-admit-it-issued-apple-a-secret-encryption-order/
466•Terretta•7h ago•201 comments

Rebuilding my local voice assistant pipeline

https://blog.platypush.tech/article/Rewriting-my-voice-assistant-pipeline
42•todsacerdoti•3h ago•5 comments

Launch HN: Onlook (YC W25) – An open-source developer tool for designers

https://github.com/onlook-dev/onlook/
82•D_R_Farrell•7h ago•66 comments

Reverse-Engineering Kevin J. Lang's Lost OCaml Code in Apache DataSketches

https://www.tisonkun.io/posts/ai-repair-program/
29•tison•3d ago•0 comments

Making 8-page foldable zines from a single A4 sheet in the browser

https://krthr.co/paper-folds-and-whats-new-in-fanzines-app/
235•krthr•10h ago•51 comments

Computer Graphics from Scratch (2021)

https://www.gabrielgambetta.com/computer-graphics-from-scratch/index.html
43•ibobev•2d ago•9 comments

Ruby2ßhell: Pre-authentication RCE on stock Rails

https://verialabs.com/ruby2shell/
379•jdns•19h ago•160 comments

Nintendo takes Picofly firmware down from GitHub [video]

https://www.youtube.com/watch?v=-TLCGUpoD6c
249•cowlevel•1d ago•95 comments

How the European Commission rolled out Matrix to more than 40k staff

https://element.io/blog/how-the-european-commission-rolled-out-matrix-to-more-than-40-000-staff/
649•liotier•13h ago•310 comments

Pete warden on local AI, open models, voice interfaces, the future of hardware

https://thedataexchange.media/pete-warden-moonshine/
207•datascientist•8h ago•189 comments

Visa, Mastercard and JPMorgan Customer Data Leaked by Hackers

https://www.wsj.com/finance/banking/visa-mastercard-and-jpmorgan-customer-data-leaked-by-hackers-...
28•mikhael•40m ago•2 comments

An Oregon library ditched Dewey Decimal and got people excited about books again

https://www.fastcompany.com/91597520/oregon-library-ditched-dewey-decimal-wayfinding-system
183•bookofjoe•2d ago•138 comments

Do not buy RAM, compress

https://curiousbits.nl/blog/do-not-buy-ram-compress/
240•Ecno92•15h ago•201 comments

What's New in PHP 8.6

https://www.php.net/releases/8.6/en.php
269•netol•14h ago•126 comments

Unblockable communication with gravity

https://www.science.org/doi/10.1126/sciadv.aee0802
137•rbanffy•11h ago•50 comments

Distributed, high-performance blob storage on SQLite

https://zerodha.tech/blog/high-performance-distributed-blob-storage/
251•ghostfoxgod•15h ago•68 comments

How to Make the Ink Used to Write Hamlet and the Declaration of Independence

https://lithub.com/how-to-make-the-ink-used-to-write-hamlet-the-declaration-of-independence-and-b...
68•ohjeez•8h ago•28 comments

Court: 4th Amendment Disallows Use Of AI-Generated 'Probable Cause'

https://www.techdirt.com/2026/11/19/court-tells-cops-that-the-4th-amendment-doesnt-cover-ai-gener...
31•defrost•1h ago•10 comments

Adding Fortran Support to LLDB (GSoC 2026)

https://blog.llvm.org/posts/2026-09-07-gsoc-add-fortran-support-to-lldb/
32•JDevlieghere•3d ago•9 comments