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

Three new discoveries in mathematics, computer science, and physics

https://openai.com/index/building-scientific-understanding-with-academic-communities/
868•jonluca•11h ago•392 comments

The Mythical Man-Month in the Age of AI

https://j11g.com/the-mythical-man-month-in-the-age-of-ai
95•ilreb•2h ago•78 comments

The Exponential Time Hypothesis Is False [pdf]

https://github.com/openai/math/blob/main/preprints/The-Exponential-Time-Hypothesis-is-False-Octob...
611•vok•11h ago•215 comments

New 'Circadian' Subtype of Depression Affecting 1 in 4 Patients

https://www.sciencealert.com/researchers-identify-new-circadian-subtype-of-depression-affecting-1...
38•gmays•4d ago•13 comments

Sebastian Raschka's from-scratch video course on building reasoning models

https://magazine.sebastianraschka.com/p/building-reasoning-models
698•sgiannopoulos•17h ago•94 comments

Writing about pratt parsing so I remember it

https://www.unix.dog/~yosh/blog/2026-10-25_pratt-parsing.html
25•dverlaeckt80•3h ago•1 comments

Oldest GUI application that still runs on Windows 11

https://blog.enlyth.com/posts/oldest-windows-gui-app-win-11/
410•enlyth•15h ago•235 comments

I still teach OpenGL ES 3.0

https://eliasfarhan.ch/graphics/cpp/2026/01/27/why-i-teach-opengles.html
52•majorchord•6h ago•32 comments

Type Server Protocol

https://github.com/microsoft/pylance-release/blob/main/docs/tsp/type-server-protocol.md
240•adamnemecek•14h ago•157 comments

16-bit Windows (Windows 1.x, 2.x, 3.0, 3.1, etc.) on 64-bit Windows

https://github.com/otya128/winevdm
86•doener•7h ago•18 comments

Solar power is becoming bigger than nuclear

https://www.bbc.com/future/article/20261023-how-solar-became-bigger-than-nuclear
294•geox•17h ago•439 comments

CSS-Tricks has a new owner

https://css-tricks.com/css-tricks-has-a-new-owner/
463•edent•17h ago•103 comments

Cross-request KV cache exposure in the GLM-5.3 Workers AI model (155 responses)

https://blog.cloudflare.com/kv-cache-exposure-remediation/
131•wondersky•10h ago•43 comments

A Printer Printing onto Paper

https://twitter.com/macrofying/status/2112904628509528219
125•MrBuddyCasino•4d ago•26 comments

How to grow a cacao tree at home (2024)

https://www.cocoterra.com/guide-on-how-to-grow-chocolate-at-home/
66•felipevb•1d ago•23 comments

New iPad mini

https://www.apple.com/newsroom/2026/10/apple-gives-ipad-mini-its-biggest-update-ever/
202•soheilpro•19h ago•498 comments

APC says let there be light, with standards to speed up photonics manufacturing

https://www.nextplatform.com/connect/2026/10/23/apc-says-let-there-be-light-with-raft-of-standard...
34•rbanffy•1d ago•5 comments

Txoko: Basques' traditional feast a gastronomic peek into a culture (2024)

https://johnhendersontravel.com/txoko/
18•jxub•3d ago•7 comments

A Man from the Future: Why Johnny Can't Stop Abstracting

http://muratbuffalo.blogspot.com/2026/10/the-man-from-future-why-johnny-cant.html
169•aray07•15h ago•79 comments

Chemists, Chemical Engineers, and Plant Managers

https://www.seeingthesystem.com/p/chemists-chemical-engineers-and-plant
9•TinyBig•4d ago•0 comments

Anthropic S-1

https://www.sec.gov/Archives/edgar/data/2130357/000162828026067168/anthropicpbc-sx1.htm
1605•SiNTEx•20h ago•1538 comments

Websites Should Be Printable

https://brennenputh.me/blog/printable-websites/
332•bagatelle•22h ago•193 comments

Blaise Pascal invented fixed route public transport (2024)

https://humantransit.org/2024/12/one-of-the-greatest-inventions-in-the-history-of-human-transport...
288•skadamat•4d ago•147 comments

LimonOS Custom x86-64 Kernel

https://github.com/AnonimusShamshiAlex/LimonOS
4•DrMoris•2d ago•1 comments

Nietzschian Debugger

https://github.com/DilawarShafiq/nietzschian-debugger
174•dilawargopang•15h ago•53 comments

LISPy things you can do in 64K bytes of core (2019)

https://t3x.org/lisp64k/index.html
58•andsoitis•1d ago•12 comments

Virtual and Real World Combine at LAN Party (1998)

https://www.latimes.com/archives/la-xpm-1998-aug-10-mn-11870-story.html
44•npunt•2d ago•6 comments

SIMD-accelerated computer vision on a $2 microcontroller

https://shraiwi.com/blog/simd-fast-esp32s3/
203•zdw•1d ago•59 comments

GPT-6.1 Terra

https://openai.com/index/introducing-gpt-6-1-terra/
584•meetpateltech•15h ago•372 comments

Microsoft offers mass buyouts for roughly a quarter of its workforce

https://www.seattletimes.com/business/microsoft/microsoft-offers-mass-buyouts-for-roughly-a-quart...
928•doctorzook•17h ago•891 comments