frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

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

Flipper One – we need your help

https://blog.flipper.net/flipper-one-we-need-your-help/
182•sandebert•1h ago•98 comments

Python 3.15: features that didn't make the headlines

https://blog.changs.co.uk/python-315-features-that-didnt-make-the-headlines.html
64•rbanffy•1h ago•26 comments

Show HN: Rmux – A programmable terminal multiplexer with a Playwright-style SDK

https://github.com/helvesec/rmux
93•shideneyu•3h ago•49 comments

An OpenAI model has disproved a central conjecture in discrete geometry

https://openai.com/index/model-disproves-discrete-geometry-conjecture/
1245•tedsanders•17h ago•907 comments

Fender escalates legal campaign against S-style guitars

https://www.guitarworld.com/gear/electric-guitars/fender-cease-and-desist-lsl-instruments
42•rectang•2d ago•19 comments

GitHub confirms breach of 3,800 repos via malicious VSCode extension

https://www.bleepingcomputer.com/news/security/github-confirms-breach-of-3-800-repos-via-maliciou...
918•Timofeibu•23h ago•382 comments

Google officially announces that ads will be included in AI Mode search results

https://blog.google/products/ads-commerce/google-marketing-live-search-ads/
201•sofumel•2h ago•207 comments

Cekura (YC F24) Is Hiring

https://www.ycombinator.com/companies/cekura-ai/jobs/AiWwUxI-forward-deployed-engineer-us
1•atarus•47m ago

Lost Images from the 1945 Trinity Nuclear Test Restored

https://spectrum.ieee.org/trinity-nuclear-test
23•pseudolus•1h ago•5 comments

Show HN: I reverse engineered Apple's video wallpapers

https://github.com/kageroumado/phosphene
330•kageroumado•12h ago•79 comments

Haskell Foundation 2026 Update

https://discourse.haskell.org/t/haskell-foundation-2026-update/14136
134•azhenley•10h ago•47 comments

No Slop Grenade

https://noslopgrenade.com/
102•napolux•3h ago•53 comments

The Letter S, by Donald Knuth (1980) [pdf]

https://gwern.net/doc/design/typography/1980-knuth.pdf
205•bambax•12h ago•28 comments

Flipper One Tech Specs

https://docs.flipper.net/one/general/tech-specs
432•gregsadetsky•18h ago•143 comments

New features in GCC 16: Improved error messages and SARIF output

https://developers.redhat.com/articles/2026/04/28/gcc-16-improved-error-messages-sarif-output
105•siteshwar•2d ago•18 comments

DOS Zone

https://dos.zone/
283•rglover•13h ago•65 comments

Earth is now heating up twice as fast as in previous decades

https://www.newscientist.com/article/2518362-earth-is-now-heating-up-twice-as-fast-as-in-previous...
72•Anon84•1h ago•50 comments

What Do Gödel's Incompleteness Theorems Mean?

https://www.quantamagazine.org/what-do-godels-incompleteness-theorems-truly-mean-20260518/
20•baruchel•2d ago•3 comments

Anthropic is expanding to Colossus2. Will use GB200

https://twitter.com/nottombrown/status/2057194829986300375
231•aurareturn•15h ago•251 comments

All the bugs they found

https://andreapivetta.com/posts/all-the-bugs-they-found.html
50•ziggy42•2d ago•17 comments

How fast is N tokens per second really?

https://mikeveerman.github.io/tokenspeed/
440•hexagr•3d ago•90 comments

Simulating Infinity in Conway's Game of Life with Modern C++

https://ryanjk5.github.io/posts/GOLDE/
51•HeliumHydride•2d ago•12 comments

Show HN: I made a tactical map-based WWII submarine simulator (public beta)

https://silentshark.app/alpha/
75•epaga•2d ago•25 comments

OpenAI Is Preparing to File for an IPO Soon

https://www.wsj.com/tech/ai/openai-is-preparing-to-file-for-an-ipo-very-soon-0ec95af5
130•louiereederson•20h ago•274 comments

Archaeologists find Egyptian mummy buried with the 'Iliad'

https://www.openculture.com/2026/05/archaeologists-discover-ancient-egyptian-mummy-buried-with-pa...
160•diodorus•5d ago•120 comments

Saying goodbye to asm.js

https://spidermonkey.dev/blog/2026/05/20/saying-goodbye-to-asmjs.html
393•eqrion•1d ago•150 comments

Show HN: The Hanging Sculptures of the Xiaoxitian

https://funes.world/apps/the-hanging-sculptures-of-the-xiaoxitian
16•hanyangwang•2d ago•4 comments

Reviving old scanners with an in-browser Linux VM bridged to WebUSB over USB/IP

https://yes-we-scan.app/details
94•gmac•3d ago•30 comments

Recreate famous water profiles using supermarket bottled water

https://www.waterdictionary.net
62•smugglerFlynn•2d ago•32 comments

What is a Demand Coop

https://cahootzcoops.com/blog/what-is-a-demand-coop
72•DeonRob•11h ago•77 comments