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

Mag 7 starting to underperform [pdf]

https://www.apollo.com/content/dam/apolloaem/pdf/daily-spark/2026/jun/28/062826-Mag7.pdf
54•mooreds•50m ago•22 comments

RocketLab Acquires Iridium

https://investors.rocketlabcorp.com/news-releases/news-release-details/rocket-lab-acquire-iridium...
22•everfrustrated•54m ago•3 comments

Building Principia for Windows XP

https://voxelmanip.se/2026/06/28/building-principia-for-windows-xp/
42•LorenDB•1h ago•4 comments

What happens when you run a CUDA kernel?

https://fergusfinn.com/blog/what-happens-when-you-run-a-gpu-kernel/
40•mezark•1h ago•3 comments

Sandia National Labs SA3000 8085 CPU

https://www.cpushack.com/2026/06/03/sandia-national-labs-sa3000-8085-cpu/
94•rbanffy•4h ago•25 comments

Tidal AI Policy

https://tidal.com/ai-policy
141•hn8726•1h ago•155 comments

HackerRank open sourced its ATS. My resume scored 90/100. Oh wait 74. No – 88

https://danunparsed.com/p/hackerrank-open-source-ats
752•sambellll•13h ago•317 comments

GLM 5.2 beats Claude in our benchmarks

https://semgrep.dev/blog/2026/we-have-mythos-at-home-glm-52-beats-claude-in-our-cyber-benchmarks/
1004•jms703•21h ago•466 comments

Instagram is incorporating users' photos in ads for Meta Glasses

https://twitter.com/i/status/2071277885646868536
76•notRobot•1h ago•18 comments

Halvar's Guide to Entrepreneurship

https://thomasdullien.github.io/guides/entrepreneurship/
92•nekitamo•3d ago•24 comments

Type-checked non-empty strings

https://exploring-better-ways.bellroy.com/haskell-koan-type-checked-non-empty-strings.html
30•surprisetalk•2d ago•10 comments

Rebuilding the Computer Room

https://alexwlchan.net/2026/computer-room/
38•ingve•3h ago•15 comments

Pollen tried to remove my article and Google is assisting with it

https://blog.pragmaticengineer.com/pollen-tried-to-remove-my-article-about-callum-negus-fancey-an...
575•taubek•5h ago•81 comments

I Am Behind on C# 14 Features, and I Can't Prove It but Does It Matter?

https://medium.com/c-sharp-programming/i-am-behind-on-csharp-14-features-and-i-cant-prove-it-but-...
4•sukhpinder0804•3d ago•1 comments

Studio Canal Movies purchased on PlayStation Store removed without refund

https://www.playstation.com/en-gb/legal/psvideocontent/
51•kugelblitz•1h ago•15 comments

A field guide to the modern front end for developers who hand-wrote HTML

https://davidpoblador.com/deep-dives/the-descent/
32•nirvanis•39m ago•19 comments

How we made WINDOW JOIN parallel and vectorized

https://questdb.com/blog/window-join-parallel-vectorized/
13•tosh•3d ago•0 comments

Samsung, SK Hynix, Micron Sued in US over Memory Price Fixing

https://en.sedaily.com/international/2026/06/29/samsung-sk-hynix-micron-sued-in-us-over-memory-pr...
89•donohoe•3h ago•31 comments

NUMA: Cores, memory, and the distance between them

https://edera.dev/stories/numa-part-1-cores-memory-and-the-distance-between-them
82•sys_call•4d ago•14 comments

Dissecting Apple's Sparse Image Format (ASIF)

https://schamper.dev/dissecting-apples-sparse-image-format-asif/
122•supermatou•22h ago•18 comments

Age verification is just a precursor to automated attribution of speech

https://nonogra.ph/age-verification-is-just-a-precursor-to-attribution-of-speech-06-29-2026
766•arkhiver•11h ago•467 comments

Data breach exposes up to 14.2M email logins at six ISPs

https://www.bleepingcomputer.com/news/security/data-breach-exposes-up-to-142-million-email-logins...
12•Brajeshwar•35m ago•0 comments

Federating Clusters for Zero-Downtime Kubernetes

https://linkerd.io/2026/06/24/federating-clusters-for-zero-downtime-kubernetes/index.html
22•PagCatOli•4d ago•1 comments

Herdr: Agent multiplexer that lives in your terminal

https://github.com/ogulcancelik/herdr
109•mzehrer•10h ago•72 comments

Historical memory prices 1960-2026

https://dam.stanford.edu/memory-prices.html
364•vga1•20h ago•139 comments

We found a bug in the hyper HTTP library

https://blog.cloudflare.com/hyper-bug/
127•Pop_-•4d ago•60 comments

5k menus from the New York Public Library’s Buttolph Collection (1880-1920)

https://pudding.cool/2026/06/menu-story/
393•xbryanx•1d ago•103 comments

I used Claude Code to get a second opinion on my MRI

https://antoine.fi/mri-analysis-using-claude-code-opus
514•engmarketer•22h ago•642 comments

1.38 Millimeter Microcontroller

https://www.ti.com/product/MSPM0C1104
28•kristianpaul•2d ago•55 comments

Why did this journal retract two 1940s papers by Max Planck?

https://arstechnica.com/science/2026/06/why-did-this-journal-retract-two-1940s-papers-by-max-planck/
193•DR_MING•6h ago•22 comments