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

OpenAI unveils its first custom chip, built by Broadcom

https://techcrunch.com/2026/06/24/openai-unveils-its-first-custom-chip-built-by-broadcom/
440•jamdesk•5h ago•282 comments

PostgreSQL Is Enough

https://gist.github.com/cpursley/c8fb81fe8a7e5df038158bdfe0f06dbb
23•Imustaskforhelp•40m ago•1 comments

Qualcomm to Acquire Modular

https://www.reuters.com/business/qualcomm-buy-ai-startup-modular-2026-06-24/
99•timmyd•9h ago•27 comments

RubyLLM: A Ruby framework for all major AI providers

https://rubyllm.com/
327•doener•8h ago•50 comments

Elastic lays off 7% of employees

https://www.elastic.co/blog/ceo-ash-kulkarni-announcement-to-elastic-employees
65•dakrone•1h ago•32 comments

We’re making Bunny DNS free

https://bunny.net/blog/were-making-bunny-dns-free/
822•dabinat•14h ago•251 comments

PR spam today looks like email spam in the early 2000s

https://www.greptile.com/blog/prs-on-openclaw
162•dakshgupta•8h ago•92 comments

Computer use in Gemini 3.5 Flash

https://blog.google/innovation-and-ai/models-and-research/gemini-models/introducing-computer-use-...
136•swolpers•5h ago•86 comments

The Xteink X4 E-Ink Reader

https://blog.omgmog.net/post/xteink-x4-e-ink-reader/
138•felixdoerp•6h ago•100 comments

Robotics Teams Are Rebuilding the Data Stack from Scratch

https://rerun.io/blog/data-layer-tax
12•Tycho87•3d ago•1 comments

Crawling BitTorrent DHTs for Fun and Profit [pdf]

https://www.usenix.org/legacy/event/woot10/tech/full_papers/Wolchok.pdf
36•dgellow•3d ago•18 comments

45°C cooling design cuts data center water use to near zero

https://blogs.nvidia.com/blog/liquid-cooling-ai-factories/
122•nitin_flanker•9h ago•99 comments

There are a few things that I look back on as my mistakes in the early days

https://twitter.com/ID_AA_Carmack/status/2069799283369345247
463•shadowtree•7h ago•232 comments

Show HN: Nub – A Bun-like all-in-one toolkit for Node.js

https://github.com/nubjs/nub
184•colinmcd•9h ago•52 comments

GLM-5.2 is a step change for open agents

https://www.interconnects.ai/p/glm-52-is-the-step-change-for-open
80•vantareed•1d ago•27 comments

GitHub shouldn't be a dependency for publishing Rust on crates.io

https://infosec.exchange/@mttaggart/116806641273303255
118•speckx•3h ago•41 comments

Show HN: LookAway, a Mac break reminder that knows when not to interrupt

https://lookaway.com
43•_kush•9h ago•5 comments

Stealing Is a Skill

https://ben-mini.com/2026/stealing-is-a-skill
197•bewal416•10h ago•120 comments

Krea 2: SOTA open-weights 12B image model

https://www.krea.ai/blog/krea-2-technical-report
310•mattnewton•1d ago•35 comments

How the Fifth Lateran Council unlocked financial theory

https://sebastiangarren.com/2026/06/17/lending-is-meritorious-and-should-be-praised-how-the-fifth...
42•momentmaker•4d ago•4 comments

I can haz smoller NixOS ISOs?

https://natkr.com/2026-06-19-nixos-but-smol/
64•logickkk1•5d ago•20 comments

A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding

https://labs.iximiuz.com/tutorials/ssh-tunnels
248•signa11•4d ago•53 comments

Pondering routing more of my traffic via nodes outside the UK

https://neilzone.co.uk/2026/06/pondering-routing-more-of-my-traffic-via-nodes-outside-the-uk-beca...
44•ColinWright•3d ago•31 comments

Running Windows Games on a Hobby OS with Wine

https://astral-os.org/posts/2026/04/03/wine-on-astral.html
93•avaliosdev•8h ago•30 comments

Show HN: Monolisa v3 – a typeface for developers and creatives

https://www.monolisa.dev/
148•bebraw•2d ago•49 comments

Exploiting vulnerabilities in Johnson and Johnson web apps

https://eaton-works.com/2026/06/24/jnj-webapp-hacks/
51•EatonZ•6h ago•2 comments

Thomann takes legal action against Fender

https://www.thomann.de/blog/en/inside/thomann-takes-legal-action-against-fender/
166•Audiophilip•4h ago•102 comments

Big AI labs are hiring philosophers

https://www.economist.com/science-and-technology/2026/06/24/why-big-ai-labs-are-hiring-so-many-ph...
102•Brajeshwar•6h ago•91 comments

I taught a bucket to speak Git

https://www.tigrisdata.com/blog/objgit/
72•xena•7h ago•16 comments

NSA lost access to Mythos amid Anthropic dispute

https://www.nytimes.com/2026/06/23/us/politics/nsa-lost-access-anthropic-tool.html
203•thm•11h ago•184 comments