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

Qwen 3.8 27B is excellent, but it defaults to overthinking things

https://simonwillison.net/2026/Aug/16/qwen-38-27b/
525•bilsbie•11h ago•251 comments

On A.I. regulation and messaging

https://twitter.com/DarioAmodei/status/2088758816376807762
76•jacquesm•9h ago•137 comments

The continuing "Q collar" scandal

https://statmodeling.stat.columbia.edu/2026/08/13/we-should-probably-be-doing-more-coverage-of-sc...
21•luu•3d ago•4 comments

A third world engineer responds to “RISC-V: They should have known better”

https://rvembedded.com/blog_post/12/
527•Narishma•18h ago•272 comments

Anthropic's 'watermark' text adulteration in Claude is a perversion of writing

https://daringfireball.net/2026/08/anthropics_watermark_text_adulteration_in_claude_is_a_perversi...
311•ropbear•13h ago•311 comments

Reticulum – Decentralized Mesh Network

https://reticulum.network/
135•sudo_cowsay•11h ago•41 comments

Claude: System Prompts

https://platform.claude.com/docs/en/release-notes/system-prompts
671•tosh•22h ago•258 comments

Gakutensoku

https://en.wikipedia.org/wiki/Gakutensoku
35•benbreen•3d ago•3 comments

AGI-64 Brings Sierra Adventures to the Commodore 64

https://meanhamster.com/news/agi-64-brings-sierra-adventures-to-the-commodore-64
89•erickhill•9h ago•10 comments

Rhombus 1.1 is now available

https://blog.racket-lang.org/2026/08/rhombus-v1.1.html
90•spdegabrielle•10h ago•28 comments

Linear algebra done right

https://linear.axler.net/
94•the-mitr•5h ago•40 comments

How do I permanently disable random Google Photos popup to backup photos? (2024)

https://support.google.com/photos/thread/256212140/how-do-i-permanently-disable-google-photos-pop...
133•dt3ft•3d ago•83 comments

SIMD in the 90s: Programming Intel's Pentium MMX

https://pikuma.com/blog/programming-intel-pentium-mmx-simd
123•ibobev•3d ago•52 comments

Design 3D-printable parts by talking

https://nurb.dev/
25•mkmk•2d ago•12 comments

Applying a photosynthetic process to treat “dry eye”

https://www.science.org/content/blog-post/taking-tip-plants-eyes
48•gumby•10h ago•15 comments

GIMP Development Update

https://www.gimp.org/news/2026/08/16/dev-update-august-2026/
189•lumpa•7h ago•139 comments

The Mysterious Syndrome Destroying Endurance Athletes

https://www.outsideonline.com/health/training-performance/running-empty/
9•cwwc•2d ago•2 comments

Production-ready detection and response queries for osquery

https://github.com/chainguard-dev/osquery-defense-kit
3•ankitg12•4d ago•0 comments

The AI Credit Resale Economy

https://vectoral.com/blog/who-are-the-token-brokers
297•mlenhard•20h ago•120 comments

Red queen hypothesis – A new way forward for self-improving AI

https://www.cst.cam.ac.uk/news/red-queen-hypothesis-new-way-forward-self-improving-ai
69•hardlianotion•15h ago•18 comments

Prolly: A content-addressed ordered map built on prolly trees

https://github.com/crabbuild/prolly
46•forhappy•10h ago•4 comments

Tell HN: Cloudflare silently injects its analytics when you switch nameservers

525•stagas•17h ago•147 comments

Protobuf has LSP support

https://buf.build/blog/protobuf-lsp
157•theanonymousone•16h ago•109 comments

Strong gravitational lensing and microlensing of supernovae (2024)

https://infoscience.epfl.ch/entities/publication/644cad8a-6c9b-4b02-bcf3-b8b6e8c614c5
12•andsoitis•8h ago•1 comments

Show HN: Desktopcolors.com – A museum for solid background colors of classic OS

https://desktopcolors.com
6•vlowrian•3h ago•0 comments

MathCode, Mathematical Coding Agent

https://math-ai-org.github.io/mathcode/
95•homarp•16h ago•28 comments

Stripe will reportedly acquire OpenRouter for $7B+

https://techcrunch.com/2026/08/16/stripe-will-reportedly-acquire-ai-gateway-startup-openrouter-fo...
370•zacharyozer•14h ago•229 comments

Clamiga: Common Lisp for the Amiga

https://nnamgreb.de/blog/Clamiga+-+Common+Lisp+for+the+Amiga
116•emptybits•4d ago•19 comments

GPS and the Lost Art of Getting Lost

https://www.newyorker.com/news/annals-of-inquiry/gps-and-the-lost-art-of-getting-lost
82•karakoram•20h ago•72 comments

Plastic mechanical computer from 1963: The Digi-Comp 1 [video]

https://www.youtube.com/watch?v=-y8bGBE71yw
69•tobr•1d ago•18 comments