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

Sharing AI progress in mathematics

https://openai.com/index/sharing-ai-progress-in-mathematics/
274•OfficialTurkey•2h ago•234 comments

Mistral Large 4

https://mistral.ai/news/mistral-large-4/\
1554•Philpax•11h ago•950 comments

Decisions API is in public beta

https://developers.openai.com/api/docs/guides/decisions
106•chiefstorm•3h ago•42 comments

Integer multiplication below n log n

https://github.com/openai/math/tree/main/preprints/Integer-multiplication-below-n-log-n-September...
19•E-Reverance•1h ago•6 comments

Vibecoding Photoshop: Time and pressure

https://andreklein.net/vibecoding-photoshop-time-and-pressure/
41•samtheDamned•3h ago•36 comments

Penguin Mail – open-source Rust email client for Linux with AI

https://penguin-mail.com/
28•kavourias•2h ago•8 comments

EmbeddingGemma 2: An open, lightweight multimodal embedding model

https://blog.google/innovation-and-ai/technology/developers-tools/embeddinggemma-2/
196•ilreb•8h ago•28 comments

Nobel Prize in Physics 2026: Francis Halzen

https://www.nobelprize.org/prizes/physics/2026/
513•solarist•14h ago•168 comments

OpenTPU – An open-source AI accelerator, developed by AI

https://github.com/FeSens/openTPU
212•fsbonetto•7h ago•280 comments

When random is not actually random enough

https://ersc.io/blog/when-random-isnt-random-enough
18•steveklabnik•4h ago•5 comments

Claude Code’s suggested message feature: I think the real customer is the model

https://www.zohaib.cc/blog/smartest-claude-code-feature
74•zed_labs_dev•6h ago•39 comments

LLMs may have helped my RSI

https://vaughanhilts.me/2026/10/05/llms-immensely-helped-my-rsi.html
23•vaughands•21h ago•14 comments

Paramount Skydance has completed its $111B merger with Warner Bros. Discovery

https://arstechnica.com/tech-policy/2026/10/paramount-completes-111b-warner-merger-creating-skyda...
154•Mgtyalx•3h ago•227 comments

The Query Transformation Pipeline

https://readyset.io/blog/how-readyset-rewrites-your-sql-inside-the-query-transformation-pipeline
7•gvsg-rs•2h ago•0 comments

Ask HN: Are there AI models for generating sounds based on a text and reference?

15•onemiketwelve•1d ago•3 comments

AnyPS5: Port PS5 binaries to PC without emulation (87% system libraries mapped)

https://github.com/boykopovar/AnyPS5
3•Fe2O3•51m ago•1 comments

UniEvo-VL: Self-Distillation Training for Multimodal Model Self-Improvement

https://arxiv.org/abs/2609.38721
5•gmays•1h ago•0 comments

Utah to let AI examine patients and prescribe medication without human oversight

https://www.techspot.com/news/114111-utah-become-first-state-ai-examine-patients-prescribe.html
53•healsdata•7h ago•81 comments

How Fast is Python 3.15?

https://blog.miguelgrinberg.com/post/how-fast-is-python-3-15
14•Qem•2h ago•5 comments

Stanford scientists found a way to regrow cartilage and stop arthritis

https://www.sciencedaily.com/releases/2026/10/261005011249.htm
16•kelnos•24m ago•1 comments

Benchmark in Milliseconds

https://matklad.github.io/2026/10/05/benchmark-milliseconds.html
126•surprisetalk•1d ago•36 comments

State of Devs 2026 survey results: developers are exhausted

https://2026.stateofdevs.com/en-US/
15•sgdesign•53m ago•6 comments

What's Earth's dominant species by mass?

https://signoregalilei.com/2026/09/27/whats-earths-dominant-species-by-mass/
134•surprisetalk•11h ago•86 comments

OpenSSH 10.6

https://www.openssh.org/releasenotes.html#10.6
79•torcete•3h ago•17 comments

Gleam doesn't compile to Erlang source anymore

https://gleam.run/news/gleam-doesnt-compile-to-erlang-source-anymore/
290•ingve•16h ago•122 comments

California closed the Montana license plate loophole

https://www.thedrive.com/news/heres-how-california-closed-the-montana-license-plate-loophole
40•speckx•7h ago•68 comments

Berthd

https://berthd.app/
41•handfuloflight•5h ago•62 comments

Ask HN: Why is Ask HN only showing me 14 posts?

31•Gooblebrai•2h ago•31 comments

Toronto-Based VPN Provider Plans to Quit Canada over Lawful-Access Bill

https://citizenlab.ca/toronto-based-vpn-provider-plans-to-quit-canada-over-lawful-access-bill/
90•speckx•5h ago•37 comments

Show HN: I turned my iPhone and a $20 smart plug into an f-stop timer

https://peterszentkiralyi.eu/darkplug/
67•pentakkusu•10h ago•19 comments