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

GrapheneOS Overhauled Default Apps and Secure Clipboard

https://grapheneos.social/@GrapheneOS/117225539756835649
180•Cider9986•4h ago•95 comments

Making a Python interpreter in 1024 bytes

https://austinhenley.com/blog/python1024.html
64•azhenley•1h ago•22 comments

Your intellectual fly is open (2025)

https://bcantrill.dtrace.org/2025/12/05/your-intellectual-fly-is-open/
517•cyb0rg0•13h ago•330 comments

Show HN: Mador – Make any DOM reactive with a tiny 80-line Proxy state tuple

https://github.com/marsbos/mador
63•bosmarcel•4h ago•22 comments

Is mathematics about to enter the conservatory?

https://mbmccoy.dev/posts/mathematical-conservatory/
13•_alternator_•2h ago•10 comments

Harnessing the Universal Geometry of Embeddings

https://arxiv.org/abs/2505.12540
39•ur-whale•4h ago•7 comments

Babylonian Lamb Stew with Beets (1750–1730 BCE)

https://babylonian-collection.yale.edu/about/babylonian-cooking
91•yubblegum•3d ago•44 comments

NetBSD 9.5 released and EOL for NetBSD-9

https://blog.netbsd.org/tnf/entry/netbsd_9_5_released_and
103•jaypatelani•9h ago•5 comments

Black Hole of Los Alamos Seller of surplus nuclear research materials (2011)

https://www.atlasobscura.com/places/black-hole-of-los-alamos
40•Bluestein•4d ago•10 comments

Reverse engineering the storage format for an undocumented database

https://blog.glazer.ee/posts/converting-cronos/
20•pintprint•2d ago•1 comments

Hackers have withdrawn ~4k BTC (~$320M) from the Liquid Federation wallet

https://twitter.com/Liquid_BTC/status/2096696272447218108
53•felipelalli•2h ago•24 comments

Asahi Linux on M3

https://asahilinux.org/2026/09/m2-episode-1/
350•mdp2021•11h ago•191 comments

Adverse Selection and Markouts

https://machow.ski/posts/markouts_and_adverse_selection/
6•costco•5d ago•0 comments

A/I shuts down – Stay human

https://keepitfree.ai/announcements/a/i-shuts-down-stay-human/
515•captainmuon•10h ago•383 comments

Research carried out using NetBSD

https://www.netbsd.org/gallery/research.html
76•Bluestein•8h ago•18 comments

Vidact – a compiler that turns React into direct DOM operations

https://www.vidact.dev/
48•mohebifar•4d ago•24 comments

Electronic skin for prosthetics to sense temperature and pressure

https://news.wsu.edu/press-release/2026/08/20/researchers-develop-electronic-skin-for-prosthetics...
46•gmays•4d ago•5 comments

D2 Is Non-Profit

https://d2lang.com/blog/d2-non-profit/
27•alixanderwang•5h ago•10 comments

Doomscrolling Ourselves to Death

https://www.edwest.co.uk/p/doomscrolling-ourselves-to-death
364•shubhamjain•13h ago•260 comments

M-DISC – DVD/Blu-ray compatible discs that may last up to 1000 years

https://en.wikipedia.org/wiki/M-DISC
181•gurjeet•4d ago•88 comments

Opalite Health (YC W26) Is Hiring – Founding GTM

https://www.ycombinator.com/companies/opalite-health/jobs/bNedVAD-founding-gtm
1•ckuo9•8h ago

Isar Aerospace reaches orbit and deploys payloads on second flight

https://isaraerospace.com/press/history-for-european-spaceflight-isar-aerospace-reaches-orbit-and...
557•mpweiher•17h ago•177 comments

Every Novel Is Boring–Until It Isn't

https://www.publicbooks.org/every-novel-is-boring-until-it-isnt/
5•samclemens•3d ago•1 comments

It took a year to ship WebAssembly in Anubis

https://anubis.techaro.lol/blog/2026/anubis-wasm/
131•xena•4h ago•81 comments

Political meddling at the Census Bureau damages the US statistical system

https://www.piie.com/blogs/realtime-economics/2026/political-meddling-census-bureau-damages-entir...
56•boshomi•2h ago•18 comments

A Week of Bug Reporting

https://tratt.net/laurie/blog/2022/a_week_of_bug_reporting.html
6•luu•2d ago•1 comments

Nitter and XCancel resume service after legal advice

https://github.com/zedeus/nitter/commit/1428b4c2b4246f92a7e5b2673438e5fb39fcc4a3
441•zImPatrick•7h ago•234 comments

IBM Quantum Nighthawk R2

https://www.ibm.com/quantum/blog/nighthawk-r2
80•fuglede_•3d ago•36 comments

Research acceleration: The view inside OpenAI

https://openai.com/index/research-acceleration-view-inside-openai
105•iamsyr•10h ago•75 comments

Icy Moons Are Ocean Worlds

https://mceglowski.substack.com/p/icy-moons-are-ocean-worlds
42•worldvoyageur•12h ago•4 comments