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

PHP 8.2.35

https://github.com/php/php-src/releases/tag/php-8.2.35
473•tuyuri•1h ago•195 comments

PHP2Shell: AI uncovers critical RCE in PHP

https://www.wiz.io/blog/php2shell-php-rce
278•danlark1•1h ago•75 comments

DuckDB 2.0.0 LTS "Cinnamon Teal"

https://duckdb.org/2026/10/21/announcing-duckdb-200
132•nnx•1h ago•11 comments

Eight Bits of Trust; eMudhra's CA keys cracked in milliseconds

https://scotthelme.co.uk/eight-bits-of-trust-emudhras-ca-keys-cracked-in-milliseconds/
547•hkc•6h ago•241 comments

Compromised LiteLLM 1.107.0 on PyPI Installs a Credential Stealer and Backdoor

https://safedep.io/litellm-pypi-compromise-credential-stealer-backdoor/
51•abhisek•1h ago•19 comments

Patch the Planet: global response coordination as agents uncover vulnerabilities

https://openai.com/index/coordinated-disclosure-of-critical-vulnerabilities/
91•nr378•1h ago•47 comments

The No Kings Takedown Is Why You Shouldn't Rent Your Megaphone from Zuck

https://www.techdirt.com/2026/10/20/accident-or-not-the-no-kings-takedown-is-why-you-shouldnt-ren...
214•robtherobber•1h ago•143 comments

Most advice is right for the person giving it

https://coached.com/essays/most-advice-is-right-for-the-person-giving-it/
89•rohanm93•2h ago•69 comments

Oregon lawmakers approve money to buy an iconic waterfall listed on Redfin

https://apnews.com/article/oregon-waterfall-for-sale-lawmakers-996de63462d49ec3ad9bee1629fb9488
4•surprisetalk•22m ago•2 comments

LayerFS: The filesystem for AI coding agents

https://layerfs.ai/
45•l2dy•3h ago•25 comments

Upcoming critical PHP security release (CVE-2026-109618 / -109619)

https://news-web.php.net/php.announce/509
1427•xd•19h ago•602 comments

Qwen3-Coder writes less secure code when told it's for a US persona

https://www.hirundo.io/blog/qwen3-coder-vulnerabilities
200•mattifrank•3h ago•101 comments

9 Mothers (YC P26) Is Hiring in Austin, TX

https://9mothers.com/careers
1•ukd1•3h ago

C++ futures part 1: The mental model

https://devblogs.microsoft.com/oldnewthing/20261012-00/?p=112767/
21•ibobev•1d ago•5 comments

The Future of CSS

https://www.joshwcomeau.com/css/interop-2027/
521•soheilpro•13h ago•220 comments

Using thousands of AI agents to uncover new leads in biological data

https://openai.com/index/scaling-ai-research-for-complex-biological-data/
23•raahelb•2h ago•3 comments

Way to Play Super Mario 64: On Apple Vision Pro

https://www.pagetable.com/303
123•frizlab•2d ago•41 comments

Delays for Pull Requests and Webhook deliveries

https://www.githubstatus.com/incidents/nms1dpzmh9d9
35•bearsyankees•46m ago•9 comments

Show HN: SimCity, but with Permits

https://permit.petercai.com/
877•pcai•21h ago•396 comments

Muse exposes users' personal and business secrets when they share conversations

https://arstechnica.com/security/2026/10/meta-muse-exposes-users-personal-and-business-secrets-wh...
292•gumby•14h ago•140 comments

PHP2Shell

https://www.php2shell.com
18•nr378•1h ago•2 comments

Show HN: Sumi.css – CSS Framework

https://github.com/vladocar/Sumi.css
20•bepero•2h ago•6 comments

Dutch National Cyber Security Center is Offline because it uses PHP

https://www.ncsc.nl/actueel
232•jacquesm•3h ago•75 comments

The Decoherence Trap

https://maevyn.codes/decoherence
118•cassianoleal•2d ago•51 comments

Voxtral 3

https://mistral.ai/news/voxtral-3/
745•ilreb•23h ago•192 comments

Whatever Happened to Fire Escapes

https://practical.engineering/blog/2026/10/20/whatever-happened-to-fire-escapes
129•sohkamyung•5h ago•87 comments

The Lucrative World of Literary Scams

https://www.thedial.world/articles/news/ai-book-scams
37•samclemens•2d ago•4 comments

Feds suspect ransom negotiator ran ShinyHunters extortion site

https://krebsonsecurity.com/2026/10/feds-suspect-ransom-negotiator-ran-shinyhunters-extortion-site/
246•Bender•17h ago•124 comments

Good type against all odds

https://unsung.aresluna.org/good-type-against-all-odds/
180•firloop•13h ago•15 comments

The Other Epidemic: Trying to get off benzodiazepines

https://www.thebeliever.net/the-other-epidemic/
253•gaplong•16h ago•200 comments