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

Comments

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

Days since last GitHub incident

https://github-incidents.pages.dev/
141•AquiGorka•2h ago•77 comments

Rivian Unveils Custom Silicon, R2 Lidar Roadmap, and Universal Hands Free

https://riviantrackr.com/news/rivian-unveils-custom-silicon-r2-lidar-roadmap-universal-hands-free...
45•doctoboggan•44m ago•41 comments

Litestream VFS

https://fly.io/blog/litestream-vfs/
42•emschwartz•1h ago•18 comments

Programmers and software developers lost the plot on naming their tools

https://larr.net/p/namings.html
34•todsacerdoti•55m ago•26 comments

GPT-5.2

https://openai.com/index/introducing-gpt-5-2/
93•meetpateltech•49m ago•27 comments

Craft software that makes people feel something

https://rapha.land/craft-software-that-makes-people-feel-something/
128•lukeio•5h ago•58 comments

GPT-5.2

https://platform.openai.com/docs/guides/latest-model
143•atgctg•56m ago•93 comments

Show HN: SIM – Apache-2.0 n8n alternative

https://github.com/simstudioai/sim
10•waleedlatif1•1h ago•0 comments

An Orbital House of Cards: Frequent Megaconstellation Close Conjunctions

https://arxiv.org/abs/2512.09643
62•rapnie•3h ago•32 comments

Things I want to say to my boss

https://www.ithoughtaboutthatalot.com/2025/the-things-i-want-to-say-to-my-boss
164•casca•2h ago•126 comments

Launch HN: BrowserBook (YC F24) – IDE for deterministic browser automation

40•cschlaepfer•3h ago•18 comments

Size of Life

https://neal.fun/size-of-life/
2414•eatonphil•1d ago•268 comments

Show HN: I've asked Claude to improve codebase quality 200 times

https://gricha.dev/blog/the-highest-quality-codebase
266•Gricha•2d ago•205 comments

Going Through Snowden Documents, Part 1

https://libroot.org/posts/going-through-snowden-documents-part-1/
4•libroot•9m ago•0 comments

Auto-grading decade-old Hacker News discussions with hindsight

https://karpathy.bearblog.dev/auto-grade-hn/
530•__rito__•1d ago•232 comments

Show HN: Local Privacy Firewall-blocks PII and secrets before ChatGPT sees them

https://github.com/privacyshield-ai/privacy-firewall
83•arnabkarsarkar•2d ago•32 comments

A “frozen” dictionary for Python

https://lwn.net/SubscriberLink/1047238/25c270b077849dc0/
164•jwilk•9h ago•113 comments

Prove It All Night: With no fame or fortune, what keeps a band onstage? (1999)

https://chicagoreader.com/news/prove-it-all-night/
7•NaOH•1w ago•0 comments

Getting a Gemini API key is an exercise in frustration

https://ankursethi.com/blog/gemini-api-key-frustration/
758•speckx•22h ago•291 comments

Oldest attestation of Austronesian language: Đông Yên Châu inscription

https://en.wikipedia.org/wiki/%C4%90%C3%B4ng_Y%C3%AAn_Ch%C3%A2u_inscription
48•teleforce•5d ago•9 comments

Kicking Robots

https://harpers.org/archive/2025/12/kicking-robots-james-vincent-humanoids/
19•Hooke•4d ago•1 comments

Patterns.dev

https://www.patterns.dev/
502•handfuloflight•17h ago•113 comments

Show HN: GPULlama3.java Llama Compilied to PTX/OpenCL Now Integrated in Quarkus

13•mikepapadim•3h ago•1 comments

Giant of the Attic: On the Majesty of Alan Moore

https://www.metropolitanreview.org/p/giant-of-the-attic
11•CharlesW•1w ago•2 comments

Helldivers 2 on-disk size 85% reduction

https://store.steampowered.com/news/app/553850/view/491583942944621371
185•SergeAx•1w ago•177 comments

Pop Goes the Population Count?

https://xania.org/202512/11-pop-goes-the-weasel-er-count
31•hasheddan•4h ago•6 comments

The Cost of a Closure in C

https://thephd.dev/the-cost-of-a-closure-in-c-c2y
164•ingve•11h ago•63 comments

Disney making $1B investment in OpenAI, will allow characters on Sora AI

https://www.cnbc.com/2025/12/11/disney-openai-sora-characters-video.html
290•tiahura•4h ago•236 comments

How the Brain Parses Language

https://www.quantamagazine.org/the-polyglot-neuroscientist-resolving-how-the-brain-parses-languag...
101•mylifeandtimes•3d ago•53 comments

Booting Linux in QEMU and Writing PID 1 in Go to Illustrate Kernel as Program

https://serversfor.dev/linux-inside-out/the-linux-kernel-is-just-a-program/
235•birdculture•1w ago•72 comments