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

Apple introduces M6 and M5 Ultra

https://www.apple.com/newsroom/2026/08/apple-introduces-m6-and-m5-ultra-for-a-big-leap-in-perform...
1033•interpol_p•16h ago•953 comments

FDA authorizes first wearable device that monitors ketone and blood sugar levels

https://www.fda.gov/news-events/press-announcements/fda-authorizes-first-wearable-device-continuo...
326•sunnynagra•10h ago•159 comments

OpenAI Jalapeño: Better than Nvidia Blackwell

https://newsletter.semianalysis.com/p/openai-jalapeno-better-than-nvidia
389•bmulholland•15h ago•256 comments

New Mac Studio with M5 Max and M5 Ultra

https://www.apple.com/newsroom/2026/08/apple-introduces-new-mac-studio-with-m5-max-and-m5-ultra/
728•interpol_p•16h ago•481 comments

Queryable Executables

https://fzakaria.com/2026/08/24/actually-queryable-executables
59•rguiscard•4h ago•7 comments

Black hole singularity is a surface not a point

https://arxiv.org/abs/2608.21590
214•raattgift•12h ago•152 comments

Maiao: Gerrit-style code review workflow for GitHub, GitLab, Gitea, others

https://github.com/runetes/maiao
49•zdw•6h ago•19 comments

New Mac mini, featuring M6 and M5 Pro

https://www.apple.com/newsroom/2026/08/apple-unveils-a-more-powerful-mac-mini-featuring-the-all-n...
458•runako•15h ago•282 comments

When str.lower() is a security vulnerability in Python – Seth Larson

https://sethmlarson.dev/when-str-lower-is-a-security-vulnerability
89•rbanffy•8h ago•39 comments

C2PA Cameras Do Not Survive Contact with Reality

https://www.da.vidbuchanan.co.uk/blog/android-c2pa.html
109•Retr0id•9h ago•58 comments

Agentic Context Management: Memory and Cost as Architecture Problems

https://arxiv.org/abs/2607.21503
12•gdad•2h ago•3 comments

Nitter and XCancel receive cease and desist notices

https://github.com/zedeus/nitter/issues/1442
729•Banditoz•11h ago•623 comments

Show HN: TeXbrain, a LaTeX editor that runs pdfTeX in the browser via WASM

https://github.com/swimmingbrain/texbrain
71•swimmingbrain•6h ago•12 comments

Building a backyard office, the build and cost breakdown

https://www.imkylelambert.com/articles/building-a-backyard-office-the-build-and-cost-breakdown
296•surprisetalk•14h ago•202 comments

Run OpenBSD on DigitalOcean for $4/month

https://nil.wallyjones.com/run-openbsd-on-digitalocean-for-4month/
138•speckx•11h ago•65 comments

Bomb fishing is wreaking havoc on Indonesia's coral reefs

https://e360.yale.edu/digest/bomb-fishing-coral-reefs
290•speckx•14h ago•147 comments

Tooltips need a delay, and then they need to skip it

https://blog.master.dev/tooltips-need-a-delay-and-then-they-need-to-skip-it/
134•ibobev•12h ago•34 comments

Show HN: LatticeDB – Like SQLite but for graph databases

https://github.com/jeffhajewski/latticedb
129•smiths1999•12h ago•36 comments

Don't Wordle

https://dontwordle.com/
324•Hbruz0•17h ago•117 comments

Show HN: I made a Raspberry with Qwen my local car AI

https://github.com/ThinkOffApp/CarWatch
118•petruspennanen•13h ago•31 comments

Dolly Parton has died

https://www.theguardian.com/music/2026/aug/25/dolly-parton-country-singer-dead
1335•helsinkiandrew•11h ago•201 comments

My Friend Aaron

https://rorz.io/writing/my-friend-aaron
491•sarreph•12h ago•133 comments

A brief history of federal lift ticket regulation

https://zakpodmore.substack.com/p/a-brief-history-of-federal-lift-ticket
50•CGMthrowaway•9h ago•6 comments

Firefox 157 will include JPEG XL by default on all platforms

https://groups.google.com/a/mozilla.org/g/dev-platform/c/3YMV4MS34KA?pli=1
318•yboris•11h ago•86 comments

Visualizing Binary Files

https://movq.de/blog/postings/2026-08-05/0/POSTING-en.html
93•zdw•1d ago•17 comments

Tracking Costco gas prices

https://www.jack.bio/blog/costco-gas-tracking
96•lafond•1d ago•98 comments

Show HN: I built self-hosted deployment automation tool for Windows and IIS

https://fdeploy.com/
27•dt3ft•21h ago•13 comments

The brain may be about to have its Ozempic moment

https://www.economist.com/science-and-technology/2026/08/11/the-brain-may-be-about-to-have-its-oz...
66•Anon84•4h ago•48 comments

Clara (YC P26) is hiring a growth engineer to bring AI doctors to market

https://www.ycombinator.com/companies/clara-2/jobs/8snci6k-founding-full-stack-growth-engineer
1•gfavvas•11h ago

Starbase, LA

https://www.spacex.com/sites/starbase-la
249•bilsbie•12h ago•451 comments