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

Shopify is moving from React Native back to Swift and Kotlin

https://shopify.engineering/back-to-native
846•fnthawar2•13h ago•567 comments

More questions about whether researchers can trust OpenAI with unpublished math

https://mathstodon.xyz/@andreasthom/117240535270608201
727•pred_•20h ago•669 comments

YuE2 · Frontier Music with Symbolic Planning

https://map-yue2.github.io/
58•sexy_seedbox•3h ago•47 comments

OpenAI Agents API

https://developers.openai.com/api/docs/guides/agents-api/overview
168•aquir•7h ago•103 comments

Thelio Mira AI Linux Workstation: 192 GB GPU Memory

https://system76.com/workstations/thelio-mira-ai
52•jonifico•4h ago•32 comments

Don't let anyone take away your big box of cables

https://blog.jim-nielsen.com/2026/hands-off-my-cables/
358•Brajeshwar•12h ago•268 comments

Cognition launches new SWE-2 model, Rivaling Fable 5.1 and GPT-Astra

https://cognition.com/blog/swe-2
365•seelos•12h ago•155 comments

Google will buy half the electricity of a nuclear power plant

https://www.bbc.com/news/articles/c8r6y4me2g6o
118•lukaspetersson•2h ago•89 comments

The Deathray: A simple way for an untrusted site to freeze a Mac

https://auberon.xyz/blog/posts/deathray/
106•auberonedu•8h ago•67 comments

Technique for Manipulating Satellite Photos Now Reveals Ancient Images (2025)

https://spinoff.nasa.gov/Manipulating_Satellite_Photos_Now_Reveals_Ancient_Images
284•gumby•12h ago•45 comments

Mexican student creates an acoustic fire extinguisher to put out fire in seconds

https://www.upsocl.com/en/16-year-old-mexican-student-creates-an-acoustic-fire-extinguisher-that-...
70•rguiscard•2h ago•25 comments

NTSB issues investigative update on B-767 runway excursion accident in Miami

https://www.ntsb.gov:443/news/press-releases/Pages/NR20260909.aspx
70•mckn1ght•6h ago•114 comments

Customizing my Compaq MX-11800 keyboard

https://blog.webb.page/WM-102
17•NetOpWibby•3d ago•4 comments

Music Theory for the 21st-Century Classroom

https://musictheory.pugetsound.edu/mt21c/MusicTheory.html
176•aanet•10h ago•79 comments

LLM Visualizer – Build a Transformer from Scratch

https://jayvisaria.github.io/LLM-Visualizer/#/dashboard
7•evo_9•42m ago•2 comments

Proof of Capture: Apple Reference Image, but open source and using steganography

https://merybenavente.me/blog/proof-of-capture
75•merybenavente•7h ago•51 comments

Neki – Sharded Postgres

https://planetscale.com/blog/introducing-neki
212•simon_weber•11h ago•114 comments

Forgejo <=16.0.3 Critical RCE

https://codeberg.org/forgejo/forgejo/src/branch/forgejo/release-notes-published/16.0.4.md
156•weierstass•11h ago•57 comments

Show HN: Algo-Trading-Skills - 501 agent skills for trading infrastructure

https://github.com/HimanshuJ16/Algo-Trading-Skills
4•HimanshuJ16•56m ago•1 comments

Rust is tier-1 language at Microsoft

https://rustfoundation.org/media/guest-post-rust-is-tier-1-language-at-microsoft/
625•mmastrac•13h ago•357 comments

iPhone Duo

https://www.apple.com/iphone-duo/
1418•thecosmicfrog•1d ago•2451 comments

Hitachi launches CO2 heat pump water heaters with solar-friendly tariff controls

https://www.pv-magazine.com/2026/09/07/hitachi-launches-co2-heat-pump-water-heaters-with-solar-fr...
289•thelastgallon•1d ago•234 comments

Recursion into madness

https://blog.coredump.cx/p/recursion-into-madness
49•surprisetalk•3d ago•14 comments

Detecting and countering misuse of AI: September 2026

https://www.anthropic.com/threat-intelligence-report-september-2026
95•garo-pro•10h ago•167 comments

JEP 544: Ahead-of-Time Code Compilation

https://openjdk.org/jeps/544
82•Skinney•10h ago•28 comments

Setting up OpenCode with Ollama and sbx on Mac

https://tensorsandtokens.com/posts/opencode-ollama/
12•etoxin•2h ago•8 comments

Douglas Hofstadter: Analogy as the Core of Cognition [video]

https://www.youtube.com/watch?v=n8m7lFQ3njk
152•tosh•4d ago•75 comments

What happens when a GPU writes memory

https://blog.doubleword.ai/what-happens-when-a-gpu-writes-memory
53•ibobev•2d ago•1 comments

Bitap: My favorite string matching algorithm

https://jo3-l.dev/posts/bitap/
3•haeseong•2d ago•0 comments

Herdr Studio

https://powerfooI.github.io/herdr-studio/
10•throwaway888abc•2h ago•4 comments