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

Show HN: Minimalist editor that lives in browser, stores everything in the URL

https://github.com/antonmedv/textarea
44•medv•47m ago•17 comments

Fabrice Bellard: Biography [pdf]

https://www.ipaidia.gr/wp-content/uploads/2020/12/117-2020-fabrice-bellard.pdf
66•lioeters•2h ago•12 comments

European Majority favours more tech regulation

https://yougov.co.uk/technology/articles/53241-european-political-monthly-where-do-europeans-stan...
19•snowpid•57m ago•9 comments

Show HN: Vibium – Browser automation for AI and humans, by Selenium's creator

https://github.com/VibiumDev/vibium
89•hugs•2h ago•45 comments

When Compilers Surprise You

https://xania.org/202512/24-cunning-clang
159•brewmarche•7h ago•61 comments

A faster path to container images in Bazel

https://www.tweag.io/blog/2025-12-18-rules_img/
36•malt3•6d ago•13 comments

My 2026 Open Social Web Predictions

https://www.timothychambers.net/2025/12/23/my-open-social-web-predictions.html
46•todsacerdoti•4h ago•30 comments

Some Epstein file redactions are being undone

https://www.theguardian.com/us-news/2025/dec/23/epstein-unredacted-files-social-media
867•vinni2•1d ago•684 comments

Looking for Decent Conversation?

38•kmstout•1h ago•3 comments

Beijing is enforcing tough rules to ensure chatbots don’t misbehave

https://www.wsj.com/tech/ai/china-is-worried-ai-threatens-party-ruleand-is-trying-to-tame-it-bfdc...
13•bookofjoe•25m ago•2 comments

Researchers achieved 1,270 Wh/L in an anode-free lithium metal battery

https://postech.ac.kr/eng/research/research_results.do?mode=view&articleNo=43617&title=Anode-Free...
72•giuliomagnifico•2h ago•32 comments

X-ray: a Python library for finding bad redactions in PDF documents

https://github.com/freelawproject/x-ray
636•rendx•22h ago•108 comments

Avoid Mini-Frameworks

https://laike9m.com/blog/avoid-mini-frameworks,171/
82•laike9m•8h ago•71 comments

Qntm's Power Tower Toy

https://qntm.org/files/knuth/knuth.html
4•ravenical•4d ago•0 comments

Fabrication Techniques Using Myco-Materials

https://encyclopedia.pub/entry/27602
8•andsoitis•2d ago•1 comments

Making a game on a custom bytecode VM in 7 days and 3kB

https://laurent.le-brun.eu/blog/making-a-game-on-a-custom-bytecode-vm-in-7-days-and-3kb
59•laurentlb•5d ago•8 comments

I'm returning my Framework 16

https://yorickpeterse.com/articles/im-returning-my-framework-16/
76•YorickPeterse•7h ago•96 comments

Games’ affordance of childlike wonder and reduced burnout risk in young adults

https://games.jmir.org/2025/1/e84219/
109•azalemeth•6h ago•91 comments

The Port I couldn't Ship

https://ammil.industries/the-port-i-couldnt-ship/
84•cjlm•6d ago•41 comments

AMD entered the CPU market with reverse-engineered Intel 8080 clone 50 years ago

https://www.tomshardware.com/pc-components/cpus/amd-first-entered-the-cpu-market-with-reverse-eng...
126•ksec•6h ago•58 comments

Unifi Travel Router

https://blog.ui.com/article/travel-in-style-unifi-style-unifi-travel-router
424•flurdy•19h ago•366 comments

LVM Thin Provisioning (2016)

https://storageapis.wordpress.com/2016/06/24/lvm-thin-provisioning/
15•indigodaddy•2d ago•3 comments

The e-scooter isn't new – London was zooming around on Autopeds a century ago

https://www.ianvisits.co.uk/articles/the-e-scooter-isnt-new-london-was-zooming-around-on-autopeds...
107•zeristor•11h ago•91 comments

Spice: A 40-year old open-source success story (2011)

https://www.edn.com/spice-a-40-year-old-open-source-success-story/
7•stmw•3h ago•1 comments

Nabokov's guide to foreigners learning Russian

https://twitter.com/haravayin_hogh/status/2003299405907247502
201•flaxxen•19h ago•361 comments

Why We Abandoned Matrix (2024)

https://forum.hackliberty.org/t/why-we-abandoned-matrix-the-dark-truth-about-user-security-and-sa...
159•Flere-Imsaho•5h ago•124 comments

Microsoft Agent Framework

https://learn.microsoft.com/en-us/agent-framework/overview/agent-framework-overview
33•mooreds•2h ago•20 comments

Fabrice Bellard Releases MicroQuickJS

https://github.com/bellard/mquickjs/blob/main/README.md
1317•Aissen•1d ago•502 comments

Permission Systems for Enterprise That Scale

https://eliocapella.com/blog/permission-systems-for-enterprise/
72•eliocs•10h ago•28 comments

Show HN: LazyPromise = Observable – Signals

https://github.com/lazy-promise/lazy-promise
23•ivan7237d•5d ago•4 comments