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

DeepSeek V4 Pro 0813

https://openrouter.ai/deepseek/deepseek-v4-pro-0813
436•explosion-s•3h ago•150 comments

Zed: Delta

https://zed.dev/blog/introducing-delta
97•khy•1h ago•27 comments

Tailscale Traces Database Corruption to 16y/o SQLite WAL-Reset Bug

https://tailscale.com/blog/sqlite-wal-reset-bug
529•ropbear•5h ago•84 comments

Qwen3.8-2.4T

https://huggingface.co/Qwen/Qwen3.8-2.4T-A95B
266•Philpax•4h ago•68 comments

2026 Eclipse Webcams

https://jonty.github.io/2026_eclipse_webcams/
412•zoenolan•7h ago•105 comments

Tim King, AmigaDOS developer, has died

https://amiga-news.de/en/news/AN-2026-08-00070-EN.html
149•doener•5h ago•23 comments

Someone is running mass vulnerability scans, spoofing AI bots like ClaudeBot

https://knownagents.com/insights
156•gavinhking•5h ago•100 comments

HTML over WebSockets: real-time SPAs with barely any JavaScript

https://en.andros.dev/blog/ef4968f5/html-over-websockets-real-time-spas-with-barely-any-javascript/
44•redbell•2h ago•35 comments

Your Key to Success Isn't More Luck or Hard Work

https://julienreszka.com/blog/your-key-to-success-isn-t-more-luck-or-hard-work/
20•julienreszka•1h ago•14 comments

Glaciers on the Climate Dashboard

https://climate.metoffice.cloud/glaciers.html
61•mooreds•2h ago•6 comments

Reflex (YC W23) Is hiring Growth and GTM Roles

https://www.ycombinator.com/companies/reflex/jobs/71x5GFb-growth-engineer
1•apetuskey•2h ago

Why Tiny JPEGs Look Different in Chrome

https://guillaumetech.github.io/posts/jpg-scaling-chrome/
180•gutechh•5h ago•35 comments

Wednesday, August 12: GitHub, Incident with Pull Requests and Issues

https://www.githubstatus.com/incidents/76t89hbfb09h
47•arm32•3h ago•11 comments

License plate reader searches should require a warrant

https://andrewpwheeler.com/2026/08/12/license-plate-reader-searches-should-require-a-warrant/
403•apwheele•4h ago•253 comments

SpaceXAI's Grok 4.6 Scores 61 on the Artificial Analysis Intelligence Index

https://artificialanalysis.ai/articles/grok-4-6-benchmarks-and-analysis
185•wertyk•2h ago•164 comments

The Essential Question: "What should I read next?"

https://thenewcuriosityshop.substack.com/p/the-essential-question
15•benbreen•6d ago•2 comments

We just raised $400M in Series C

https://lovable.dev/blog/series-c
45•thoughtpeddler•3h ago•28 comments

AI is removing the middle class of software engineering

https://blog.florianherrengt.com/ai-removing-middle-class-software-engineering.html
505•florianherrengt•6h ago•420 comments

Shade Map

https://shademap.app
80•fredley•6h ago•21 comments

What sort of maths are LLMs good at?

https://gowers.wordpress.com/2026/08/12/what-sort-of-maths-are-llms-good-at/
208•ColinWright•9h ago•105 comments

Bike Bureau: Report Bike Lane Obstructions

https://loudbicycle.com/bb
33•kdmccormick•3h ago•25 comments

Grok 4.6

https://x.ai/news/grok-4-6
184•iLuddite•3h ago•204 comments

Show HN: Woxi - Open-source Mathematica / Wolfram Language reimplementation

https://woxi.ad-si.com
223•adius•9h ago•32 comments

Felix and I

https://jacobfilipp.com/felix/
59•surprisetalk•2d ago•7 comments

The Bit Player: My Father with Steve Zissou

https://www.theparisreview.org/blog/2026/07/27/the-bit-player-my-father-with-steve-zissou/
20•Thevet•4d ago•1 comments

Automatic1111 for Apple metal, 40% speed up sd1.5

https://therad.ninja/from-8-10-seconds-to-3-7-teaching-automatic1111-to-speak-metal-on-an-m3-pro/
52•dmikey831•5h ago•18 comments

High-Res Photo Shows Sand-Capped Butte Rising from Mars Plain of Polygons

https://petapixel.com/2026/08/04/amazing-high-res-photo-shows-a-butte-rising-from-mars/
135•bookofjoe•6d ago•11 comments

Delphi 13 Community Edition Is Now Available

https://blogs.embarcadero.com/delphi-13-community-edition-is-now-available/
136•layer8•8h ago•97 comments

Solving the Shortest Vector Problem in $2^{0.6039n}$ Time via Mid-Point Hessian

https://arxiv.org/abs/2608.02478
30•sbulaev•1w ago•7 comments

Hax – a minimalist, terminal-native coding agent written in C

https://usehax.dev/
51•OleksandrC•4h ago•20 comments