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

Advent of Code 2026

https://adventofcode.com/2026
129•meffmadd•45m ago•56 comments

Fake Meta Ads Manager apps passed App Store review; two ran as Apple's top ad

https://husseinsaleh.com/2026/12/01/fake-meta-ads-manager-apps-pass-app-store-review-apple-ads/
70•itshusseinsaleh•57m ago•21 comments

Bob's Company

https://lucumr.pocoo.org/2026/11/28/bob/
312•BerislavLopac•5h ago•161 comments

Show HN: A GUI for polishing the text your coding agent writes

https://draftmux.raine.dev/
89•rane•3h ago•29 comments

Squashfs: Fix a lot of AI issues and AI style issues

https://lkml.iu.edu/hypermail/linux/kernel/2611.2/22806.html
149•gpi•2h ago•93 comments

Goals don't work. Rely on your values

https://adam.ci/train/goals-do-not-work/
104•adamci•3h ago•48 comments

Nuclear magnetic resonance on a single atom with a local probe

https://www.nature.com/articles/s41467-026-78801-5
16•Cilan798•1d ago•1 comments

Baggins End

https://www.bagginsend.net/
35•tosh•2h ago•10 comments

Initial Assessment of Anthropic's Findings on Lattice Cryptography

https://cirg.org/statements/1/
733•nwcs•15h ago•377 comments

Best Buy Putting 4K UHD Discs Back on Store Shelves

https://www.mediaplaynews.com/the-odyssey-was-not-a-one-off-best-buy-putting-4k-uhd-discs-back-on...
539•kartik147•15h ago•392 comments

Adhesive coatings in naval archaeology: Materials from Roman Republican wreck

https://www.frontiersin.org/journals/materials/articles/10.3389/fmats.2026.1758862/full
15•bookofjoe•2d ago•0 comments

'Big fat lady' hawk who ate too many chickens to fly soars free once again

https://www.cbc.ca/radio/asithappens/hefty-hawk-released-9.7439479
58•randycupertino•2d ago•15 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
245•illidan1000•13h ago•139 comments

Cloudflare Clairic System One Extraction Models Are Now Open-Weight

https://blog.cloudflare.com/open-clairic/
228•reddmachine•11h ago•46 comments

CrowdGPT – A Collaboratively Trained AI

https://www.crowdgpt.net/
532•Vxtzq•18h ago•203 comments

Hetzner Inference API

https://www.hetzner.com/ai/inference-api/
338•PaoloBarbolini•5h ago•119 comments

The Exponential Rise of Agent Instruction Files

https://homes.cs.washington.edu/~reshabh/posts/exponential-rise-of-agent-instruction-files.html
38•reshabh•2d ago•23 comments

Chez Scheme from a Clojurian Perspective

https://get-aksh.com/blog/chez-from-a-clojurian-perspective
49•pushpankar•2d ago•35 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...
291•Skrillor•15h ago•152 comments

Usb2shell: Root on Linux from a USB Plug-In

https://usb2shell.com/
321•matanyall•17h ago•141 comments

Advent of Puzzles – An advent calendar with 25 logic puzzles

https://adventofpuzzles.io/
294•ruslan5t•14h ago•71 comments

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

https://github.com/Th0rgal/satmux
138•joshcsimmons•2d ago•21 comments

Homomorphic encrypted Llama 3.1 8B at 1.7 tokens per second

https://bel.belfortlabs.com/
221•solyin•16h ago•87 comments

Reading unreadable tapes: A universal reader for mini QIC cartridges

https://dmitrybrant.com/2026/11/28/mini-qic-universal-reader
43•zdw•2d ago•5 comments

Writing a paper is no longer a signal

https://lemire.me/blog/2026/11/30/writing-a-paper-is-no-longer-a-signal/
309•zdw•17h ago•249 comments

Post-quantum cryptography is still safe

https://blog.cloudflare.com/pq-is-still-safe/
169•soheilpro•12h ago•32 comments

A Visual Guide to Agent Harnesses

https://newsletter.maartengrootendorst.com/p/a-visual-guide-to-agent-harnesses
375•mariuz•21h ago•62 comments

People must remain in control of the future

https://openai.com/index/people-must-remain-in-control-of-the-future/
286•j4mie•19h ago•429 comments

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

https://retrocomputing.stackexchange.com/questions/15611
120•Skyfall106•14h ago•41 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...
248•ersinesen•20h ago•193 comments