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

Media scraper Gallery-dl is moving to Codeberg after receiving a DMCA notice

https://github.com/mikf/gallery-dl/discussions/9304
85•MoltenMonster•1h ago•26 comments

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

https://github.com/arman-bd/guppylm
200•armanified•4h ago•14 comments

Gemma 4 on iPhone

https://apps.apple.com/nl/app/google-ai-edge-gallery/id6749645337
511•janandonly•10h ago•133 comments

Show HN: YouTube search barely works, I made a search form with advanced filters

https://playlists.at/youtube/search/
140•nevernothing•4h ago•93 comments

Copilot is 'for entertainment purposes only', per Microsoft's terms of use

https://techcrunch.com/2026/04/05/copilot-is-for-entertainment-purposes-only-according-to-microso...
98•airstrike•5h ago•18 comments

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

https://moonrf.com/
25•hillcrestenigma•1h ago•3 comments

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/
302•naves•11h ago•172 comments

LÖVE: 2D Game Framework for Lua

https://github.com/love2d/love
243•cl3misch•1d ago•97 comments

The 1987 game "The Last Ninja" was 40 kilobytes

https://twitter.com/exQUIZitely/status/2040777977521398151
23•keepamovin•2h ago•9 comments

Eight years of wanting, three months of building with AI

https://lalitm.com/post/building-syntaqlite-ai/
709•brilee•16h ago•218 comments

Artemis II crew see first glimpse of far side of Moon [video]

https://www.bbc.com/news/videos/ce3d5gkd2geo
453•mooreds•14h ago•348 comments

Show HN: Gemma Gem – AI model embedded in a browser – no API keys, no cloud

https://github.com/kessler/gemma-gem
37•ikessler•4h ago•4 comments

Endian wars and anti-portability: this again?

https://dalmatian.life/2026/04/03/endian-wars-and-anti-portability-this-again/
35•awilfox•1d ago•39 comments

Winners of the 2026 Kokuyo Design Awards

https://spoon-tamago.com/winners-of-the-2026-kokuyo-design-awards/
9•zdw•1h ago•0 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
226•vbtechguy•11h ago•56 comments

Case study: recovery of a corrupted 12 TB multi-device pool

https://github.com/kdave/btrfs-progs/issues/1107
16•salt4034•2h ago•0 comments

Show HN: Modo – I built an open-source alternative to Kiro, Cursor, and Windsurf

https://github.com/mohshomis/modo
29•mohshomis•5h ago•2 comments

Employers use your personal data to figure out the lowest salary you'll accept

https://www.marketwatch.com/story/employers-are-using-your-personal-data-to-figure-out-the-lowest...
138•thisislife2•4h ago•60 comments

We replaced Node.js with Bun for 5x throughput

https://trigger.dev/blog/firebun
22•pier25•3h ago•7 comments

Rendering arbitrary-scale emojis using the Slug algorithm

https://leduyquang753.name.vn/blog/2026/4/4/rendering-arbitrary-scale-emojis-using-the-slug-algor...
5•leduyquang753•1d ago•0 comments

Why Switzerland has 25 Gbit internet and America doesn't

https://sschueller.github.io/posts/the-free-market-lie/
331•sschueller•10h ago•262 comments

In Japan, the robot isn't coming for your job; it's filling the one nobody wants

https://techcrunch.com/2026/04/05/japan-is-proving-experimental-physical-ai-is-ready-for-the-real...
142•rbanffy•6h ago•163 comments

Music for Programming

https://musicforprogramming.net
131•merusame•10h ago•60 comments

Sheets Spreadsheets in Your Terminal

https://github.com/maaslalani/sheets
24•_____k•1d ago•6 comments

Usenet Archives

https://usenetarchives.com
9•myth_drannon•3h ago•1 comments

The Mechanics of Steins Gate (2023) [pdf]

https://github.com/Votuko/steins-gate-mechanics/blob/main/The%20Mechanics%20of%20Steins%20Gate%20...
61•Ariarule•7h ago•12 comments

Computational Physics (2nd Edition) (2025)

https://websites.umich.edu/~mejn/cp2/
121•teleforce•13h ago•17 comments

A tail-call interpreter in (nightly) Rust

https://www.mattkeeter.com/blog/2026-04-05-tailcall/
140•g0xA52A2A•13h ago•25 comments

Wavelets on Graphs via Spectral Graph Theory (2009)

https://arxiv.org/abs/0912.3848
33•dedalus•5d ago•4 comments

Stamp It All Programs Must Report Their Version – Michael Stapelberg

https://michael.stapelberg.ch/posts/2026-04-05-stamp-it-all-programs-must-report-their-version/
8•gurjeet•3h ago•1 comments