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

Astra for Law

https://openai.com/index/astra-for-law/
225•vertigoruntime•3h ago•255 comments

Bonsai 2 27B: Near-Lossless Compression in a 9x Smaller Footprint

https://prismml.com/news/bonsai-2-27b
128•JonSchneider•2h ago•39 comments

Bend – A language that blocks AI mistakes via proof, on CPU and GPU

https://bend-lang.com/
215•nicolas-siplis•2h ago•116 comments

Hister: A private search engine for the pages you visit and the files you keep

https://github.com/asciimoo/hister
407•bookofjoe•7h ago•123 comments

How to Write with an LLM

https://sockpuppet.org/blog/2026/09/17/how-to-write-with-an-llm/
34•joeriddles•1h ago•20 comments

Wax motor

https://en.wikipedia.org/wiki/Wax_motor
188•mhb•1d ago•39 comments

Fujitsu launches made-in-Japan next-generation CPU FUJITSU-MONAKA

https://global.fujitsu/en-global/pr/news/2026/09/14-02
480•my123•2d ago•183 comments

Sex, AI, and the Apocalypse

https://www.iankduncan.com/personal/2026-09-16-sex-ai-and-the-apocalypse/
89•Anon84•2h ago•60 comments

Flet 1.0 – Build cross-platform apps in Python

https://flet.dev/
31•absqueued•2h ago•10 comments

More than 100k people in Japan are now aged 100 or older

https://www.bbc.com/news/articles/cmzezj5e18xxo
30•karakoram•3h ago•11 comments

CrowdSec Source Code Leak

https://www.crowdsec.net/blog/crowdsec-statement-source-code-exposure
122•eccgecko•8h ago•35 comments

The most important product decision is what you don't build

https://liamnugent.me/posts/what-you-dont-build/
23•ChrisArchitect•2h ago•7 comments

Diplodocus, Long Thought Exclusively American, Turns Up in Spain

https://www.sci.news/paleontology/spanish-diplodocus-15064.html
13•embedding-shape•2d ago•7 comments

Rate limits on GitLab.com are changing

https://about.gitlab.com/blog/rate-limit-change-2026/
144•darkwater•8h ago•103 comments

Infinite-Parameter LLMs: Generating and Adapting Weights from Live Data

https://arxiv.org/abs/2609.18842
96•Betelbuddy•6h ago•26 comments

How Uber Protects Against Retry Storms

https://www.uber.com/us/en/blog/protecting-against-retry-storms/
18•iscmt•2h ago•9 comments

How GLM built its own inference infrastructure

https://z.ai/blog/glm-built-its-inference-infrastructure
355•whiteros_e•15h ago•259 comments

Why I didn’t sign the Fields medallists’ letter

https://gowers.wordpress.com/2026/09/17/why-i-didnt-sign-the-fields-medallists-letter/
190•simianwords•14h ago•249 comments

Zettascale (YC S24) Is Hiring ASIC/FPGA Engineers to Build Chips for ASI

https://zscc.ai/careers?job_id=109821
1•el_al•6h ago

TSMC revealing details about next gen A14 node

https://iedm26.mapyourshow.com/8_0/sessions/session-details.cfm?scheduleid=331
79•osnium123•2d ago•29 comments

How do we prevent mathemathics from devolving into the Medieval Era of secrecy?

https://mathoverflow.net/questions/515260/how-do-we-prevent-mathematics-from-devolving-into-the-m...
60•jjgreen•2d ago•40 comments

The American Religion of Self-Storage Facilities

https://www.newyorker.com/magazine/2026/09/21/the-american-religion-of-self-storage-facilities
174•pseudolus•10h ago•304 comments

One year of sponsored Servo development

https://servo.org/blog/2026/09/15/one-year-of-sponsorship/
342•AshleysBrain•15h ago•140 comments

CCC invites all model citizens to 40C3

https://events.ccc.de/en/2026/09/12/40c3-model-citizens/
323•antonly•15h ago•176 comments

Running Ubuntu on the Lenovo IdeaPad Duet

https://vhaudiquet.fr/blog/duet-ubuntu/
61•vhaudiquet•3d ago•20 comments

André Weil and the Hodge Conjecture

https://jiahao116.github.io/Articles/
26•caojiahao•5d ago•10 comments

Computer Reset, Dallas

https://dfarq.homeip.net/computer-reset-dallas/
11•ibobev•2h ago•0 comments

Show HN: Snapdrop: Instantly share files between devices. No setup, no signup

https://snapdrop.me
10•Capira•2h ago•9 comments

Launch HN: Skillsync (YC W26) – AI chat sessions made portable across agents

40•cat-whisperer•7h ago•45 comments

Towards Self-Driving Codebases

https://blog.detail.dev/posts/towards-self-driving-codebases/
93•wilhelmklopp•6h ago•78 comments