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

The session you cannot take with you

https://earendil.com/posts/session-portability/
441•apitman•7h ago•114 comments

DeepSeek V4 Flash 0731 Intelligence, Performance and Price Analysis

https://artificialanalysis.ai/models/deepseek-v4-flash-ga
62•theanonymousone•3h ago•14 comments

JEP 401: Value Objects (Preview) merged to OpenJDK master

https://github.com/openjdk/jdk/pull/31120
141•mfiguiere•7h ago•65 comments

DeepSeek-V4-Flash Update

https://api-docs.deepseek.com/updates/
353•dnhkng•5h ago•170 comments

Stacked PRs are now live on GitHub

https://github.blog/changelog/2026-07-30-stacked-pull-requests-are-now-in-public-preview/
675•tomzorz•19h ago•231 comments

Google fixed more Chrome bugs in June than over the past two years, thanks to AI

https://blog.google/security/chrome-stronger-with-every-update/
137•Garbage•4h ago•153 comments

I flagged two research papers for fake authors and both were accepted as orals

https://geospatialml.com/posts/reviewing-ai-slop/
220•volumes94•13h ago•99 comments

Gemini Robotics 2 brings whole body intelligence to robots

https://deepmind.google/blog/gemini-robotics-2-brings-whole-body-intelligence-to-robots/
573•ai2027•20h ago•458 comments

Show HN: Gander, an Android file viewer that asks for no permissions at all

https://github.com/mokshablr/gander
89•mokshablr•5h ago•44 comments

The mean means nothing: data visualization to debug a latency problem

https://fzakaria.com/2026/07/27/the-mean-means-nothing
54•fanf2•1d ago•8 comments

IMAX vs. IMAX 70mm: The difference between these two cinema formats

https://www.engadget.com/2220571/differences-between-imax-70mm/
12•ksec•5d ago•6 comments

Read this before you buy that TV streaming stick

https://krebsonsecurity.com/2026/07/read-this-before-you-buy-that-tv-streaming-stick/
734•speckx•18h ago•439 comments

The Religion of Speed

https://graybeard.ing/the-religion-of-speed/
181•MobiusHorizons•11h ago•87 comments

Where USB Memory Sticks are Born (2013)

https://www.bunniestudios.com/blog/2013/where-usb-memory-sticks-are-born/
63•jacquesm•3d ago•3 comments

The Economic Benefit of Refactoring

https://martinfowler.com/articles/exploring-gen-ai/refactoring-economic-benefit.html
247•javaeeeee•20h ago•107 comments

Simulating TCP loss and congestion in browser using Go/WASM

https://ccsim.fly.dev
32•dilyevsky•2d ago•1 comments

GCC steering committee announces AI policy

https://lwn.net/Articles/1086041/
307•arto•23h ago•344 comments

Show HN: A udev implementation in Guile Scheme

https://codeberg.org/goodev/goodev
14•mbakke•3d ago•5 comments

Bad Apple but It's Traceroute

https://jssfr.de/2026-07-27-bad-apple-but-traceroute.html
125•jssfr•3d ago•41 comments

Obfuscation (Part II): Diamond IO

https://vitalik.eth.limo/general/2026/07/28/obfuscation_part_ii_diamond_io.html
7•elffjs•2d ago•1 comments

Memo-1: A 6502 computer built from scratch, using a Minitel as its terminal

https://github.com/MemoireMorte/Memo-1
81•sciences44•2d ago•11 comments

The AI Aesthetic

https://blog.jim-nielsen.com/2026/ai-aesthetic/
318•montroser•12h ago•143 comments

The lost civic life of movie rental stores

https://thereader.mitpress.mit.edu/the-lost-civic-life-of-movie-rental-stores/
177•facundo_olano•21h ago•233 comments

UEFA and its national associations will not participate in FIFA competitions

https://www.uefa.com/news-media/news/02a7-213a92896eb0-54dfbf454e3b-1000--statement-on-behalf-of-...
1076•dickfickling•17h ago•581 comments

CodePen 2.0

https://chriscoyier.net/2026/07/30/codepen-2-0/
171•robin_reala•17h ago•49 comments

Physicists Solve a Muon Mystery. Now, Old Results Don't Add Up

https://www.quantamagazine.org/physicists-solve-a-muon-mystery-now-old-results-dont-add-up-20260729/
222•ibobev•20h ago•151 comments

Rune 1.1: adds Python, an Emacs editor, a symbol index and is now free

https://rune.build/blog/rune-1-1-release
84•ernestrc•13h ago•37 comments

Why is everyone trying to build a solid-state battery?

https://www.construction-physics.com/p/why-is-everyone-trying-to-build-a
198•crescit_eundo•23h ago•247 comments

Show HN: Distilling DeepSeek into GPT-OSS doesn't transfer censorship. Try it

https://www.ctgt.ai/research/distillation-censorship-transfer
133•cgorlla•17h ago•67 comments

Saber-toothed cats became inbred–and struggled to move–before they went extinct

https://www.science.org/content/article/saber-toothed-cats-became-inbred-and-struggled-move-they-...
62•gmays•14h ago•25 comments