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

The newest Instagram “exploit” is the goofiest I've seen

https://www.0xsid.com/blog/meta-account-takeover-fiasco
1321•ssiddharth•9h ago•323 comments

Can the stockmarket swallow Anthropic, SpaceX and OpenAI?

https://www.economist.com/finance-and-economics/2026/06/01/can-the-stockmarket-swallow-anthropic-...
49•1vuio0pswjnm7•1h ago•78 comments

OpenAI frontier models and Codex are now available on AWS

https://openai.com/index/openai-frontier-models-and-codex-are-now-available-on-aws/
121•typpo•3h ago•44 comments

Debug Project

https://debug.com/
146•Eridanus2•4h ago•69 comments

What's gonna happen to software engineers?

https://yakko.dev/blog/whats-gonna-happen-to-software-developers
26•yakkomajuri•1h ago•14 comments

AI Agent Guidelines for CS336 at Stanford

https://github.com/stanford-cs336/assignment1-basics/blob/main/CLAUDE.md
317•prakashqwerty•8h ago•114 comments

A new way to build chips: Sequentially stacking silicon to extend Moore's Law

https://matse.illinois.edu/news/85775
19•hhs•2d ago•2 comments

Chipotlai Max

https://github.com/cyberpapiii/chipotlai-max
21•nigelgutzmann•2h ago•4 comments

CS336: Language Modeling from Scratch

https://cs336.stanford.edu/
357•kristianpaul•11h ago•43 comments

Should you normalize RGB values by 255 or 256?

https://30fps.net/pages/255-vs-256-division/
188•pplanu•7h ago•83 comments

GrapheneOS Speech Services version 2 released

https://discuss.grapheneos.org/d/36001-grapheneos-speech-services-version-2-released
97•pretext•6h ago•16 comments

What appear to be biochemical processes may be a natural feature of geology

https://www.quantamagazine.org/the-dirt-that-refused-to-die-20260601/
191•speckx•10h ago•64 comments

Microsoft builds MacBook Pro rival with NVIDIA-powered Surface Laptop Ultra

https://www.windowslatest.com/2026/06/01/microsoft-builds-its-ultimate-macbook-pro-rival-with-the...
142•jbk•13h ago•340 comments

Age verification for social media, the beginning of the end for a free internet?

https://mullvad.net/en/blog/age-verification-for-social-media-the-beginning-of-the-end-for-a-free...
78•StrLght•2h ago•38 comments

Nvidia RTX Spark

https://www.nvidia.com/en-us/products/rtx-spark/
325•shenli3514•20h ago•327 comments

Stealing from Biologists to Compile Haskell Faster

https://www.iankduncan.com/engineering/2026-05-30-stealing-from-biologists-to-compile-haskell-fas...
96•mooreds•2d ago•4 comments

The Frame Problem (2004)

https://plato.stanford.edu/entries/frame-problem/
11•rzk•2h ago•3 comments

Ask HN: Who is hiring? (June 2026)

156•whoishiring•10h ago•228 comments

Alphabet announces $80B equity capital raise to expand AI infra and compute

https://abc.xyz/investor/news/news-details/2026/Alphabet-Announces-Proposed-80-Billion-Equity-Cap...
105•gregschlom•4h ago•102 comments

I made my phone slow on purpose

https://vinewallapp.com/notes/i-made-my-phone-slow-on-purpose/
167•gcampos•4d ago•150 comments

Launch HN: Expanse (YC P26) – Unlock Wasted GPU Capacity

69•ismaeel_bashir•12h ago•21 comments

Constant Q Transform – A Visual Guide

https://brendanjameslynskey.github.io/ConstantQ-Transform/
4•hyperific•3d ago•0 comments

Only 17% of all 64-bit Integers are products of two 32-bit integers

https://lemire.me/blog/2026/05/22/only-17-of-all-64-bit-integers-are-products-of-two-32-bit-integ...
201•sebg•4d ago•91 comments

Windows GOG DOS Games on M-Series Macs

https://f055.net/technology/windows-gog-dos-games-on-m-series-macs/
139•f055•12h ago•79 comments

Ask HN: Who wants to be hired? (June 2026)

92•whoishiring•10h ago•271 comments

Anthropic confidentially submits draft S-1 to the SEC

https://www.anthropic.com/news/confidential-draft-s1-sec
448•surprisetalk•9h ago•363 comments

Flipper Zero Zig Template

https://github.com/NishantJoshi00/flipper-template
128•Nars088•12h ago•10 comments

Malicious npm packages detected across Red Hat Cloud Services

https://github.com/RedHatInsights/javascript-clients/issues/492
728•kurmiashish•12h ago•411 comments

The Pirate Bay Remains Resilient, 20 Years After the Raid

https://torrentfreak.com/the-pirate-bay-remains-resilient-20-years-after-the-raid/
507•speckx•11h ago•248 comments

Handmade Hawaiian Islands Map

https://www.notesfromtheroad.com/roam/hawaiian-islands-map.html
57•bovermyer•2d ago•18 comments