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

Someone behind the software

https://karrisaarinen.com/posts/someone-behind-the-software/
151•tosh•3h ago•57 comments

RepRapMicron

https://github.com/VikOlliver/RepRapMicron/wiki
274•RobotToaster•6h ago•38 comments

Free Pascal Compiler Now Supports Dynamic Packages

https://www.getlazarus.org/dynamic/
26•sysrpl•1h ago•5 comments

Investing in the Public Benefit

https://www.anthropic.com/news/public-benefit-fund
27•surprisetalk•1h ago•24 comments

Personal software factories are a waste of time

https://www.peterp.me/articles/personal-software-factories-are-a-waste-of-time/
20•thegreatpeter•56m ago•15 comments

PalmOS Lemmings by Aaron Ardiri

https://github.com/ardiri/palmos-lemmings
28•memalign•2h ago•5 comments

Mitos editor is a fork of Helix

https://mitos.computer/
46•ambigious7777•2h ago•39 comments

Java sealed classes and exhaustive pattern matching

https://neilmadden.blog/2026/04/24/java-sealed-classes-and-exhaustive-pattern-matching/
99•hnisjafx40•5h ago•61 comments

The Intel 8087 chip: floating-point addition and subtraction

https://www.righto.com/2026/10/8087-addition-subtraction-microcode.html
61•pwg•3h ago•10 comments

Sigsaly: Churchill's top secret hotline to the President

https://www.iwm.org.uk/history/iwm/cwr/telephone
73•stmw•3d ago•9 comments

DeepSeek search and fetch – $0.75 per 1000 successful requests

https://api-docs.deepseek.com/guides/search/
476•fagnerbrack•13h ago•232 comments

Legal experts warn Meta's new terms still grant broad scraping permissions

https://www.niemanlab.org/2026/10/legal-experts-warn-metas-new-terms-still-grant-broad-scraping-p...
203•DeepLogin•9h ago•58 comments

Show HN: The Zelda timeline to catch up before the Ocarina of Time remake

https://legendofhyrule.com/
124•jsomau•6h ago•65 comments

HOA's are making the home crisis worse

https://hoaspy.com/hoa/fl/florida-hoa-housing-crisis.html
93•lovewins•1h ago•122 comments

Beyond Tetris: The Other Games of Alexey Pajitnov [video]

https://www.youtube.com/watch?v=QH_LPimUJMs
31•zdw•20h ago•0 comments

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

https://github.com/0x23/MicroManipulatorStepper
145•_Microft•8h ago•11 comments

I Electrified My Push Scooter with a Power Drill

https://eddieabbondanz.io/post/shop/drill-powered-scooter/
52•speckx•4d ago•22 comments

Namecheap just seized and disabled all my domains

https://www.reddit.com/r/sysadmin/comments/1x8cycd/namecheap_just_seized_and_disabled_all_my_doma...
155•sashk•3h ago•89 comments

US threatens Europe over Starlink restrictions

https://www.ft.com/content/d1e28d93-8574-4a46-946a-b261c401d6fa
17•mraniki•34m ago•9 comments

How the Elizabeth Holmes documentary “You Can See Everything” is deceiving

https://www.readtheprofile.com/p/elizabeth-holmes-documentary-you-can-see-everything
321•MaysonL•16h ago•432 comments

Parser Combinators

https://t3.at/blog/2026-10-17-parser-combinators/
194•schindlabua•11h ago•74 comments

Geographical Fun: Being Humourous Outlines of Various Countries (1868)

https://publicdomainreview.org/collection/geographical-fun-being-humourous-outlines-of-various-co...
5•Thevet•1d ago•0 comments

Will it be a golden age or a dark age for mathematics (and science)?

https://terrytao.wordpress.com/2026/10/18/will-it-be-a-golden-age-or-a-dark-age-for-mathematics-a...
102•smilelamp•4h ago•133 comments

CFPB Opens Debanking Investigation into Nine Large National Banks

https://www.forbes.com/sites/ajdhaliwal/2026/10/16/cfpb-opens-debanking-investigation-into-nine-l...
19•iamnothere•1h ago•7 comments

Teal – A statically-typed dialect of Lua

https://teal-language.org/
137•Lyngbakr•1d ago•60 comments

CKKS – Addition and Multiplication

https://www.jeremykun.com/2026/10/11/ckks-addition-and-multiplication/
6•ibobev•2d ago•0 comments

macOS 15.8.2 Breaks OpenGL

https://developer.apple.com/forums/verify-human/verify.html?next=/forums/thread/850550
216•Audiophilip•4h ago•212 comments

The Electronic Disturbance Theater and Electronic Civil Disobedience (1998)

https://www.thing.net/~rdom/ecd/EDTECD.html
28•jruohonen•6h ago•7 comments

Show HN: Sphinx – A hook that quizzes you on your AI's code before shipping

https://sphinx-six-theta.vercel.app/
224•critiquebrowser•15h ago•76 comments

Voyage of the Paper Canoe: 2500 Miles from Quebec to the Gulf of Mexico, 1874-5

http://www.ibiblio.org/eldritch/nhb/paperc/intro.html
23•Eridanus2•3d ago•5 comments