frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

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•9mo ago

Comments

castratikron•9mo 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•9mo 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•9mo 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•9mo 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•9mo 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•9mo ago
in CPU's - pipelining!
jchw•9mo 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...)

Defer available in gcc and clang

https://gustedt.wordpress.com/2026/02/15/defer-available-in-gcc-and-clang/
167•r4um•4d ago•114 comments

Consistency diffusion language models: Up to 14x faster, no quality loss

https://www.together.ai/blog/consistency-diffusion-language-models
118•zagwdt•6h ago•40 comments

Gemini 3.1 Pro

https://blog.google/innovation-and-ai/models-and-research/gemini-models/gemini-3-1-pro/
783•MallocVoidstar•19h ago•818 comments

I tried building my startup entirely on European infrastructure

https://www.coinerella.com/made-in-eu-it-was-harder-than-i-thought/
232•willy__•1h ago•121 comments

Reading the undocumented MEMS accelerometer on Apple Silicon MacBooks via iokit

https://github.com/olvvier/apple-silicon-accelerometer
65•todsacerdoti•5h ago•30 comments

AI is not a coworker, it's an exoskeleton

https://www.kasava.dev/blog/ai-as-exoskeleton
272•benbeingbin•14h ago•286 comments

FreeCAD

https://www.freecad.org/index.php
175•doener•2d ago•53 comments

Show HN: Micasa – track your house from the terminal

https://micasa.dev
561•cpcloud•18h ago•182 comments

Infrastructure decisions I endorse or regret after 4 years at a startup (2024)

https://cep.dev/posts/every-infrastructure-decision-i-endorse-or-regret-after-4-years-running-inf...
266•Meetvelde•3d ago•110 comments

Untapped Way to Learn a Codebase: Build a Visualizer

https://jimmyhmiller.com/learn-codebase-visualizer
8•andreabergia•1h ago•0 comments

Raspberry Pi Pico 2 at 873.5MHz with 3.05V Core Abuse

https://learn.pimoroni.com/article/overclocking-the-pico-2
8•Lwrless•1h ago•0 comments

Pi for Excel: AI sidebar add-in for Excel

https://github.com/tmustier/pi-for-excel
74•rahimnathwani•8h ago•22 comments

US plans online portal to bypass content bans in Europe and elsewhere

https://www.reuters.com/world/us-plans-online-portal-bypass-content-bans-europe-elsewhere-2026-02...
333•c420•1d ago•550 comments

Spell Checking a Year's Worth of Hacker News

https://fi-le.net/spell/
6•fi-le•2d ago•2 comments

An ARM Homelab Server, or a Minisforum MS-R1 Review

https://sour.coffee/2026/02/20/an-arm-homelab-server-or-a-minisforum-ms-r1-review/
71•neelc•9h ago•61 comments

A beginner's guide to split keyboards

https://www.justinmklam.com/posts/2026/02/beginners-guide-split-keyboards/
141•thehaikuza•4d ago•158 comments

An AI Agent Published a Hit Piece on Me – The Operator Came Forward

https://theshamblog.com/an-ai-agent-wrote-a-hit-piece-on-me-part-4/
384•scottshambaugh•7h ago•321 comments

Fast KV Compaction via Attention Matching

https://arxiv.org/abs/2602.16284
29•cbracketdash•5h ago•0 comments

America vs. Singapore: You can't save your way out of economic shocks

https://www.governance.fyi/p/america-vs-singapore-you-cant-save
282•guardianbob•19h ago•408 comments

Micropayments as a reality check for news sites

https://blog.zgp.org/micropayments-as-a-reality-check-for-news-sites/
165•speckx•15h ago•340 comments

A terminal weather app with ASCII animations driven by real-time weather data

https://github.com/Veirt/weathr
223•forinti•16h ago•38 comments

Show HN: Ghostty-based terminal with vertical tabs and notifications

https://github.com/manaflow-ai/cmux
141•lawrencechen•13h ago•62 comments

Web Components: The Framework-Free Renaissance

https://www.caimito.net/en/blog/2026/02/17/web-components-the-framework-free-renaissance.html
4•mpweiher•2h ago•0 comments

Paged Out Issue #8 [pdf]

https://pagedout.institute/download/PagedOut_008.pdf
390•SteveHawk27•22h ago•60 comments

Show HN: Write native binary web apps with TypeScript and Express

https://github.com/tsoniclang/express
5•jeswin•3d ago•1 comments

Mystery donor gives Japanese city $3.6M in gold bars to fix water system

https://www.bbc.com/news/articles/c3ew5jlqz87o
102•tartoran•6h ago•47 comments

Brave Iranians gather in central Iran to honour those killed in uprising

https://twitter.com/IranIntl_En/status/2024767317893075330
9•ukblewis•49m ago•1 comments

William Latham – Art and the Computer (1990) [video]

https://www.youtube.com/watch?v=OwL3dsFBxpE
8•hyperific•2d ago•1 comments

Lindenmayer.jl: Defining recursive patterns in Julia

https://cormullion.github.io/Lindenmayer.jl/stable/
53•WillMorr•3d ago•2 comments

MuMu Player (NetEase) silently runs 17 reconnaissance commands every 30 minutes

https://gist.github.com/interpiduser5/547d8a7baec436f24b7cce89dd4ae1ea
279•interpidused•9h ago•105 comments