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

Kimi K3.1 Pro and K3.1 Pro Highspeed

https://www.kimi.ai/blog/kimi-k3-1-pro
489•Jowsey•3h ago•283 comments

Apple Music 404 Not Found

https://music.apple.com/this-url-doesnt-exist
264•frizlab•8h ago•93 comments

Kimi K3.1 scores 55 on Artificial Analysis, placed on the Pareto line

https://artificialanalysis.ai/models/kimi-k3-1-pro
108•theanonymousone•2h ago•24 comments

Today, we hacked what we'd set out to hack: the iPhone

https://blog.calif.io/p/iphone
566•pavel_lishin•4h ago•388 comments

Dessa: the most authentic full-duplex speech model ever built

https://block.xyz/dessa
32•dsr12•1h ago•8 comments

Local Wikipedia: Wikipedia, but only for things a half hour walk from you

https://edjefferson.com/localwiki/
1099•sohkamyung•21h ago•212 comments

The Real Kevin Bacon

https://pudding.cool/2026/10/kevin-bacon/
160•xnx•3d ago•44 comments

Canadians are running out of time to oppose Bill C-22

https://www.eff.org/deeplinks/2026/10/canadians-are-running-out-time-oppose-dangerous-c-22-survei...
203•hn_acker•22h ago•82 comments

How is music possible

https://www.henrikkarlsson.xyz/p/music
71•rafaelc•4h ago•44 comments

UUIDv7 doesn't have the properties you think it does

https://alexsci.com/blog/uuidv7-is-weird/
80•ibobev•4h ago•68 comments

I turned my TV into a Game Boy Color with a Pokemon town as my home screen

https://twitter.com/robbietilton/status/2111936458923851923
42•scrambled•3h ago•10 comments

Kimi K3.1 Pro puts open-source AI a month behind the best

https://www.modelcompare.ai/blog/china-open-source-ai
3•rakannimer•31m ago•0 comments

Reforming English Spelling

https://blog.oup.com/2026/10/reforming-english-spelling/
13•jruohonen•4h ago•27 comments

Show HN: Impossible Machines: declaratively program the physical world

https://www.impossiblemachines.xyz
43•bhaprayan•20h ago•12 comments

The Missed Opportunities of Sonic 06 (2025)

https://isaacmarovitz.com/posts/sonic-06/
51•ibobev•4h ago•10 comments

We are all living inside of an obscure sci-fi film from 1970

https://thanksforthatjim.bearblog.dev/we-are-all-living-inside-of-an-obscure-sci-fi-film-from-1970/
4•speckx•1h ago•1 comments

Animations for System Builders

https://brooker.co.za/blog/2026/10/23/animations.html
16•KraftyOne•3h ago•2 comments

LISP Comes of Age (1980)

https://microship.com/lisp-comes-of-age/
45•so-cal-schemer•1d ago•14 comments

Time Nuts (2005)

http://leapsecond.com/time-nuts.htm
23•jacquesm•3h ago•20 comments

Show HN: Swurf – Swipe through the real web

https://swurf.org/
31•webtjb096•13h ago•15 comments

Total Historian

https://www.theideasletter.org/essay/total-historian/
18•benbreen•4h ago•3 comments

Can we replace a $150k Looker with a bucket of HTML files?

https://david.lequin.dev/blog/bi-software-is-dead/
75•skadamat•3h ago•49 comments

Ask HN: If the models are so good, why doesn't OpenAI just start 100 companies?

534•ex-aws-dude•23h ago•584 comments

Job loss and cortisone mania

https://tilschuenemann.de/job-loss-cortisone-mania
151•speckx•10h ago•85 comments

The foolishness of "natural language programming" (1978)

https://www.cs.utexas.edu/~EWD/transcriptions/EWD06xx/EWD667.html
348•xiaoyu2006•19h ago•236 comments

Gemma-4-26B-A4B with 39-69% less thinking at same accuracy

https://bottlecapai.com/post/thinkingcap-gemma-4-26b/
74•armcat•6h ago•11 comments

Show HN: OnKey – I'm a bad singer, so I built an app to show where I'm off-key

https://github.com/dsmurrell/onkey
193•dsmurrell•1d ago•82 comments

Florida officer found dead man, impersonated him for years, renovated his home

https://www.nbcnews.com/news/us-news/officer-impersonates-dead-florida-man-moved-into-home-rcna60...
21•Michelangelo11•1h ago•6 comments

The alien space of science: Coherent but cognitively unavailable directions

https://arxiv.org/abs/2603.01092
190•martincsweiss•1d ago•78 comments

How does Fable 5.1 hide messages in images?

https://www.lesswrong.com/posts/WHEQps5PK8LrrcTAb/how-does-fable-5-1-hide-messages-in-images
188•gmays•23h ago•68 comments