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

Scientists reverse brain aging, with a nasal spray

https://stories.tamu.edu/news/2026/04/14/scientists-reverse-brain-aging-with-a-nasal-spray/
113•cybermango•1h ago•40 comments

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

https://github.com/ammaarreshi/Generals-Mac-iOS-iPad/tree/main
347•asronline•5h ago•140 comments

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

https://github.com/openai/codex/issues/30364
135•maille•3h ago•44 comments

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

https://software.annas-archive.gl/AnnaArchivist/annas-archive/-/work_items/234
328•Cider9986•8h ago•166 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
30•hhs•2h ago•4 comments

Leaking YouTube creators' private videos

https://javoriuski.com/post/youtube
471•javxfps•8h ago•264 comments

Better Models: Worse Tools

https://lucumr.pocoo.org/2026/7/4/better-models-worse-tools/
85•leemoore•5h ago•27 comments

Explanation of everything you can see in htop/top on Linux (2019)

https://peteris.rocks/blog/htop/
389•theanonymousone•13h ago•52 comments

Potential session/cache leakage between workspace instances or consumer accounts

https://github.com/anthropics/claude-code/issues/74066
269•chatmasta•11h ago•127 comments

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

https://ziglang.org/devlog/2026/#2026-06-30
137•tosh•9h ago•26 comments

Verizon is About to Break our Watches

https://www.jefftk.com/p/verizon-is-about-to-break-our-watches
134•jefftk•7h ago•78 comments

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

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

Can you build a recognizable World Map in under 500 bytes?

https://www.experimentlog.com/blog/building-a-world-map-with-only-500-bytes
21•iweczek•3d ago•22 comments

My AI-built PHP engine in Rust passes 17% of PHP-src tests, renders WordPress

https://ekinertac.com/blog/i-dont-know-rust-my-ai-is-rewriting-php-in-it/
22•ekinertac•3h ago•24 comments

Drone Physics

https://iahmed.me/post/drone-physics/
79•wrxd•4d ago•23 comments

Reflections on the Guillotine

https://theanarchistlibrary.org/library/albert-camus-reflections-on-the-guillotine
6•halperter•1h ago•0 comments

Windows CE Dreamcast Community Edition (wince-dc)

https://github.com/maximqaxd/wince-dc
91•msephton•10h ago•17 comments

It's not me, it's the compiler

https://parsa.wtf/cast/
55•SVI•3d ago•10 comments

Astrophysicists Puzzle over Webb’s New Universe

https://www.quantamagazine.org/astrophysicists-puzzle-over-webbs-new-universe-20260702/
193•jnord•16h ago•120 comments

Protocol Prying: Vulnerability Research in AirDrop and Quick Share

https://arxiv.org/abs/2606.26967
11•logickkk1•4h ago•1 comments

The Vespa at 80

https://www.cbc.ca/news/world/vespa-italy-postwar-design-9.7252641
145•cf100clunk•3d ago•135 comments

Egg consumption inversely correlated with Alzheimer's

https://pubmed.ncbi.nlm.nih.gov/42002260/
14•natbennett•42m ago•2 comments

Zo Computer

https://www.zo.computer
8•erhuve•1h ago•6 comments

Fable created novel 4D splat format

https://adamraudonis.github.io/splats4D/
108•adamraudonis•9h ago•39 comments

BareMetal RAM Dumper – Bare-metal x86 tool for Cold Boot Attack experiments

https://github.com/pIat0n/BareMetal-RAM-Dumper
53•liffik•7h ago•36 comments

Curveball

https://mightyburger.net/projects/curveball/
49•toilet•9h ago•11 comments

Mapping with In-Memory Layers to Reduce LLM Overload

https://ridgetext.com/blog/mapbox-llm-composition
3•Buckwheat469•2h ago•0 comments

Drone Autonomy Crash Course

https://www.cggonzalez.com/blog/index.html
4•cgg1•2h ago•0 comments

Neural Render Proxies for Interactive and Differentiable Lighting

https://studios.disneyresearch.com/2026/07/01/neural-render-proxies-for-interactive-and-different...
49•tobr•3d ago•8 comments

CloudsLinker: Move and sync files across 50 cloud services

https://app.cloudslinker.com/login
5•janandonly•2d ago•0 comments