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

Jerry's Map

http://www.jerrysmap.com/the-map
214•turtleyacht•2h ago•25 comments

Don't verify email addresses by sending spam to them

https://milek7.pl/mailverifyspam/
47•garaetjjte•1h ago•2 comments

Swift Package Index joins Apple

https://swiftpackageindex.com/blog/swift-package-index-joins-apple
126•JDevlieghere•3h ago•39 comments

All train services in Germany halted after train radio communications disruption

https://english.news.cn/20260624/65f1b6192cd947e28849776a5aef05c6/c.html
20•sva_•19m ago•4 comments

FUTO Swipe – A new swipe typing model

https://swipe.futo.tech/
114•futohq•3h ago•40 comments

Printing Gaussian Splats

https://www.patreon.com/DanyBittel/posts/printing-splats-161333338
62•ilnmtlbnm•2d ago•2 comments

Show HN: TikZ Editor – WYSIWYG editor for figures in LaTeX

https://tikz.dev/editor/
283•DominikPeters•7h ago•58 comments

German Rail Service Suspended Due to Radio Interference

https://www.bluewin.ch/en/news/german-rail-service-suspended-due-to-radio-interference-li.3295297
13•sva_•14m ago•0 comments

F3

https://github.com/future-file-format/f3
546•tosh•4h ago•124 comments

The worthlessness of Vitamin D is mildly exaggerated

https://dynomight.net/vitamin-d/
115•surprisetalk•5h ago•82 comments

Unlimited OCR: One-shot long-horizon parsing

https://github.com/baidu/Unlimited-OCR
402•ingve•9h ago•95 comments

The deadly rise of giant trucks and SUVs

https://www.nytimes.com/interactive/2026/06/21/us/trucks-suv-pedestrian-crashes.html
271•xnx•1d ago•458 comments

AI Hiring Tools Yield Racial Bias and Systemic Rejection; 26% Black & 15% Asian

https://hai.stanford.edu/news/ai-hiring-tools-can-yield-racial-bias-and-systemic-rejection
94•sizzle•2h ago•76 comments

Five monitors on a Commodore 128 [video]

https://www.youtube.com/watch?v=ul5hC3PY1Yg
84•EvanAnderson•1d ago•16 comments

The Coming Loop

https://lucumr.pocoo.org/2026/6/23/the-coming-loop/
252•ingve•10h ago•200 comments

Lift4D: Harmonizing Single-View 3D Estimation for 4D Reconstruction In-the-Wild

https://lift4d.github.io/
95•ilreb•6h ago•9 comments

San Diego photologs from the 1970s

https://www.beautifulpublicdata.com/san-diego-photologs-from-the-1970s/
128•jonathanmkeegan•4h ago•37 comments

Samsung demonstrates 3D stacked FETs with triple nanosheet channels at 42nm

https://semiconductor.samsung.com/news-events/tech-blog/from-gaa-to-3d-stacked-fet-expanding-the-...
68•its_ajseven•4d ago•21 comments

Claude Tag

https://www.anthropic.com/news/introducing-claude-tag
190•adocomplete•4h ago•117 comments

Show HN: The Cascade Graph – An interactive map of AI and energy constraints

https://atomprophet.io/tools/cascade/
8•antisyzygy•6h ago•4 comments

Plotnine

https://plotnine.org/
241•tosh•4d ago•71 comments

Mistral OCR 4

https://mistral.ai/news/ocr-4/
388•meetpateltech•7h ago•102 comments

F* file system – file search that reads SSD directly bypassing OS kernel

https://github.com/dmtrKovalenko/ffs
4•neogoose•2d ago•5 comments

Performance Improvements in Libffi

https://atgreen.github.io/repl-yell/posts/libffi-plan-cache/
30•atgreen•2d ago•6 comments

Solving Wordle using information theory

https://www.binghamton.edu/news/story/6327/s-m-a-r-t-these-researchers-used-math-to-crack-wordle
49•hhs•2d ago•53 comments

MSG Made Dossier on Activists Who Opposed Facial Recognition

https://www.404media.co/madison-square-garden-made-dossier-on-activists-who-opposed-facial-recogn...
267•cdrnsf•7h ago•75 comments

The Low-Tech AI of Elden Ring

https://nega.tv/posts/low-tech-ai-of-elden-ring.html
78•g0xA52A2A•9h ago•48 comments

Show HN: Bun-sqlgen – Type-safe raw SQL for Bun, no ORM

https://github.com/ilbertt/bun-sqlgen
50•ilbert•7h ago•23 comments

Finding the best dog treat with statistics

https://www.wespiser.com/posts/2026-06-19-best-dog-treat.html
124•wespiser_2018•1d ago•54 comments

Elevated error rate across multiple models

https://status.claude.com/incidents/jbhf20wjmzrf
195•rob•7h ago•245 comments