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

John C. Dvorak has died

https://twitter.com/na_announce/status/2079952538040672302
146•coleca•1h ago•26 comments

Terrence Tao's ChatGPT Conversation about the Jacobian Conjecture Counterexample

https://chatgpt.com/share/6a5fdc7a-d6f8-83e8-bbea-8deb42cfed56
403•gmays•3h ago•211 comments

GigaToken: ~1000x faster Language model tokenization

https://github.com/marcelroed/gigatoken/
245•syrusakbary•3h ago•47 comments

Show HN: Bento - An entire PowerPoint in one HTML file (edit+view+data+collab)

https://bento.page/slides/
526•starfallg•5h ago•115 comments

Are AI Labs Pelicanmaxxing?

https://dylancastillo.co/posts/pelicanmaxxing.html
232•dcastm•3h ago•97 comments

Everyone Should Know SIMD

https://mitchellh.com/writing/everyone-should-know-simd
123•WadeGrimridge•3h ago•35 comments

I Inspected My Take-Home Interview Project. It Was a Whole Operation

https://citizendot.github.io/articles/fake-job-interview-git-hook-malware/
14•CITIZENDOT•34m ago•0 comments

Nvidia DGX Spark as a daily driver

https://daniel.lawrence.lu/blog/2026-07-15-dgx-spark-as-daily-driver/
43•plun9•3d ago•17 comments

Making

https://beej.us/blog/data/ai-making/
216•erikschoster•5h ago•92 comments

Nobody knows what a used GPU cluster is worth

https://ciphertalk.substack.com/p/nobody-knows-what-a-used-gpu-cluster
109•rbanffy•1w ago•91 comments

The startup's Postgres survival guide

https://hatchet.run/blog/postgres-survival-guide
258•abelanger•8h ago•142 comments

Safari Technology Preview 248 Released

https://webkit.org/blog/18162/release-notes-for-safari-technology-preview-248/
4•Erenay09•8m ago•0 comments

Ghost Cut – or why Cut and Paste is broken everywhere

https://ishmael.textualize.io/blog/ghost-cut/
98•willm•6h ago•67 comments

Can a MUD evaluate LLMs? A $99 proof of concept

https://cruciblebench.ai/
78•Davisb135•5h ago•45 comments

Taking OCaml and Eio for a Spin

https://mattjhall.co.uk/posts/taking-ocaml-eio-for-a-spin.html
8•mattjhall•2d ago•0 comments

Launch HN: Unlayer (YC W22) – Add email and document builders to your app

https://unlayer.com
34•adeelraza•5h ago•22 comments

Mechanical light bulb from 1675 [video]

https://www.youtube.com/watch?v=0Y-9GbsS9Fg
57•kadohg•1w ago•28 comments

Does creatine make you smarter?

https://dynomight.net/creatine/
190•surprisetalk•5h ago•182 comments

Full Scale Foldable Wing Extensions

https://www.airbus.com/en/newsroom/press-releases/2026-07-airbus-launches-new-flight-test-program...
56•r2sk5t•6h ago•48 comments

“We have information that Moonshot distilled Fable for the development of K3”

https://twitter.com/mkratsios47/status/2079933645888880708
176•softwaredoug•6h ago•422 comments

10 REM"_(C2SLFF4

https://beej.us/blog/data/mystery-comment/
143•ingve•9h ago•40 comments

Show HN: DeepSQL – A self-hostable DBA agent for Postgres and MySQL

https://deepsql.ai/
37•venkat971•2d ago•19 comments

Which streaming service was that on again?

https://www.timwehrle.de/blog/which-streaming-service-was-that-on-again/
25•weetii•6h ago•43 comments

Introduction to Formal Verification with Lean Part 1

https://hashcloak.com/blog/tutorial-introduction-to-formal-verification-with-lean-(part-1)
216•badcryptobitch•3d ago•41 comments

Perlin's Noise Algorithm (2023)

https://blog.jaysmito.dev/blog/02-perlins-noise-algorithm/
52•ibobev•6h ago•13 comments

Show HN: HN Hall of Fame – browse 3,100 legendary Hacker News links

https://www.orangecrumbs.com/hall/
162•oyster143•5h ago•36 comments

Critical Minerals: Reducing U.S. import reliance with substitution and recycling

https://www.gao.gov/products/gao-26-108687
39•Jimmc414•5h ago•59 comments

Show HN: Web swing through midtown NYC

https://www.swingnyc.com/
52•shahahmed•4h ago•23 comments

Teardown: The BMW / Harman IDC23H Infotainment Unit (B423)

https://www.hakstuff.net/blog/teardown-the-bmw-idc23h-infotainment-unit
4•JojoFatsani•1h ago•0 comments

Passkeys were invented by engineers with zero understanding of consumer brain

https://twitter.com/nikitabier/status/2079787406300266743
371•ksec•6h ago•487 comments