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

Comments

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

Launch HN: Freestyle: Sandboxes for AI Coding Agents

https://www.freestyle.sh
80•benswerd•2h ago•43 comments

Battle for Wesnoth: open-source, turn-based strategy game

https://www.wesnoth.org
51•akyuu•58m ago•10 comments

Germany Doxes "UNKN," Head of RU Ransomware Gangs REvil, GandCrab

https://krebsonsecurity.com/2026/04/germany-doxes-unkn-head-of-ru-ransomware-gangs-revil-gandcrab/
185•Bender•4h ago•80 comments

A cryptography engineer's perspective on quantum computing timelines

https://words.filippo.io/crqc-timeline/
109•thadt•3h ago•34 comments

Sc-im: Spreadsheets in your terminal

https://github.com/andmarti1424/sc-im
69•m-hodges•2h ago•19 comments

Book review: There is no antimemetics division

https://www.stephendiehl.com/posts/no_antimimetics/
123•ibobev•4h ago•81 comments

Sky – an Elm-inspired language that compiles to Go

https://github.com/anzellai/sky
52•whalesalad•3h ago•4 comments

Claude Code is unusable for complex engineering tasks with the Feb updates

https://github.com/anthropics/claude-code/issues/42796
371•StanAngeloff•4h ago•262 comments

Reducto releases Deep Extract

https://reducto.ai/blog/reducto-deep-extract-agent
24•raunakchowdhuri•2h ago•3 comments

Adobe modifies hosts file to detect whether Creative Cloud is installed

https://www.osnews.com/story/144737/adobe-secretly-modifies-your-hosts-file-for-the-stupidest-rea...
62•rglullis•57m ago•27 comments

Show HN: GovAuctions lets you browse government auctions at once

https://www.govauctions.app/
27•player_piano•2h ago•16 comments

What being ripped off taught me

https://belief.horse/notes/what-being-ripped-off-taught-me/
221•doctorhandshake•5h ago•134 comments

Show HN: I built a tiny LLM to demystify how language models work

https://github.com/arman-bd/guppylm
781•armanified•18h ago•120 comments

The Last Quiet Thing

https://www.terrygodier.com/the-last-quiet-thing
46•coinfused•2d ago•24 comments

I won't download your app. The web version is a-ok

https://www.0xsid.com/blog/wont-download-your-app
650•ssiddharth•4h ago•352 comments

Eighteen Years of Greytrapping – Is the Weirdness Finally Paying Off?

https://nxdomain.no/~peter/eighteen_years_of_greytrapping.html
4•jruohonen•2d ago•0 comments

PostHog (YC W20) Is Hiring

1•james_impliu•5h ago

Microsoft hasn't had a coherent GUI strategy since Petzold

https://www.jsnover.com/blog/2026/03/13/microsoft-hasnt-had-a-coherent-gui-strategy-since-petzold/
726•naves•1d ago•506 comments

Gemma 4 on iPhone

https://apps.apple.com/nl/app/google-ai-edge-gallery/id6749645337
802•janandonly•23h ago•222 comments

An open-source 240-antenna array to bounce signals off the Moon

https://moonrf.com/
227•hillcrestenigma•15h ago•46 comments

81yo Dodgers fan can no longer get tickets because he doesn't have a smartphone

https://twitter.com/Suzierizzo1/status/2040864617467924865
223•josephcsible•2h ago•207 comments

France pulls last gold held in US for $15B gain

https://www.mining.com/france-pulls-last-gold-held-in-us-for-15b-gain/
492•teleforce•10h ago•268 comments

The 1987 game “The Last Ninja” was 40 kilobytes

https://twitter.com/exQUIZitely/status/2040777977521398151
243•keepamovin•15h ago•159 comments

LÖVE: 2D Game Framework for Lua

https://github.com/love2d/love
387•cl3misch•2d ago•200 comments

Signals, the push-pull based algorithm

https://willybrauner.com/journal/signal-the-push-pull-based-algorithm
137•mpweiher•2d ago•34 comments

One ant for $220: The new frontier of wildlife trafficking

https://www.bbc.com/news/articles/cg4g44zv37qo
95•gmays•4d ago•26 comments

Show HN: Real-time AI (audio/video in, voice out) on an M3 Pro with Gemma E2B

https://github.com/fikrikarim/parlor
227•karimf•1d ago•26 comments

Drop, formerly Massdrop, ends most collaborations and rebrands under Corsair

https://drop.com/
113•stevebmark•14h ago•59 comments

Running Gemma 4 locally with LM Studio's new headless CLI and Claude Code

https://ai.georgeliu.com/p/running-google-gemma-4-locally-with
377•vbtechguy•1d ago•93 comments

Sheets Spreadsheets in Your Terminal

https://github.com/maaslalani/sheets
171•_____k•2d ago•45 comments