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

We're making Bunny DNS free: because a faster internet won't build itself

https://bunny.net/blog/were-making-bunny-dns-free/
215•dabinat•2h ago•66 comments

Vulnerability reports are not special anymore

https://words.filippo.io/vuln-reports/
298•goranmoomin•11h ago•165 comments

Statistics that live in your SQL

https://kolistat.com/blog/the-stats-duck-v0-6-0/
20•caerbannogwhite•1d ago•0 comments

Raspberry Pi Pico W as USB Wi-Fi Adapter

https://gitlab.com/baiyibai/pico-usb-wifi
153•byb•8h ago•58 comments

Jerry's Map

http://www.jerrysmap.com/the-map
490•turtleyacht•16h ago•55 comments

In memory of the man who put red and green squiggles under words

https://devblogs.microsoft.com/oldnewthing/20260622-00/?p=112451
426•saikatsg•17h ago•68 comments

FUTO Swipe – A new swipe typing model

https://swipe.futo.tech/
571•futohq•17h ago•193 comments

Why eval startups fail (2025)

https://thomasliao.com/eval-startups
30•jxmorris12•1d ago•30 comments

Show HN: An ASCII 3D Rendering Engine

https://glyphcss.com
159•apresmoi•3d ago•41 comments

Qwen-AgentWorld: Language World Models for General Agents

https://arxiv.org/abs/2606.24597
119•ilreb•9h ago•39 comments

"Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds

https://gist.github.com/retroplasma/ec21767d0a8380c7ea9c2fbee1c7d6bf
117•retroplasma•8h ago•45 comments

François Englert (1932 – 2026)

https://home.cern/francois-englert-1932-2026/
7•toomuchtodo•3d ago•1 comments

Printing Gaussian Splats

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

Vector Graphics in Lil

http://beyondloom.com/blog/vectorgraphics.html
18•RodgerTheGreat•1d ago•0 comments

Ashby (YC W19) Is Hiring EMEA Engineers Who Can Design

https://www.ashbyhq.com/careers?ashby_jid=87b96eef-edc1-4de4-adb6-d460126d02f8&utm_source=hn
1•abhikp•4h ago

Rhombus Language 1.0

https://blog.racket-lang.org/2026/06/rhombus-v1.0.html
183•Decabytes•1d ago•55 comments

Remaking BBC test cards to teach you video processing

https://www.youtube.com/watch?v=U_6HxPkrgcg
47•unleaded•2d ago•2 comments

Swift Package Index joins Apple

https://swiftpackageindex.com/blog/swift-package-index-joins-apple
212•JDevlieghere•17h ago•70 comments

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

https://tikz.dev/editor/
403•DominikPeters•21h ago•73 comments

Usbliter8: an A12/A13 SecureROM Exploit

https://ps.tc/pages/blog-usbliter8.html
151•givinguflac•5d ago•30 comments

The worthlessness of Vitamin D is mildly exaggerated

https://dynomight.net/vitamin-d/
311•surprisetalk•19h ago•225 comments

How to burst the AI bubble: Strike at its roots

https://arstechnica.com/gadgets/2026/06/how-to-burst-the-ai-bubble-strike-at-its-roots/
26•0nce•1h ago•15 comments

A man was gifted his dream car by Kevin Mitnick, who he helped put in prison

https://www.thedrive.com/news/this-man-was-gifted-his-dream-car-by-the-notorious-hacker-he-put-in...
187•mauvehaus•1d ago•127 comments

Dirty Little Zine – a tool for making an 8 page printable Zine

https://dirtylittlezine.com/
130•cianmm•3d ago•21 comments

Millimeter wave technology drills 100 meters into granite

https://www.thinkgeoenergy.com/quaise-energy-achieves-100-meters-of-drilling-using-millimeter-wav...
172•Jimmc414•3d ago•66 comments

The Teensy Executable Revisited

https://www.muppetlabs.com/~breadbox/software/tiny/revisit.html
44•ankitg12•9h ago•3 comments

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

https://github.com/dmtrKovalenko/ffs
87•neogoose•2d ago•44 comments

Fired by Google for creating the Google workspace CLI

https://twitter.com/JPoehnelt/status/2069482265953087602
564•justinwp•17h ago•337 comments

The Low-Tech AI of Elden Ring

https://nega.tv/posts/low-tech-ai-of-elden-ring.html
150•g0xA52A2A•23h ago•88 comments

Inventing the Future, One Lisp Machine at a Time

https://www.patrickdomanico.com/bpm/2026/06/16/inventing-the-future-one-lisp-machine-at-a-time/
107•pamoroso•1d ago•15 comments