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

Muse Spark 1.3

https://developer.meta.com/ai/models/muse-spark/
299•bvaldivielso•3h ago•209 comments

Gemini 3.8 Flash and 3.8 Flash Cyber

https://blog.google/innovation-and-ai/models-and-research/gemini-models/3-8-flash-and-3-8-flash-c...
762•bratao•7h ago•458 comments

Google avoids a breakup of its ad tech business

https://www.nytimes.com/2026/09/02/technology/google-ad-tech-remedies.html
194•donohoe•8h ago•109 comments

Reverse Engineering Unknown File Formats with ImHex

https://werwolv.net/posts/file_format_reverse_engineering/
62•carlos-menezes•2d ago•7 comments

Uber shuts operations in Nigeria and Uganda with immediate effect

https://www.bbc.com/news/articles/c86xpv8l9y9o
27•yakkomajuri•1h ago•8 comments

Fable 5.1 World Modeling

https://github.com/PhiloLabs/fable51-worlds
95•surreal_•3h ago•37 comments

Launch HN: RonanRX (YC S26) – Personalized Peptides and GLP-1s

https://ronanrx.com/
6•lloydarmbrust•33m ago•6 comments

Three sites made 215,128 “best software” pages for AI. Perplexity cites them

https://trellner.com/reports/manufactured-sources-behind-ai-recommendations/
272•jakobgreenfeld•9h ago•124 comments

Earth's organisms developed via evolution. What if the cosmos did, too?

https://www.smithsonianmag.com/science-nature/earths-organisms-developed-via-evolution-some-theor...
43•JulianPGough•5h ago•26 comments

Nango (YC W23) is hiring across eng, product and GTM (SF and remote)

https://nango.dev/careers
1•bastienbeurier•2h ago

Show HN: Every AI agrees with you. This writes your startup's obituary instead

https://theyfell.com/
7•kyleclouthier•23m ago•3 comments

Wendell Berry has died

https://www.nytimes.com/2026/08/31/us/wendell-berry-dead.html
118•Curiositry•1d ago•60 comments

Altair Basic Interpreter Source Code (1975) [pdf]

https://images.gatesnotes.com/12514eb8-7b51-008e-41a9-512542cf683b/34d561c8-cf5c-4e69-af47-3782ea...
35•Eridanus2•3h ago•11 comments

Can I opt out of my input or output data being used for training?

https://help.mistral.ai/en/articles/455207-can-i-opt-out-of-my-input-or-output-data-being-used-fo...
354•teekert•10h ago•154 comments

Engineering of the fastest WebAssembly interpreters

https://wasmi-labs.github.io/blog/posts/wasmi-v2.0/
19•herobird•1d ago•0 comments

Qantas Airbus A380 engine failure in 2010 (2023)

https://admiralcloudberg.medium.com/a-matter-of-millimeters-the-story-of-qantas-flight-32-bdaa62d...
61•gumby•4h ago•34 comments

Biggest dark matter detector spots a single weird particle

https://www.science.org/content/article/world-s-biggest-dark-matter-detector-spots-single-weird-p...
225•randycupertino•9h ago•72 comments

Embedded Rust RTOS vs. C RTOS

https://tweedegolf.nl/en/blog/65/async-rust-vs-rtos-showdown/
50•kooi•4h ago•21 comments

Exit the Cave

https://turtlespace.blog/p/exit-the-cave
195•akkartik•8h ago•61 comments

Commodore 64 released September 1, 1982

https://dfarq.homeip.net/commodore-64-released-september-1-1982/
315•giuliomagnifico•14h ago•163 comments

Aging brains blend memories together instead of just forgetting them

https://studyfinds.com/aging-brains-blend-memories-together-instead-of-forgetting-them-study-finds/
178•mdp2021•10h ago•83 comments

Product Backlog Problems: Why Your Hierarchy Is Broken

https://www.prodpad.com/blog/backlog-hierarchy-problem/
10•adrianhoward•2d ago•1 comments

Making the Internet Boring

https://cemrehancavdar.com/2026/08/30/making-the-internet-boring/
66•zdw•3d ago•40 comments

A Selection of Los Alamos Rolodex Business Cards

https://clui.org/collections/los-alamos-business-cards/selection-cards
130•1970-01-01•2d ago•29 comments

Show HN: OwnTime – a chess clock for your day's priorities

https://owntime.app/
16•fmos•1d ago•4 comments

I wanna live an NPC life

https://signalundefied.bearblog.dev/i-wanna-live-an-npc-life/
156•conferza•3h ago•151 comments

Mamdani Bans AI in NYC Schools

https://www.nytimes.com/2026/09/01/nyregion/ai-ban-schools-nyc.html
115•handfuloflight•2h ago•77 comments

Poisson Disk Sampling

https://stripeacross.com/posts/poisson-disk-sampling/
116•vismit2000•9h ago•17 comments

We could save petabytes of cache storage with Zstandard and Pingora

https://blog.cloudflare.com/cache-transcoding/
52•torutofu•1d ago•22 comments

A docs page is a search query to find AI agents and route them to your company

https://blog.val.town/aeo
8•stevekrouse•1d ago•1 comments