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

Semaglutide linked to 26% lower 5-year predicted dementia risk

https://alz-journals.onlinelibrary.wiley.com/doi/10.1002/dad2.70432
218•randycupertino•4h ago•146 comments

AI Isn't Outthinking Mathematicians. It's Out-Remembering Them

https://davidepiffer.com/p/ai-isnt-outthinking-mathematicians
217•rzk•2h ago•186 comments

So How Is AI Drug Discovery Doing, Really?

https://www.science.org/content/blog-post/so-how-ai-drug-discovery-doing-really
29•AnodicElegy•1h ago•15 comments

The First At-Home Test for Infected Ticks Could Improve Lyme Disease Diagnosis

https://www.smithsonianmag.com/innovation/the-first-at-home-test-for-infected-ticks-could-improve...
156•gmays•6h ago•54 comments

First human trials of designer protein therapies stun US neuroscientists

https://cen.acs.org/biological-chemistry/biotechnology/human-trial-chemogenetic-brain-therapy/104...
17•gradus_ad•1h ago•28 comments

Auto-research with codex: How I achieved a 232x Faster Kernel

https://sankalp.bearblog.dev/autoresearch/
322•tosh•9h ago•82 comments

RISC-V: They Should Have Known Better

https://dmitry.gr/?r=06.%20Thoughts&proj=12.%20RV
139•dmitrygr•1d ago•257 comments

A Spectre Is Haunting Unicode

https://www.dampfkraft.com/ghost-characters.html
100•sensanaty•5h ago•23 comments

Working with AI Feels More Like Leadership Than Coding

https://allen.bargi.org/notes/working-with-ai-feels-like-leadership/
204•allenb•9h ago•144 comments

Voltair (YC W26) Is Hiring a Test Flight Engineer

https://www.ycombinator.com/companies/voltair/jobs/sSOD2Ox-flight-test-engineer
1•wweissbluth•1h ago

Could a computer scientist build a brain?

https://stankerstjens.github.io/could-a-computer-scientist-build-a-brain/
65•ogundipeore•6h ago•36 comments

2D Gaussian Splatting for Bézier Spline Line Art Vectorization

https://studios.disneyresearch.com/2026/07/16/2d-gaussian-splatting-for-bezier-spline-line-art-ve...
42•Jimmc414•19h ago•4 comments

A controversial Alzheimer's surgery is said to reverse symptoms

https://www.nature.com/articles/d41586-026-02448-x
113•jeffreyrogers•3h ago•41 comments

The mathematical beauty of hyperbezier curves

https://linebender.org/blog/hyperbezier/
153•raphlinus•5d ago•21 comments

Show HN: Eigendrum - Draw any shape and hear what it sounds like as a drum

https://baselashraf81.github.io/eigendrum/
156•BaselAshraf81•5d ago•81 comments

BriskDB

https://github.com/schapman1974/briskdb
12•schapman1974•2h ago•2 comments

The other Sean Byrne doesn't exist

https://conic.al/writing/the-other-sean-byrne-doesnt-exist/
343•rdl•15h ago•170 comments

The Dutch Community Where People Live on Strips of Land in a Lake

https://www.core77.com/posts/144869
61•Bowes-Lyon•3h ago•33 comments

Printytron – Type it. 3D Print it

https://printytron.com
29•statenjason•5h ago•1 comments

Going Dark, and the era of law enforcement hacking

https://blog.cryptographyengineering.com/2026/08/14/everything-is-about-to-go-dark/
438•vslira•23h ago•233 comments

Pizza Box Project Stack

https://cblgh.org/posts/2026-07-31-pizza-box-project-stack/
3•surprisetalk•4d ago•0 comments

Yadda 3.0.0: BDD in the Age of AI Agents

http://www.stephen-cresswell.com/2026/08/15/Yadda-3.0.0-BDD-in-the-Age-of-AI-Agents.html
46•scresswell•6h ago•24 comments

The Color of White Light

https://ludens.cl/photo/spectra/spectra.html
75•xk3•4d ago•40 comments

Using GCC's Nested Functions with Wide Pointers and No Trampolines II

https://uecker.codeberg.page/2026-07-14.html
77•uecker•12h ago•42 comments

Thunderbird's Desktop Calendar Visual Redesign

https://blog.thunderbird.net/2026/08/desktop-calendar-a-design-journey/
25•birdculture•2h ago•6 comments

In 1962, Egypt's Missile Program Lost Its Key Scientist Without a Trace

https://www.popularmechanics.com/military/a73358518/nazi-rocket-scientist-disappearance/
110•bookofjoe•3d ago•69 comments

Möbius Strips and Differential Equations

https://hidden-phenomena.com/articles/monodromy
52•mbustamanter•5d ago•9 comments

Qwen 3.8 27B

https://huggingface.co/Qwen/Qwen3.8-27B-FP8
1331•erdaltoprak•1d ago•758 comments

Robot Videos: Heavy Lift Cargo Drones, Grippers, More

https://spectrum.ieee.org/video-friday-heavy-lift-drone
7•rbanffy•5d ago•0 comments

Firefox is now the last major browser that still supports uBlock Origin

https://www.pcworld.com/article/3212428/firefox-is-now-the-last-major-browser-that-still-supports...
1608•DemiGuru•1d ago•609 comments