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•8mo ago

Comments

castratikron•8mo 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•8mo 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•8mo 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•8mo 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•8mo 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•8mo ago
in CPU's - pipelining!
jchw•8mo 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...)

Show HN: Ferrite – Markdown editor in Rust with native Mermaid diagram rendering

https://github.com/OlaProeis/Ferrite
40•OlaProis•1h ago•13 comments

Finding and fixing Ghostty's largest memory leak

https://mitchellh.com/writing/ghostty-memory-leak-fix
298•thorel•8h ago•63 comments

Show HN: Librario, a book metadata API that aggregates G Books, ISBNDB, and more

71•jamesponddotco•3h ago•24 comments

Show HN: I used Claude Code to discover connections between 100 books

https://trails.pieterma.es/
237•pmaze•10h ago•78 comments

Open Chaos: A self-evolving open-source project

https://www.openchaos.dev/
325•stefanvdw1•11h ago•66 comments

Show HN: VAM Seek – 2D video navigation grid, 15KB, zero server load

https://github.com/unhaya/vam-seek
5•haasiy•43m ago•0 comments

Show HN: Play poker with LLMs, or watch them play against each other

https://llmholdem.com/
80•projectyang•8h ago•43 comments

Eulogy for Dark Sky, a data visualization masterpiece (2023)

https://nightingaledvs.com/dark-sky-weather-data-viz/
385•skadamat•15h ago•163 comments

AI is a business model stress test

https://dri.es/ai-is-a-business-model-stress-test
185•amarsahinovic•10h ago•211 comments

Code and Let Live

https://fly.io/blog/code-and-let-live/
246•usrme•1d ago•79 comments

Show HN: mcpc – Universal command-line client for Model Context Protocol (MCP)

https://github.com/apify/mcp-cli
21•jancurn•4d ago•3 comments

Overdose deaths are falling in America because of a 'supply shock': study

https://www.economist.com/united-states/2026/01/08/why-overdose-deaths-are-falling-in-america
78•marojejian•7h ago•62 comments

Brands upset Buy For Me is featuring their products on Amazon without permission

https://www.modernretail.co/technology/brands-are-upset-that-buy-for-me-is-featuring-their-produc...
34•spenvo•4d ago•10 comments

Datadog, thank you for blocking us

https://www.deductive.ai/blogs/datadog-thank-you-for-blocking-us
22•binarylogic•1d ago•16 comments

Sisyphus Now Lives in Oh My Claude

https://github.com/Yeachan-Heo/oh-my-claude-sisyphus
5•deckardt•1h ago•1 comments

Code Is Clay

https://campedersen.com/code-is-clay
42•ecto•7h ago•20 comments

Bob Weir has died

https://www.rollingstone.com/music/music-news/bob-weir-grateful-dead-dead-obituary-1234810106/
67•asix66•2h ago•10 comments

Kodbox: Open-source cloud desktop with multi-storage fusion and web IDE

https://github.com/kalcaddle/kodbox
7•indigodaddy•2h ago•0 comments

ChatGPT Health is a marketplace, guess who is the product?

https://consciousdigital.org/chatgpt-health-is-a-marketplace-guess-who-is-the-product/
249•yoaviram•2d ago•243 comments

ASCII-Driven Development

https://medium.com/@calufa/ascii-driven-development-850f66661351
103•_hfqa•2d ago•70 comments

Rats caught on camera hunting flying bats

https://scienceclock.com/rats-caught-on-camera-hunting-flying-bats-for-the-first-time/
78•akg130522•8h ago•9 comments

A Year of Work on the Arch Linux Package Management (ALPM) Project

https://devblog.archlinux.page/2026/a-year-of-work-on-the-alpm-project/
5•susam•1h ago•0 comments

CPU Counters on Apple Silicon: article + tool

https://blog.bugsiki.dev/posts/apple-pmu/
4•verte_zerg•3d ago•0 comments

Org Mode Syntax Is One of the Most Reasonable Markup Languages for Text (2017)

https://karl-voit.at/2017/09/23/orgmode-as-markup-only/
253•adityaathalye•18h ago•177 comments

Show HN: GlyphLang – An AI-first programming language

21•goose0004•3h ago•14 comments

UpCodes (YC S17) is hiring PMs, SWEs to automate construction compliance

https://up.codes/careers?utm_source=HN
1•Old_Thrashbarg•10h ago

Private equity firms acquired more than 500 autism centers in past decade: study

https://www.brown.edu/news/2026-01-07/private-equity-autism-centers
219•hhs•4h ago•151 comments

I replaced Windows with Linux and everything's going great

https://www.theverge.com/tech/858910/linux-diary-gaming-desktop
586•rorylawless•12h ago•491 comments

New information extracted from Snowden PDFs through metadata version analysis

https://libroot.org/posts/going-through-snowden-documents-part-4/
289•libroot•16h ago•119 comments

Extracting books from production language models (2026)

https://arxiv.org/abs/2601.02671
41•logicprog•6h ago•9 comments