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

Terrence Tao's ChatGPT Conversation about the Jacobian Conjecture Counterexample

https://chatgpt.com/share/6a5fdc7a-d6f8-83e8-bbea-8deb42cfed56
349•gmays•2h ago•170 comments

GigaToken: ~1000x faster Language model tokenization

https://github.com/marcelroed/gigatoken/
209•syrusakbary•3h ago•44 comments

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

https://bento.page/slides/
496•starfallg•5h ago•104 comments

Are AI Labs Pelicanmaxxing?

https://dylancastillo.co/posts/pelicanmaxxing.html
186•dcastm•3h ago•68 comments

Everyone Should Know SIMD

https://mitchellh.com/writing/everyone-should-know-simd
82•WadeGrimridge•2h ago•31 comments

Making

https://beej.us/blog/data/ai-making/
207•erikschoster•4h ago•82 comments

Nobody knows what a used GPU cluster is worth

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

The startup's Postgres survival guide

https://hatchet.run/blog/postgres-survival-guide
243•abelanger•7h ago•132 comments

Nvidia DGX Spark as a daily driver

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

Ghost Cut – or why Cut and Paste is broken everywhere

https://ishmael.textualize.io/blog/ghost-cut/
91•willm•5h ago•60 comments

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

https://cruciblebench.ai/
67•Davisb135•4h ago•38 comments

Mechanical light bulb from 1675 [video]

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

Does creatine make you smarter?

https://dynomight.net/creatine/
170•surprisetalk•4h ago•155 comments

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

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

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

https://twitter.com/mkratsios47/status/2079933645888880708
155•softwaredoug•5h ago•369 comments

10 REM"_(C2SLFF4

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

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

https://unlayer.com
29•adeelraza•4h ago•22 comments

Perlin's Noise Algorithm (2023)

https://blog.jaysmito.dev/blog/02-perlins-noise-algorithm/
51•ibobev•5h ago•11 comments

Introduction to Formal Verification with Lean Part 1

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

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

https://www.orangecrumbs.com/hall/
156•oyster143•4h ago•36 comments

Show HN: Web swing through midtown NYC

https://www.swingnyc.com/
48•shahahmed•4h ago•22 comments

Hologram works. Elixir runs in the browser

https://hologram.page/blog/backing-hologram
79•lawik•5h ago•15 comments

Passkeys were invented by engineers with zero understanding of consumer brain

https://twitter.com/nikitabier/status/2079787406300266743
348•ksec•6h ago•453 comments

OpenNode – Bitcoin Payment Processor

https://opennode.com/
98•gurjeet•5h ago•81 comments

Neo Radar: A browser-based orbital mechanics engine with 41k real asteroids

https://neoradar.space
48•daviazpen•5h ago•14 comments

ICE shared Medicaid data it wasn't supposed to have with Palantir

https://www.npr.org/2026/07/17/nx-s1-5898504/ice-medicaid-palantir-data
37•Jimmc414•1h ago•2 comments

Intel Starts Shipping High-NA EUV Silicon

https://morethanmoore.substack.com/p/intel-starts-shipping-high-na-euv
223•zdw•4d ago•97 comments

LG to ban residential proxies from smart TV apps

https://krebsonsecurity.com/2026/07/lg-to-ban-residential-proxies-from-smart-tv-apps/
366•DemiGuru•18h ago•374 comments

When is NVLink worth it?

https://platform-fools.com/posts/2026-04-27-nvlink/
39•ak_t•6h ago•8 comments

ScreenWall – Turn old phones into synced widgets for your space

https://screenwall.app/
118•buibuibui•5d ago•42 comments