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

NSA advises immediate transition to post-quantum cryptography

https://www.nsa.gov/Press-Room/Press-Releases-Statements/Press-Release-View/Article/4662430/nsa-a...
940•intunderflow•3h ago•598 comments

The end of freelance web development

https://marcarea.com/weblog/2026/11/04/ai-and-me
118•vishnugupta•1h ago•85 comments

Amber Eye: a Slay the Spire engine approaching top-level play

https://8e9f.github.io/amber_eye/
53•gcmeplz•1h ago•17 comments

Subminute CI

https://engineering.moab.com/posts/subminute-ci/
81•tamentis•1h ago•25 comments

Zig gets improved float parser/formatter

https://codeberg.org/ziglang/zig/pulls/37793
47•Retro_Dev•1h ago•2 comments

Ask HN: Who is hiring? (December 2026)

96•whoishiring•1d ago•165 comments

Nvidia Partners with SpaceX to Launch Datacenters into Space

https://www.nextplatform.com/compute/2026/12/02/nvidia-partners-with-spacex-to-launch-datacenters...
110•jonbaer•4h ago•291 comments

Truss: A programming language optimized for agent-written software

https://github.com/finiteloop/truss
19•sram1337•52m ago•9 comments

AI Adoption Is an Org Design Problem

https://cottageindustry.ai/p/ai-adoption-is-an-org-design-problem
18•kevinmannix•1h ago•4 comments

CellGemma – Model built to help accelerate discovery of new cancer therapies

https://deepmind.google/models/gemma/cellgemma/
522•estebandalelr•11h ago•108 comments

Apple honors Warren Buffett on their homepage

https://www.apple.com/?date=20261202
32•joshfraser•2h ago•1 comments

Finding faster quantum algorithms with agents and formal verification

https://deepmind.google/blog/finding-faster-quantum-algorithms-with-agents-and-formal-verification/
62•rbanffy•3h ago•11 comments

John V. Blankenbaker, the maker of the Kenbak-1 computer, has died

https://www.kenbak.com/johnblankenbaker
21•linker3000•1d ago•4 comments

Meta Announces IRL App

https://irl.meta.com/
21•brianhama•1h ago•10 comments

Ask HN: Who wants to be hired? (December 2026)

35•whoishiring•1d ago•370 comments

Show HN: Warpspec – TLA+ model checking on a GPU, 4,600× faster than TLC

https://praveenperera.com/blog/tla-model-checking-4600x-faster-on-a-gpu/
56•praveenperera•3h ago•6 comments

Don't Trust People Who Talk Like This

https://www.honest-broker.com/p/dont-trust-people-who-talk-like-this
738•baud147258•7h ago•355 comments

NPM crossed 1T monthly downloads in September

https://jonchurch.com/npm-global-trend/
14•jonchurch_•58m ago•2 comments

Kagi Us-East4 Outage

https://status.kagi.com/cmx6g51q90c2t1bp7gdhw9x95
59•natebc•1h ago•9 comments

Fortnite is now available on Linux through Proton

https://twitter.com/FortniteStatus/status/2128130519758234032
75•tosh•2h ago•21 comments

Autostep (YC P26) Is Hiring – AI/Software Engineering Contractor

https://jobs.dover.com/autostep/6464a6d6-7483-4496-83c3-4e373e7b9244
1•adawg4•7h ago

Ford Recalls over 700k Cars After Two Deaths from Carbon Monoxide Poisoning

https://www.wsj.com/business/autos/ford-recall-carbon-monoxide-poisoning-6ae4f2b8
90•bookofjoe•2h ago•95 comments

Show HN: Pryzmera – Fast PDF viewer, over 1200x faster rendering than Acrobat

https://pryzmera.com/
25•RedMindZ•4h ago•2 comments

OverTheWire War Games

https://overthewire.org/wargames/
11•fosco•1h ago•1 comments

Friends don't let friends build search on object stores

https://www.unum.cloud/blog/usearch-v3-for-cpus-gpus-ssds
18•ashvardanian•6h ago•8 comments

Gemini 4 Live and Gemini 4 Live Translate

https://blog.google/innovation-and-ai/models-and-research/gemini-models/gemini-4-live-gemini-4-li...
87•meetpateltech•2h ago•15 comments

Lawmakers describe 'willful blindness' by Nvidia's Huang about national security

https://www.npr.org/2026/12/01/nx-s1-6059384/congress-nvidia-jensen-huang-hearings
98•blinding-streak•2h ago•73 comments

AI 'prepping' for the medium term

https://anil.recoil.org/notes/ai-prepping
121•nerdypepper•3h ago•143 comments

How I Made a RISC-V CPU in Minecraft

https://www.pureengineering.com/projects/verilog-to-redstone-chip-compiler/
10•sashiono•1h ago•1 comments

TinyGo 0.45.0

https://github.com/tinygo-org/tinygo/releases/tag/v0.45.0
288•iaaan•15h ago•45 comments