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

Investor-owned utilities charge 23% more for electricity than public providers

https://www.kadoa.com/energy-prices/insights/investor-owned-utilities
229•hubraumhugo•1h ago•154 comments

OpenSSL 4.1.0

https://github.com/openssl/openssl/releases/tag/openssl-4.1.0
85•petecooper•2h ago•14 comments

Phone Is About to Stop Being Yours: 70 Days Until Lockdown

https://keepandroidopen.org/?
318•NackerHughes•1h ago•172 comments

Shitter – A Nitter Fork

https://codeberg.org/shitter/shitter
84•eustoria•1h ago•36 comments

Local Wikipedia: Wikipedia, but only for things a half hour walk from you

https://edjefferson.com/localwiki/
754•sohkamyung•15h ago•153 comments

No Need for Retirement When Utopia Is Around the Corner

https://blog.jim-nielsen.com/2026/skip-retirement-for-utopia/
85•speckx•3h ago•69 comments

Disney Raising Prices Days After Confirming Ads Will Now Show Up on Every Tier

https://www.tvfandomlounge.com/disney-plus-price-hike-ads-premium-tier-nielsen-emmys-2026/
151•robtherobber•6h ago•125 comments

Swedish government offices to ban ChatGPT and Claude

https://www.sverigesradio.se/artikel/chat-gpt-och-claude-forbjuder-regeringskansliet
211•armcat•3h ago•83 comments

Docker is weird

https://codeandcake.dev/posts/2026-10-22-docker-is-weird
652•psxuaw•14h ago•270 comments

Hacker leaks 281 GB of data from Germany's far-right AfD party

https://www.bitdefender.com/en-us/blog/hotforsecurity/hacker-leaks-281-gb-data-germany-afd
79•speckx•1h ago•32 comments

Dutch government had hacked into Jared Kushner's phone

https://twitter.com/jaredkushner/status/2113376217415958767
223•teekert•4h ago•143 comments

The foolishness of "natural language programming" (1978)

https://www.cs.utexas.edu/~EWD/transcriptions/EWD06xx/EWD667.html
270•xiaoyu2006•13h ago•167 comments

The alien space of science: Coherent but cognitively unavailable directions

https://arxiv.org/abs/2603.01092
136•martincsweiss•1d ago•50 comments

Job Loss and Cortisone Mania

https://tilschuenemann.de/job-loss-cortisone-mania
60•speckx•4h ago•15 comments

Remove pgrust: the entry is cheating

https://github.com/ClickHouse/ClickBench/pull/2165
115•f311a•6h ago•61 comments

Every AI model has the same "controversial" take on humans

https://www.modelcompare.ai/blog/ai-models-controversial-take-on-humans
532•rakannimer•22h ago•526 comments

How does Fable 5.1 hide messages in images?

https://www.lesswrong.com/posts/WHEQps5PK8LrrcTAb/how-does-fable-5-1-hide-messages-in-images
155•gmays•17h ago•48 comments

Show HN: OnKey – I'm a bad singer, so I built an app to show where I'm off-key

https://github.com/dsmurrell/onkey
111•dsmurrell•1d ago•55 comments

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

https://github.com/NVIDIA/OpenShell
450•niemandhier•21h ago•202 comments

Is this the new cyber normal?

https://drew.silcock.dev/blog/is-this-the-new-cyber-normal/
111•drewsberry•3h ago•125 comments

The HTML-in-Canvas API origin trial

https://developer.chrome.com/blog/html-in-canvas-origin-trial
93•andrewstuart•18h ago•42 comments

Run full iOS 16.5 firmware on Android Devices

https://github.com/oosexgang/hackios-xnu-kernel
478•aghuang•23h ago•177 comments

Ask HN: If the models are so good, why doesn't OpenAI just start 100 companies?

297•ex-aws-dude•17h ago•325 comments

Show HN: Making a smart TV dumb and then smart

https://github.com/anubhavmalhotra/r2d2-tv
62•animalhot•14h ago•30 comments

Getting ready to operate GNU Taler in Germany

https://www.taler.net/en/news/2026-13.html
337•dewey•22h ago•152 comments

This I Believe (1952)

https://www.awakin.org/v2/read/view.php?tid=468
121•ctoth•12h ago•50 comments

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

https://simedw.com/2026/10/21/world-model-terminal/
577•alphax314•1d ago•177 comments

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

652•petecooper•1d ago•239 comments

Quad9 to exit France

https://quad9.net/news/blog/au-revoir-france/
1287•farrokhi•1d ago•444 comments

Xbox wants you to pay 24 to 40 cents per hour to stream games you bought

https://arstechnica.com/gaming/2026/10/xbox-wants-you-to-pay-24-to-40-cents-per-hour-to-stream-ga...
349•entryleveljobsc•1d ago•312 comments