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

Meta Muse Glimmer – open weights 30B local coding model

https://research.meta.ai/blog/introducing-muse-glimmer-open-agentic-model
301•riordan•3h ago•121 comments

Because It's Not Fun Enough: why languages fail

https://bytecode.news/posts/2026/08/because-it-s-not-fun-enough
53•jottinger•1h ago•33 comments

50k Boat Names

https://www.beautifulpublicdata.com/boat-names/
7•jonathanmkeegan•14m ago•0 comments

Docker Sandboxes – Disposable, isolated sandboxes for AI agents

https://www.docker.com/products/docker-sandboxes/
330•etoxin•7h ago•194 comments

Tail-call optimization in C is relatively recent

https://lwn.net/Articles/1034703/
31•prakashqwerty•1h ago•12 comments

Squeak/Smalltalk 6.1 Release Notes

https://squeak.org/release_notes/6.1/
16•fniephaus•56m ago•2 comments

Parametron: 50s Japanese computer that uses neither transistors nor vacuum tubes

https://ethw.org/Milestones:Parametron,_1954
26•xeonmc•2h ago•2 comments

What Happened to HackerOne?

https://blog.teknogeek.io/posts/what-happened-to-hackerone/
285•hipparchus•10h ago•145 comments

Run Android ARM64 VR APKs on Apple Vision Pro

https://github.com/shinyquagsire23/Klepton
116•LorenDB•9h ago•18 comments

Tail-Call Interpreters in Rust – Jimmy Ostler

https://lordgoati.us/blog/tail-call/
45•amatheus•3d ago•16 comments

An Interesting Fourier Transform – 1/F Noise

https://www.dsprelated.com/showarticle/40.php
69•q7m•3d ago•15 comments

Show HN: Voice driven murder mystery, Interview AI suspects with your voice

https://www.whodunnitai.com/
125•MrRowTheBoat•9h ago•52 comments

Over 181,000 AI meeting recordings left wide open in note taking app

https://bobdahacker.com/blog/tldv-hack
16•colesantiago•46m ago•5 comments

DeepSeek costs OpenCode Go user $1.14/day; dual DGX breaks even in 24 years

https://twitter.com/thdxr/status/2086599224674681242
14•delduca•47m ago•6 comments

Findphone: Locate a nearby Bluetooth device by signal strength

https://github.com/ben-z/findphone
7•helsinkiandrew•5d ago•3 comments

How Blackwing Pencils are Made [video]

https://www.youtube.com/watch?v=fow-LsdaH2E
32•NaOH•4d ago•12 comments

How I use LLMs to learn complex topics

https://laurentiugabriel.github.io/blog/articles/how-i-use-llms-to-learn/
706•laurentiurad•17h ago•451 comments

Taxi drivers rarely die of Alzheimer's

https://theconversation.com/taxi-drivers-rarely-die-of-alzheimers-how-complex-mental-maps-and-spa...
324•jader201•21h ago•232 comments

How We Pushed CDC into Postgres

https://www.snowflake.com/en/blog/engineering/postgres-to-snowflake-replication-mirroring/
108•craigkerstiens•12h ago•20 comments

Ask HN: What are you working on? (August 2026)

272•david927•19h ago•939 comments

Cool URIs Don't Change (1998)

https://www.w3.org/Provider/Style/URI
255•Klaster_1•22h ago•62 comments

An alias-based formulation of the borrow checker (2018)

https://smallcultfollowing.com/babysteps/blog/2018/04/27/an-alias-based-formulation-of-the-borrow...
18•parksb•2d ago•1 comments

ATProto for Distributed Systems Engineers

https://atproto.com/articles/atproto-for-distsys-engineers
102•LelouBil•3d ago•19 comments

Tuxedo No. 2 – Cocktail recipes

https://tuxedono2.com
112•smartmic•16h ago•35 comments

Picophysics: Single file physics for games on platforms like N64, PSX, DC

https://gitlab.com/Kazade/picophysics
68•klaussilveira•5d ago•22 comments

A 'bananas' order for 5000 obscure book titles fuels suspicion

https://www.irishtimes.com/world/europe/2026/08/10/a-mysterious-buying-spree-is-unsettling-europe...
53•ohaodha•1h ago•49 comments

Everything you do is being recorded

https://www.theatlantic.com/technology/2026/05/ai-wearable-surveillance-countermeasures/687203/
346•ike_usawa•1d ago•300 comments

Nearest Pint

https://knowwhereconsulting.co.uk/maps/pubs/
42•bookofjoe•5d ago•23 comments

I made tinnitus my friend, then it disappeared [video]

https://mynoise.net/vlog.php?ep=20260803
178•gregsadetsky•18h ago•138 comments

New Zealand lost its music media, and what we're building to replace it

https://propelmusic.co.nz/articles/the-sound-went-quiet-nz-music-media
123•berghoffer•16h ago•83 comments