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/
120•bilsbie•3h ago•47 comments

The Life and Death of Direct File [pdf]

https://www.ischool.berkeley.edu/sites/default/files/vinton_report_5.pdf
105•ronbenton•3h ago•32 comments

AGI-64 Brings Sierra Adventures to the Commodore 64

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

Rhombus 1.1 is now available

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

A 3rd World Embedded Engineer Responds to "RISC-V They Should Have Known Better"

https://rvembedded.com/blog_post/12/
398•Narishma•10h ago•215 comments

Claude: System Prompts

https://platform.claude.com/docs/en/release-notes/system-prompts
566•tosh•14h ago•234 comments

Reticulum – Decentralized Mesh Network

https://reticulum.network/
30•sudo_cowsay•3h ago•7 comments

Low-Tech Ceramic Water Filter

https://wiki.lowtechlab.org/wiki/Filtre_%C3%A0_eau_c%C3%A9ramique/en
115•Bluestein•5d ago•31 comments

Interview with Amit Patel, Creator of "Solar Realms Elite"

https://breakintochat.com/blog/2013/02/18/amit-patel-creator-of-solar-realms-elite/
20•bananaboy•1w ago•1 comments

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

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

Protobuf has LSP support. You're welcome

https://buf.build/blog/protobuf-lsp
128•theanonymousone•8h ago•84 comments

The federal keyword lists that canceled billions in research funding

https://www.highereddive.com/news/inside-the-federal-keyword-lists-that-canceled-billions-in-rese...
126•walrus01•3h ago•21 comments

Dancing with friends and enemies: boids' swarm intelligence

https://community.wolfram.com/groups/-/m/t/122095
20•surprisetalk•5d ago•1 comments

The AI Credit Resale Economy

https://vectoral.com/blog/who-are-the-token-brokers
238•mlenhard•12h ago•93 comments

MathCode, Mathematical Coding Agent

https://math-ai-org.github.io/mathcode/
70•homarp•9h ago•23 comments

Clamiga: Common Lisp for the Amiga

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

Nvidia dramatically reduces amount of OpenAI infra financing it may guarantee

https://www.reuters.com/business/nvidia-scales-back-250-billion-openai-data-center-guarantee-wsj-...
131•root-parent•6h ago•49 comments

Stripe Clinches over $7B Deal to Buy AI Firm OpenRouter

https://www.bloomberg.com/news/articles/2026-08-16/stripe-nears-deal-to-buy-ai-firm-openrouter-fo...
226•zacharyozer•6h ago•155 comments

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

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

Anton Chekhov played at love most of his life

https://commonreader.wustl.edu/winning-and-losing-at-the-great-game-of-intimacy/
68•lermontov•2d ago•14 comments

Models Are Getting Dumber on Purpose

https://w4g1.dev/blog/models-are-getting-dumber-on-purpose
283•hruvhwe•8h ago•159 comments

Firefox for iOS now has a native adblocker

https://support.mozilla.org/en-US/kb/block-ads-firefox-ios
556•pentagrama•14h ago•236 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
19•hardlianotion•7h ago•2 comments

A quick look at zero-knowledge proofs

https://bernsteinbear.com/blog/zkp/
55•evakhoury•2d ago•25 comments

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

310•stagas•9h ago•78 comments

The FastLanes Unified Transport Layout

https://blog.dave.tf/post/fastlanes-utl/
3•raggi•5d ago•0 comments

Applying a photosynthetic process to treat "dry eye"

https://www.science.org/content/blog-post/taking-tip-plants-eyes
3•gumby•2h ago•0 comments

A True Telnet BBS on a Casio Calculator

https://ei3lh.eu/2026/08/16/a-true-telnet-bbs-on-a-casio-calculator/
91•austinallegro•15h ago•9 comments

St Lucie Nuclear Reactor Unit 1 manually shutdown, 3 control rods drop into core

https://www.wptv.com/news/treasure-coast/region-st-lucie-county/saint-lucie-nuclear-power-plant-u...
162•toomuchtodo•12h ago•128 comments

Asynchronous I/O in DuckDB: Work, Thread, Work

https://duckdb.org/2026/07/31/asynchronous-io
273•pdet•6d ago•31 comments