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

Cherenkov Radiation - traveling faster than light

http://www.iaea.org/newscenter/news/what-is-cherenkov-radiation
31•andsoitis•1h ago•19 comments

Shopify is moving from React Native back to Swift and Kotlin

https://shopify.engineering/back-to-native
1069•fnthawar2•19h ago•743 comments

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

https://blog.jim-nielsen.com/2026/hands-off-my-cables/
527•Brajeshwar•18h ago•339 comments

Working with Git Worktrees in Magit

https://emacsredux.com/blog/2026/09/02/working-with-git-worktrees-in-magit/
46•srijan4•3d ago•13 comments

OpenAI Agents API

https://developers.openai.com/api/docs/guides/agents-api/overview
265•aquir•14h ago•145 comments

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

https://auberon.xyz/blog/posts/deathray/
189•auberonedu•14h ago•114 comments

The Gemini app is now available for Windows

https://blog.google/innovation-and-ai/products/gemini-app/gemini-app-now-on-windows/
48•quysala12•4h ago•35 comments

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

https://spinoff.nasa.gov/Manipulating_Satellite_Photos_Now_Reveals_Ancient_Images
336•gumby•18h ago•55 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-...
206•rguiscard•8h ago•75 comments

Nine coding harnesses vs. your laptop

https://nasutton.notion.site/Nine-coding-harnesses-vs-your-laptop-3d139990182b80d59fa3cf500f0450b...
96•nasutton12•10h ago•25 comments

Neijuan

https://en.wikipedia.org/wiki/Neijuan
19•vermilingua•1h ago•7 comments

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

https://www.ntsb.gov:443/news/press-releases/Pages/NR20260909.aspx
104•mckn1ght•12h ago•177 comments

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

https://cognition.com/blog/swe-2
414•seelos•18h ago•173 comments

More questions about whether researchers can trust OpenAI with unpublished math

https://mathstodon.xyz/@andreasthom/117240535270608201
809•pred_•1d ago•742 comments

GPT‑Live‑1 in the API

https://openai.com/index/introducing-gpt-live-1-in-the-api/
14•arittr•4h ago•6 comments

Music Theory for the 21st-Century Classroom

https://musictheory.pugetsound.edu/mt21c/MusicTheory.html
224•aanet•16h ago•95 comments

Forgejo <=16.0.3 Critical RCE

https://codeberg.org/forgejo/forgejo/src/branch/forgejo/release-notes-published/16.0.4.md
185•weierstass•17h ago•68 comments

Thelio Mira AI Linux Workstation: 192 GB GPU Memory

https://system76.com/workstations/thelio-mira-ai
105•jonifico•10h ago•85 comments

Neki – Sharded Postgres

https://planetscale.com/blog/introducing-neki
243•simon_weber•18h ago•131 comments

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

https://merybenavente.me/blog/proof-of-capture
106•merybenavente•14h ago•58 comments

Testing race conditions with mem access tracing and stack-based delay injection

https://projectzero.google/2026/09/maccconc-race-condition.html
8•mfrw•2d ago•0 comments

Rust is tier-1 language at Microsoft

https://rustfoundation.org/media/guest-post-rust-is-tier-1-language-at-microsoft/
675•mmastrac•20h ago•422 comments

Astra for Coding: Why Are We Doing This Again?

https://lucumr.pocoo.org/2026/9/7/astra-why/
319•manojbajaj95•3h ago•237 comments

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

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

Detecting and countering misuse of AI: September 2026

https://www.anthropic.com/threat-intelligence-report-september-2026
130•garo-pro•16h ago•200 comments

So you want to use OpenRouter?

https://mmoustafa.com/blog/so-you-want-to-use-openrouter/
71•player85•2d ago•5 comments

Exercise intensity is associated with cardiometabolic health

https://www.cell.com/cell-reports-medicine/fulltext/S2666-3791(26)00405-2
97•qclibre22•6h ago•44 comments

YuE2 · Frontier Music with Symbolic Planning

https://map-yue2.github.io/
94•sexy_seedbox•9h ago•78 comments

DeepSeek v4.1 Flash Uncensored

https://huggingface.co/dealignai/DeepSeek-V4.1-Flash-UNCENSORED-FP8
39•soltanov•3h ago•7 comments

Recursion into madness

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