frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

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•7mo ago

Comments

castratikron•7mo 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•7mo 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•7mo 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•7mo 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•7mo 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•7mo ago
in CPU's - pipelining!
jchw•7mo 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...)

Decorative Cryptography

https://www.dlp.rip/decorative-cryptography
28•todsacerdoti•1h ago•5 comments

Databases in 2025: A Year in Review

https://www.cs.cmu.edu/~pavlo/blog/2026/01/2025-databases-retrospective.html
50•viveknathani_•2h ago•5 comments

A spider web unlike any seen before

https://www.nytimes.com/2025/11/08/science/biggest-spiderweb-sulfur-cave.html
40•juanplusjuan•2h ago•19 comments

Lessons from 14 years at Google

https://addyosmani.com/blog/21-lessons/
1215•cdrnsf•18h ago•521 comments

Building a Rust-style static analyzer for C++ with AI

http://mpaxos.com/blog/rusty-cpp.html
52•shuaimu•4h ago•22 comments

Show HN: Terminal UI for AWS

https://github.com/huseyinbabal/taws
303•huseyinbabal•13h ago•151 comments

Logos Language Guide: Compile English to Rust

https://logicaffeine.com/guide
35•tristenharr•3d ago•17 comments

During Helene, I just wanted a plain text website

https://sparkbox.com/foundry/helene_and_mobile_web_performance
187•CqtGLRGcukpy•6h ago•97 comments

The unbearable joy of sitting alone in a café

https://candost.blog/the-unbearable-joy-of-sitting-alone-in-a-cafe/
611•mooreds•18h ago•353 comments

Revisiting the original Roomba and its simple architecture

https://robotsinplainenglish.com/e/2025-12-27-roomba.html
3•ripe•2d ago•0 comments

Why does a least squares fit appear to have a bias when applied to simple data?

https://stats.stackexchange.com/questions/674129/why-does-a-linear-least-squares-fit-appear-to-ha...
236•azeemba•13h ago•62 comments

Street Fighter II, the World Warrier (2021)

https://fabiensanglard.net/sf2_warrier/
375•birdculture•19h ago•63 comments

I charged $18k for a Static HTML Page (2019)

https://idiallo.com/blog/18000-dollars-static-web-page
280•caminanteblanco•2d ago•70 comments

Baffling purple honey found only in North Carolina

https://www.bbc.com/travel/article/20250417-the-baffling-purple-honey-found-only-in-north-carolina
74•rmason•4d ago•19 comments

Monads in C# (Part 2): Result

https://alexyorke.github.io/2025/09/13/monads-in-c-sharp-part-2-result/
15•polygot•3d ago•15 comments

Why Microsoft Store Discontinued Support for Office Apps

https://www.bgr.com/2027774/why-microsoft-store-discontinued-office-support/
14•itronitron•3d ago•7 comments

Web development is fun again

https://ma.ttias.be/web-development-is-fun-again/
381•Mojah•18h ago•475 comments

How to translate a ROM: The mysteries of the game cartridge [video]

https://www.youtube.com/watch?v=XDg73E1n5-g
17•zdw•5d ago•0 comments

Linear Address Spaces: Unsafe at any speed (2022)

https://queue.acm.org/detail.cfm?id=3534854
154•nithssh•5d ago•112 comments

Show HN: An interactive guide to how browsers work

https://howbrowserswork.com/
230•krasun•18h ago•33 comments

Claude Code On-the-Go

https://granda.org/en/2026/01/02/claude-code-on-the-go/
315•todsacerdoti•13h ago•199 comments

Eurostar AI vulnerability: When a chatbot goes off the rails

https://www.pentestpartners.com/security-blog/eurostar-ai-vulnerability-when-a-chatbot-goes-off-t...
139•speckx•12h ago•34 comments

Six Harmless Bugs Lead to Remote Code Execution

https://mehmetince.net/the-story-of-a-perfect-exploit-chain-six-bugs-that-looked-harmless-until-t...
61•ozirus•3d ago•13 comments

NeXTSTEP on Pa-RISC

https://www.openpa.net/nextstep_pa-risc.html
32•andsoitis•8h ago•5 comments

Ripple, a puzzle game about 2nd and 3rd order effects

https://ripplegame.app/
119•mooreds•15h ago•30 comments

ICE Is Using Facial-Recognition Technology to Quickly Arrest People

https://www.wsj.com/politics/policy/ice-facial-recognition-app-mobile-fortify-dfdd00bf
103•KnuthIsGod•4h ago•49 comments

California residents can now request all data brokers delete personal info

https://consumer.drop.privacy.ca.gov/
232•memalign•5h ago•56 comments

Moiré Explorer

https://play.ertdfgcvb.xyz/#/src/demos/moire_explorer
164•Luc•20h ago•19 comments

Agentic Patterns

https://github.com/nibzard/awesome-agentic-patterns
120•PretzelFisch•14h ago•22 comments

Anti-aging injection regrows knee cartilage and prevents arthritis

https://scitechdaily.com/anti-aging-injection-regrows-knee-cartilage-and-prevents-arthritis/
306•nis0s•18h ago•112 comments