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

Donate to GrapheneOS

https://grapheneos.org/donate
138•charliebwrites•55m ago•20 comments

Deflock Casa Grande

https://deflockcg.com/
187•mooreds•1h ago•58 comments

Substack writers, you need a website

https://elizabethtai.com/2026/06/10/substack-writers-you-need-a-website/
157•speckx•3h ago•111 comments

A walk through of the DeltaNet family of linear attention variants

https://blog.doubleword.ai/you-could-have-come-up-with-kimi-delta-attention
262•AnhTho_FR•3h ago•110 comments

Steel Bank Common Lisp version 2.6.7

https://sbcl.org/all-news.html?2.6.7
104•tmtvl•2h ago•35 comments

Kimi K3 Architecture Overview and Notes

https://sebastianraschka.com/blog/2026/kimi-k3-architecture-notes.html
148•ModelForge•4h ago•17 comments

Discovering Cryptographic Weaknesses with Claude

https://www.anthropic.com/research/discovering-cryptographic-weaknesses
95•gslin•2h ago•40 comments

Delayed Gratification – Proud to Be 'Last to Breaking News'

https://www.slow-journalism.com/
151•speerer•4h ago•80 comments

The iPhone Upgrade Program is being replaced by Apple Upgrade

https://www.apple.com/shop/iphone/iphone-upgrade-program
52•lkurtz•2h ago•87 comments

How Do I Profile eBPF Code?

https://naveensrinivasan.com/posts/2026-07-22-how-do-i-profile-ebpf-code/
86•snaveen•4h ago•6 comments

MCP 2026-07-28 Specification: transport going stateless

https://blog.modelcontextprotocol.io/posts/2026-07-28/
30•Eldodi•1h ago•11 comments

Zig's Incremental Compilation Internals

https://mlugg.co.uk/posts/incremental-compilation-internals/
124•garyhtou•4h ago•76 comments

Show HN: XY – A Fast, composable, GPU-accelerated interactive plotting library

https://github.com/reflex-dev/xy
73•apetuskey•4h ago•24 comments

New HIV vaccine shows unprecedented success in preclinical study

https://www.lji.org/news-events/news/post/new-hiv-vaccine-shows-unprecedented-success-in-preclini...
434•codebyaditya•6h ago•205 comments

WOFF 1.0: a milestone on W3C's journey of fonts on the web

https://www.w3.org/blog/2026/woff-1-0-a-milestone-on-w3cs-journey-of-fonts-on-the-web/
41•hn_acker•2h ago•1 comments

Kimi Linear: An Expressive, Efficient Attention Architecture (2025)

https://arxiv.org/abs/2510.26692
239•ronfriedhaber•9h ago•102 comments

Now Is the Time to Give LLMs Access to the ACM Digital Library

https://cacm.acm.org/opinion/now-is-the-time-to-give-llms-access-to-the-acm-digital-library/
72•rbanffy•5h ago•29 comments

Harmony Explained: Progress Towards a Scientific Theory of Music (2012)

https://arxiv.org/abs/1202.4212
69•surprisetalk•4h ago•50 comments

Anthropeum – Where in the world, and when, does this human artifact belong?

https://anthropeum.com/
106•bookofjoe•5h ago•31 comments

The Fabled Flatbreads of Uzbekistan (2015)

https://www.aramcoworld.com/articles/2015/the-fabled-flatbreads-of-uzbekistan
7•jxub•4d ago•1 comments

Uv 0.12.0

https://github.com/astral-sh/uv/releases/tag/0.12.0
24•hallvard•20m ago•3 comments

How to survive boiling water

https://taxa.substack.com/p/how-to-survive-boiling-water
390•cainxinth•4d ago•83 comments

DMARC has been public since 2012 but most company domains still don't enforce it

https://ciphercue.com/blog/dmarc-enforcement-gap-rua-fragmentation-2026
153•adulion•9h ago•95 comments

Stop Killing the Internet: No Digital ID and No Age Verification

https://citizens-initiative.europa.eu/initiatives/details/2026/000011_en
306•doener•5h ago•97 comments

The most advanced robotic servicing satellite–that we know about

https://arstechnica.com/space/2026/07/this-is-the-worlds-most-advanced-robotic-servicing-satellit...
17•GlenTheMachine•4d ago•1 comments

So, you want to make a game engine (2023)

https://lisyarus.github.io/blog/posts/so-you-want-to-make-a-game-engine.html#part-3
40•kugurerdem•4h ago•26 comments

Una GPS smart watch – Repairable, USB-C charging, developer-friendly

https://unawatch.com/
61•pimterry•5h ago•55 comments

7.1 Earthquake in Japan

https://www.data.jma.go.jp/multi/quake/quake_detail.html?eventID=20260728163528&lang=en
741•krembo•12h ago•193 comments

Using a Gaming PC's RTX 5070 from a separate Linux workstation

https://stephenkrings.com/posts/rtx-5070-linux-gpu-server/
28•microbial•6d ago•17 comments

VMs can't boot with Network Mode set to Bridged on Apple M5 Pro machines

https://github.com/utmapp/UTM/issues/7658
62•IndySun•6h ago•36 comments