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

Shadcn/UI now defaults to Base UI instead of Radix

https://ui.shadcn.com/docs/changelog
83•dabinat•2h ago•22 comments

Command and Conquer Generals natively ported to macOS, iPhone, iPad using Fable

https://github.com/ammaarreshi/Generals-Mac-iOS-iPad/tree/main
520•asronline•11h ago•216 comments

If you're a button, you have one job

https://unsung.aresluna.org/if-youre-a-button-you-have-one-job/
140•nozzlegear•5h ago•46 comments

Mouse: Precision Editing Tools for AI Coding Agents

https://hic-ai.com
20•handfuloflight•2h ago•24 comments

GPT-5.5 Codex reasoning-token clustering may be leading to degraded performance

https://github.com/openai/codex/issues/30364
239•maille•9h ago•85 comments

Pandoc Lua Filters

https://pandoc.org/lua-filters.html
41•ankitg12•1d ago•0 comments

Megawatts by Microwave

https://computer.rip/2026-07-04-microwave-and-power.html
10•eternauta3k•1h ago•0 comments

Google Books (or similar) all book scans – $200k bounty (2025)

https://software.annas-archive.gl/AnnaArchivist/annas-archive/-/work_items/234
430•Cider9986•14h ago•234 comments

Jellyfish can heal wounds in minutes. Scientists want their secrets

https://www.mbl.edu/news/jellyfish-can-heal-wounds-minutes-scientists-want-their-secrets
97•hhs•8h ago•19 comments

Leaking YouTube creators' private videos

https://javoriuski.com/post/youtube
582•javxfps•14h ago•318 comments

Artful Cats: Feline-Inspired Art and Artifacts

https://www.si.edu/spotlight/art-cats
28•jruohonen•3d ago•4 comments

Atomic Force Microscope high-speed video, stainless etching, bacteria, and more

https://www.youtube.com/watch?v=DyIQkqBXhS0
56•mhb•2d ago•4 comments

Moby Dick Workout

https://www.hogbaysoftware.com/posts/moby-dick-workout/
23•helloplanets•3h ago•5 comments

Beeg float library, a Rust port of Fabrice Bellard's libbf

https://github.com/lifthrasiir/libbeef
14•serialx•2h ago•3 comments

The Log Is the Agent

https://arxiv.org/abs/2605.21997
25•iacguy•4h ago•1 comments

Better Models: Worse Tools

https://lucumr.pocoo.org/2026/7/4/better-models-worse-tools/
150•leemoore•11h ago•50 comments

EV Batteries Are Defying Expectations After Miles

https://www.wsj.com/business/autos/ev-batteries-are-defying-expectations-after-hundreds-of-thousa...
18•apparent•1h ago•9 comments

sqlite-utils 4.0rc2, mostly written by Claude Fable (for about $149.25)

https://simonwillison.net/2026/Jul/5/sqlite-utils-fable/
5•ognyankulev•1h ago•0 comments

Meta's Un-Stable Signature

https://hackerfactor.com/blog/index.php?/archives/1098-Metas-Un-Stable-Signature.html
69•ementally•3d ago•6 comments

Return of the Nigerian Prince Redux: Beware Book Club and Book Review Scams (2025)

https://writerbeware.blog/2025/09/19/return-of-the-nigerian-prince-redux-beware-book-club-and-boo...
43•Anon84•7h ago•10 comments

Zig: All Package Management Functionality Moved from Compiler to Build System

https://ziglang.org/devlog/2026/#2026-06-30
182•tosh•15h ago•55 comments

Potential session/cache leakage between workspace instances or consumer accounts

https://github.com/anthropics/claude-code/issues/74066
288•chatmasta•17h ago•130 comments

My ASN Journey series (2024)

https://www.animmouse.com/p/my-asn-journey/
12•antonalekseev•3h ago•1 comments

"Beyond the limit": Satellites and mirrors in space pose threat to the night sky

https://www.eso.org/public/news/eso2607/
132•Breadmaker•14h ago•219 comments

The Preemptive Draw and Preemptive Grip in the Cash-in-Transit Sector

https://gutsgatesguards.wordpress.com/2026/06/23/the-preemptive-draw-and-preemptive-grip-in-the-c...
8•stmw•4h ago•1 comments

Record-breaking solo rower Kelsey Pfendler arrives in Hawaii

https://www.hawaiinewsnow.com/2026/07/04/record-breaking-solo-rower-kelsey-pfendler-arrives-hawaii/
37•MaysonL•6h ago•3 comments

The Particle Box – Kinetic Molecular Theory Simulator

https://prepok.com/chemistry/particle-box/
8•vaibhav1312•3d ago•0 comments

Drone Autonomy Crash Course

https://www.cggonzalez.com/blog/index.html
41•cgg1•8h ago•3 comments

What ORMs have taught me: just learn SQL (2014)

https://wozniak.ca/blog/2014/08/03/1/index.html
170•ciconia•4d ago•196 comments

Efficacy and Safety of Psilocybin in Treatment-Resistant Major Depression

https://jamanetwork.com/journals/jamapsychiatry/fullarticle/2846478
28•cpncrunch•5h ago•11 comments