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

Initial Assessment of Anthropic's Findings on Lattice Cryptography

https://cirg.org/statements/1/
563•nwcs•8h ago•294 comments

Best Buy will officially sell physical media in stores again

https://media4k.pages.dev/best-buy-will-officially-sell-physical-media-in-stores-again/
371•kartik147•8h ago•237 comments

Cloudflare Clairic System One Extraction Models Are Now Open-Weight

https://blog.cloudflare.com/open-clairic/
105•reddmachine•4h ago•24 comments

Red heads are linked to a mutation that makes them resistant to anesthesia (2024)

https://health.clevelandclinic.org/why-do-redheads-need-more-anesthesia
130•illidan1000•6h ago•78 comments

Galactic quasi-polynomial quantum algorithms for integral and module lattices [pdf]

https://github.com/anthropics/formal-math/blob/main/lattices/papers/01-quasi-polynomial-quantum-a...
241•Skrillor•8h ago•122 comments

CrowdGPT – A Collaboratively Trained AI

https://www.crowdgpt.net/
422•Vxtzq•11h ago•156 comments

Advent of Puzzles – An advent calendar with 25 logic puzzles

https://adventofpuzzles.io/
176•ruslan5t•7h ago•48 comments

Usb2shell: Root on Linux from a USB Plug-In

https://usb2shell.com/
235•matanyall•10h ago•98 comments

Satmux: 3.6x faster inflight Wi-Fi via BBR TCP multiplexing

https://github.com/Th0rgal/satmux
95•joshcsimmons•1d ago•7 comments

We Must Pace the Frontier, Part 2

https://darioamodei.com/post/we-must-pace-the-frontier-part-2
472•denysvitali•18h ago•924 comments

Homomorphic encrypted Llama 3.1 8B at 1.7 tokens per second

https://bel.belfortlabs.com/
138•solyin•9h ago•50 comments

People must remain in control of the future

https://openai.com/index/people-must-remain-in-control-of-the-future/
223•j4mie•12h ago•346 comments

Writing a paper is no longer a signal

https://lemire.me/blog/2026/11/30/writing-a-paper-is-no-longer-a-signal/
201•zdw•10h ago•182 comments

Netflix turns low-fidelity media into production-grade HDR with GlowNet

https://netflixtechblog.com/how-netflix-turns-low-fidelity-media-into-production-grade-hdr-with-g...
169•mfrw•12h ago•128 comments

Why is the keyboard and telephone numbers in a different order? (2020)

https://retrocomputing.stackexchange.com/questions/15611
68•Skyfall106•7h ago•20 comments

Post-quantum cryptography is still safe

https://blog.cloudflare.com/pq-is-still-safe/
97•soheilpro•6h ago•13 comments

DoorDash reduced LLM search costs by 98% without losing accuracy

https://careersatdoordash.com/blog/how-doordash-reduced-llm-search-costs-by-98-without-losing-acc...
211•ersinesen•13h ago•175 comments

'Tremendous' sight of bird 106 miles from home

https://www.bbc.co.uk/news/articles/c54gnz3r8ml2o
27•zeristor•23h ago•2 comments

Show HN: Device, a free open-source DAW for Mac, Windows and Linux

https://devicedaw.github.io/
145•devicedaw•12h ago•64 comments

Show HN: Understanding FAT16 – an interactive filesystem explainer

https://fat16.asciitweezers.com/
69•giant_fern•2d ago•4 comments

Krenov's Hand Planes

https://www.thekrenovfoundation.org/krenov100/hand-planes
18•tosh•1d ago•1 comments

Cause of FAA systems failure that grounded flights nationwide identified

https://www.local3news.com/regional-national/cause-of-faa-systems-failure-that-grounded-flights-n...
25•firesteelrain•4h ago•7 comments

Nvdriver is a clean-room, open-source Rust Linux kernel driver for Nvidia GPUs

https://github.com/QuixiAI/nvdriver
866•rreyes1979•19h ago•424 comments

A Visual Guide to Agent Harnesses

https://newsletter.maartengrootendorst.com/p/a-visual-guide-to-agent-harnesses
256•mariuz•14h ago•42 comments

US public sector cyberdefenders can find vulnerabilities with Mythos in GovCloud

https://claude.com/resources/articles/claude-mythos-5-2-in-aws-govcloud
155•lumpa•15h ago•65 comments

iOS on iPod Nano

https://github.com/nfzerox/iOSOniPodNano
196•msephton•2d ago•67 comments

ItaliaCiv

https://italiaciv.it/
109•simonebrunozzi•9h ago•16 comments

Uncovering Hidden TCP Throttling in the Linux Kernel

https://www.cdn77.com/blog/debugging-nginx-linux-contribution
364•josefinaspidlen•18h ago•43 comments

Fractal Cluster

https://hasen.dev/fractal-cluster/
9•hsn915•1d ago•4 comments

Notes on the Martinez-Rueda Polygon Clipping Algorithm: Segments to Paths

https://liorsinai.github.io/mathematics/2026/11/28/graph-computation.html
6•the_origami_fox•1d ago•0 comments