frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

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•11mo ago

Comments

castratikron•11mo 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•11mo 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•11mo 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•11mo 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•11mo 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•11mo ago
in CPU's - pipelining!
jchw•11mo 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...)

God Sleeps in the Minerals

https://wchambliss.wordpress.com/2026/03/03/god-sleeps-in-the-minerals/
226•speckx•3h ago•58 comments

Open Source Isn't Dead. Cal.com Just Learned the Wrong Lesson

https://www.strix.ai/blog/cal-com-is-closing-its-code-due-to-ai-threats
46•bearsyankees•48m ago•19 comments

Want to Write a Compiler? Just Read These Two Papers (2008)

https://prog21.dadgum.com/30.html
329•downbad_•6h ago•100 comments

Good Sleep, Good Learning (2012)

https://super-memory.com/articles/sleep.htm
239•downbad_•7h ago•116 comments

The Future of Everything Is Lies, I Guess: New Jobs

https://aphyr.com/posts/419-the-future-of-everything-is-lies-i-guess-new-jobs
146•aphyr•2h ago•88 comments

Your Backpack Got Worse on Purpose

https://www.worseonpurpose.com/p/your-backpack-got-worse-on-purpose
230•113•5h ago•196 comments

Gemini Robotics-ER 1.6

https://deepmind.google/blog/gemini-robotics-er-1-6/
101•markerbrod•2h ago•24 comments

Costasiella kuroshimae – Solar Powered animals, that do indirect photosynthesis

https://en.wikipedia.org/wiki/Costasiella_kuroshimae
101•vinnyglennon•3d ago•42 comments

Do you even need a database?

https://www.dbpro.app/blog/do-you-even-need-a-database
54•upmostly•4h ago•90 comments

Wacli – WhatsApp CLI

https://github.com/steipete/wacli
185•dinakars777•9h ago•127 comments

Fixing a 20-year-old bug in Enlightenment E16

https://iczelia.net/posts/e16-20-year-old-bug/
223•snoofydude•11h ago•119 comments

How do Wake-On-LAN works

https://blog.xaner.dev/post/wake-on-lan/
4•swq115•4d ago•0 comments

Metro stop is Ancient Rome's new attraction

https://www.bbc.com/travel/article/20260408-a-150-metro-ticket-to-ancient-rome
76•Stevvo•5d ago•16 comments

We ran Doom on a 40 year old printer controller (Agfa Compugraphic 9000PS) [video]

https://www.youtube.com/watch?v=cltnlks2-uU
29•zdw•3d ago•5 comments

Proliferate (YC S25) Is Hiring Founding Engineers

https://www.ycombinator.com/companies/proliferate/jobs/L3copvK-founding-engineer
1•pablo24602•4h ago

Show HN: Every CEO and CFO change at US public companies, live from SEC

https://tracksuccession.com/explore
121•porsche959•3h ago•50 comments

Google Gemma 4 Runs Natively on iPhone with Full Offline AI Inference

https://www.gizmoweek.com/gemma-4-runs-iphone/
203•takumi123•11h ago•132 comments

Pretty Fish: A better mermaid diagram editor

https://pretty.fish/
64•pastelsky•5d ago•14 comments

Forcing an Inversion of Control on the SaaS Stack

https://www.100x.bot/a/client-side-injection-inversion-of-control-saas
10•shardullavekar•4d ago•7 comments

Anna's Archive loses $322M Spotify piracy case without a fight

https://torrentfreak.com/annas-archive-loses-322-million-spotify-piracy-case-without-a-fight/
90•askl•8h ago•82 comments

Academic fraud may be the symptom of a more systemic problem

https://www.voxweb.nl/en/academic-fraud-may-be-the-symptom-of-a-much-more-systemic-problem
34•the-mitr•5h ago•32 comments

US v. Heppner (S.D.N.Y. 2026) no attorney-client privilege for AI chats [pdf]

https://fingfx.thomsonreuters.com/gfx/legaldocs/xmvjyjekkpr/Rakoff%20-%20order%20-%20AI.pdf
62•1vuio0pswjnm7•2h ago•39 comments

Elevated errors on Claude.ai, API, Claude Code

https://claudestatus.com/
187•redm•1h ago•160 comments

Study: Back-to-basics approach can match or outperform AI in language analysis

https://www.manchester.ac.uk/about/news/back-to-basics-approach-can-match-or-outperform-ai/
15•giuliomagnifico•4h ago•7 comments

AI ruling prompts warnings from US lawyers: Your chats could be used against you

https://www.reuters.com/legal/government/ai-ruling-prompts-warnings-us-lawyers-your-chats-could-b...
75•alephnerd•3h ago•43 comments

H.R.8250 – To require operating system providers to verify the age of any user

https://www.congress.gov/bill/119th-congress/house-bill/8250/all-info
155•cft•18h ago•92 comments

Dependency cooldowns turn you into a free-rider

https://calpaterson.com/deps.html
165•pabs3•14h ago•111 comments

New Modern Greek

https://redas.dev/NewModernGreek/
7•holoflash•2d ago•9 comments

MIT Radiation Laboratory

https://www.ll.mit.edu/about/history/mit-radiation-laboratory
34•stmw•3d ago•8 comments

My adventure in designing API keys

https://vjay15.github.io/blog/apikeys/
95•vjay15•3d ago•70 comments