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

GLM-5.2 is the new leading open weights model on Artificial Analysis

https://artificialanalysis.ai/articles/glm-5-2-is-the-new-leading-open-weights-model-on-the-artif...
59•himata4113•1h ago•10 comments

Show HN: High-Res Neural Cellular Automata

https://cells2pixels.github.io/
24•esychology•1h ago•0 comments

GrapheneOS has been ported to Android 17

https://discuss.grapheneos.org/d/36469-grapheneos-has-been-ported-to-android-17-and-official-rele...
798•Cider9986•14h ago•398 comments

Running local models is good now

https://vickiboykis.com/2026/06/15/running-local-models-is-good-now/
1354•jfb•20h ago•516 comments

Hacker News but for Independent Blogs

https://bubbles.town/
98•headalgorithm•2h ago•31 comments

Humiliating IIS servers for fun and jail time

https://mll.sh/humiliating-iis-servers-for-fun-and-jail-time/
275•denysvitali•11h ago•64 comments

The founder's playbook: Building an AI-native startup

https://claude.com/blog/the-founders-playbook
94•e2e4•3h ago•88 comments

U.S. Science Is in Chaos

https://www.scientificamerican.com/article/americas-compact-between-science-and-politics-is-broken/
35•presspot•49m ago•6 comments

Subterranean fungi networks more than 100 quadrillion km in length

https://www.theguardian.com/science/2026/jun/11/arbuscular-mycorrhizal-fungi-plant-life-climate-g...
77•tosh•5d ago•17 comments

TIL: You can make HTTP requests without curl using Bash /dev/TCP

https://mareksuppa.com/til/bash-dev-tcp-http-without-curl/
426•mrshu•18h ago•196 comments

Wolfram Language and Mathematica version 15

https://writings.stephenwolfram.com/2026/06/launching-version-15-of-wolfram-language-mathematica-...
172•alok-g•11h ago•85 comments

Calvin and Hobbes and the price of integrity

https://therepublicofletters.substack.com/p/calvin-and-hobbes-and-the-price-of
433•pseudolus•18h ago•184 comments

Has AI already killed self-help nonfiction books?

https://tim.blog/2026/06/12/has-ai-already-killed-nonfiction/
310•imakwana•17h ago•347 comments

GPT‑NL: a sovereign language model for the Netherlands

https://www.tno.nl/en/digital/artificial-intelligence/gpt-nl/
217•root-parent•16h ago•219 comments

Map Clustering Is Not My Favorite

https://blog.greg.technology/2026/06/12/map-clustering-is-not-my-favorite.html
13•gregsadetsky•4d ago•6 comments

Stop Using JWTs

https://gist.github.com/samsch/0d1f3d3b4745d778f78b230cf6061452
405•dzonga•17h ago•233 comments

From Chesterton's fence to Chesterton's gap

https://stephantul.github.io/blog/unfence/
11•stephantul•3h ago•8 comments

Semiclassical Gravity Efficiently Solves NP-Complete Problems

https://arxiv.org/abs/2606.14806
33•ascarshen•7h ago•16 comments

Stop Killing Games fails to secure EU law despite 1.3M signatures

https://www.dexerto.com/gaming/stop-killing-games-fails-to-secure-eu-law-despite-1-3m-signatures-...
260•slymax•9h ago•162 comments

Making 'food out of thin air' (2024)

https://www.noemamag.com/making-food-out-of-thin-air/
22•muchweight•2d ago•5 comments

SpaceX to buy Cursor for $60B

https://www.reuters.com/legal/transactional/spacex-buy-anysphere-60-billion-2026-06-16/
1035•itsmarcelg•23h ago•1533 comments

But yak shaving is fun (2019)

https://parksb.github.io/en/article/32.html
268•parksb•20h ago•78 comments

Lattice Triangles Are Rare

https://axiommath.ai/territory/the-reveal
20•skogstokig•6d ago•3 comments

A brief tour of the PDP-11, the most influential minicomputer of all time (2022)

https://arstechnica.com/gadgets/2022/03/a-brief-tour-of-the-pdp-11-the-most-influential-minicompu...
83•jensgk•2d ago•32 comments

GLM 5.2 Performance Benchmarks

https://artificialanalysis.ai/models/glm-5-2
5•theanonymousone•3h ago•0 comments

The Amphibious Villagers of Indonesia

https://www.economist.com/interactive/1843/2026/06/12/the-amphibious-villagers-of-indonesia
29•haritha-j•2d ago•8 comments

10Gb/s Ethernet: switching to a Broadcom SFP+ module

https://www.gilesthomas.com/2026/06/10g-ethernet-switching-to-broadcom-sfp-plus
153•gpjt•16h ago•135 comments

Qwen-Robot Suite: A Foundation Model Suite for Physical World Intelligence

https://qwen.ai/blog?id=qwen-robotsuite
181•ilreb•21h ago•31 comments

A Nipkow Disk Mechanical TV Simulator

https://analogtv.net/mechanical-lab
51•ambanmba•2d ago•7 comments

Show HN: cuTile Rust: Safe, data-race-free GPU kernels in Rust

https://github.com/nvlabs/cutile-rs
84•melihelibol•14h ago•14 comments