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

A Herculaneum scroll has been read for the first time

https://scrollprize.org/firstscroll
262•verditelabs•2h ago•73 comments

IBM debuts sub-1 nanometer chip technology

https://newsroom.ibm.com/2026-06-25-ibm-debuts-worlds-first-sub-1-nanometer-chip-technology
97•porridgeraisin•3h ago•56 comments

Oxide computer 3D rack guided tour

https://explorer.oxide.computer/
44•darthcloud•3d ago•13 comments

Zig's new bitCast semantics and LLVM back end improvements

https://ziglang.org/devlog/2026/#2026-06-25
144•kouosi•4h ago•40 comments

I built a GPU back end for Emacs

https://en.andros.dev/blog/4b707a03/how-i-built-a-gpu-backend-for-emacs/
71•andros•2d ago•21 comments

OS9Map

https://yllan.org/software/OS9Map/
73•LaSombra•3h ago•9 comments

Apple raises prices of MacBooks, iPads

https://www.reuters.com/world/asia-pacific/apple-raises-prices-macbooks-ipads-memory-costs-skyroc...
350•virgildotcodes•5h ago•552 comments

You can't unit test for taste

https://dev.karltryggvason.com/you-cant-unit-test-for-taste/
196•kalli•1d ago•81 comments

Besimple AI (YC P25) Is Hiring

https://www.ycombinator.com/companies/besimple-ai/jobs/yWfhhOR-strategic-projects-lead-audio-data
1•yzhong94•1h ago

Show HN: Chess-Inspired Roguelike

https://princechazz.com
35•cowboy_henk•4d ago•10 comments

Show HN: I made Google Trends for Hacker News by indexing 18 years of comments

https://hackernewstrends.com
466•ytkimirti•4h ago•123 comments

Windows 10 quietly gets one more year of support and updates

https://www.neowin.net/news/windows-10-quietly-gets-one-more-year-of-support-and-updates/
119•bundie•2h ago•78 comments

Half-Life 2 in a Browser

https://hl2.slqnt.dev/
578•panza•12h ago•232 comments

Tw-fade: pure CSS scroll-driven edge masking

https://pete.design/tw-fade
49•petekp•3d ago•17 comments

Anthropic says Alibaba illicitly extracted Claude AI model capabilities

https://www.reuters.com/world/china/anthropic-says-alibaba-illicitly-extracted-claude-ai-model-ca...
718•htrp•22h ago•1159 comments

Early adversity leaves lasting molecular imprint across the body: primate study

https://medicalxpress.com/news/2026-06-early-life-adversity-molecular-imprint.html
24•gmays•4d ago•2 comments

52-hertz whale

https://en.wikipedia.org/wiki/52-hertz_whale
46•brightbeige•22h ago•4 comments

Physicists Track and Trap the Elusive Neutrino

https://www.quantamagazine.org/how-physicists-track-and-trap-the-elusive-neutrino-20260624/
24•ibobev•3h ago•3 comments

How to get your first customers [video]

https://www.ycombinator.com/library/SF-how-to-get-your-first-10-customers
44•aurenvale•1d ago•12 comments

Advanced Nintendo Entertainment System (ANES) – NES Modded to Use 2 PPUs

https://github.com/decrazyo/anes
29•zdw•1d ago•7 comments

Show HN: Turn native language audio into flashcards and shadowing practice

https://lingochunk.com/try
59•alder•7h ago•27 comments

LastPass notifies users of yet another data breach

https://9to5mac.com/2026/06/23/lastpass-notifies-users-of-yet-another-data-breach/
388•mooreds•8h ago•170 comments

The disappearance of Japan's animators

https://economist.com/interactive/1843/2026/06/19/the-strange-disappearance-of-japans-animators
73•andsoitis•4d ago•63 comments

Cloudflare launched self-managed OAuth for all

https://blog.cloudflare.com/oauth-for-all/
318•terryds•16h ago•137 comments

Show HN: MiniPCs.zip – Charting the Pareto frontier of Mini PCs

https://minipcs.zip
69•yathern•4d ago•28 comments

Political bias in AI: Where the AI models stand

https://trakkr.ai/bias
40•mektrik•5h ago•105 comments

Show HN: Bible as RAG Database

https://www.crosscanon.com/
102•jacksonastone•16h ago•66 comments

Deno 2.9

https://deno.com/blog/v2.9
115•enz•2h ago•42 comments

Mixing Visual and Textual Code

https://arxiv.org/abs/2603.15855
63•doppioandante•17h ago•41 comments

European Commission lines up Amazon and Microsoft for cloud gatekeeper status

https://www.theregister.com/legal/2026/06/25/european-commission-lines-up-amazon-and-microsoft-fo...
36•Bender•2h ago•9 comments