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

SpaceX catches the Starship to end Flight 15

https://www.spacex.com/launches/starship-flight-15
1064•ls612•9h ago•707 comments

Memory Safety Bugs in Rust Standard Library

https://forge-blog.github.io/posts/rust-std-memory-safety/
68•pjmlp•2d ago•14 comments

Lovable apps expose passport details and more than 200K private messages

https://www.crissyfield.de/research/lovable-en/
764•armcat•13h ago•303 comments

A rare glimpse inside the high-risk, high-reward Hormuz trade

https://www.lloydslist.com/LL1158922/A-rare-glimpse-inside-the-highrisk-highreward-Hormuz-trade
13•everybodyknows•4d ago•0 comments

How did Woz write the Apple 1 BASIC before building the computer?

https://retrocomputing.stackexchange.com/questions/17957
183•Skyfall106•8h ago•80 comments

Court denies motion to dismiss DRAM price fixing case

https://litnews.ai/articles/garciaguirre-samsung-sk-hynix-micron-dram-conspiracy-suit-survives-di...
60•ybathaee•6h ago•10 comments

Show HN: Gawain – Require type hints on all Python variables

https://github.com/matheuzgomes/gawain
31•MarinhoD•2h ago•10 comments

Show HN: Turbo-Browser-MCP – Batch forms, DOM deltas and submit guards for MCP

https://github.com/Tthanh2k6/turbo-browser-mcp
24•tthanh2k6•3h ago•3 comments

My favourite modern NES games

https://jordi.inversethought.com/blog/25-of-my-favourite-modern-nes-games/
32•jordigh•4h ago•2 comments

The Evolving Story of How Chemistry Became Biology

https://www.quantamagazine.org/the-evolving-story-of-how-chemistry-became-biology-20261112/
33•pseudolus•1d ago•2 comments

We're Asking an Appeals Court to Require a Warrant for ALPR Searches

https://www.eff.org/deeplinks/2026/11/were-asking-appeals-court-require-warrant-alpr-searches
192•nobody9999•5h ago•53 comments

A family tree of software job titles

https://zwischenzugs.com/2026/11/03/a-family-tree-of-software-job-titles/
278•umerf•13h ago•137 comments

KDE: The documentary [video]

https://tube.kockatoo.org/w/fFinNHfanLT7aBEb2B8y4c
439•mrkn1•17h ago•96 comments

PyPI's redesigned project pages with clearer security signals are now live

https://blog.pypi.org/posts/2026-11-06-ui-updates-complete/
231•rbanffy•15h ago•99 comments

Why get an expensive Pi when I have an old phone?

https://so.long.thanks.fish/why-pi-when-i-have-an-old-phone/
545•casi•4d ago•298 comments

500 Lines or Less A 3D Modeller

https://aosabook.org/en/500L/a-3d-modeller.html
41•myth_drannon•1d ago•4 comments

One Man's Quest to Create the Perfect Whiskey Glass

https://www.nytimes.com/2026/11/13/dining/drinks/kurt-josef-zalto-whiskey-glass.html
23•Kaibeezy•1d ago•6 comments

Show HN: DeepSeek V3 in ~200 lines of pure Jax

https://github.com/Vaibhaav-Tiwari/deepseek-v3-jax
219•VaibhaavTiwari•16h ago•21 comments

Oxford Molecular Motors

https://www.physics.ox.ac.uk/research/group/oxford-molecular-motors/research/bacterial-flagellar-...
41•handfuloflight•3d ago•6 comments

Project Zero will disclose vulnerabilities 90 days after reporting

https://projectzero.google/2026/11/disclosure-policy.html
226•hacb•20h ago•91 comments

Advancing science and engineering with Antigravity's /teamwork

https://research.google/blog/advancing-science-engineering-with-antigravitys-teamwork-feature/
192•acossta•17h ago•40 comments

Generative AI uses more energy on non-English text

https://news.umich.edu/generative-ai-uses-more-energy-on-non-english-text/
200•DeepLogin•4d ago•104 comments

Astro Spiral: Greatest Car Stunt Was Also First Computer-Modeled Stunt

https://boldentrance.com/astro-spiral-the-greatest-car-stunt/
25•CharlesW•2d ago•0 comments

The Sicilian Citrus Family Tree

https://www.notesfromtheroad.com/europa/citrus-family-tree.html
61•wmchen•4d ago•21 comments

Seagate's new hybrid drive raises some old questions

https://arstechnica.com/gadgets/2026/11/seagate-resurrects-the-ssd-hdd-hybrid-drive/
93•PaulHoule•3d ago•42 comments

'Grey Rocking': The Life-Improving Power of Being Really, Really Boring (2021)

https://www.esquire.com/uk/life/a38473153/grey-rock-technique-being-boring/
137•NaOH•2d ago•79 comments

Testing a trash can Faraday cage

https://www.jefftk.com/p/testing-a-trash-can-faraday-cage
75•torutofu•2d ago•57 comments

Show HN: A custom font based on the Jamaican flag alphabet

https://bobbiec.github.io/jamaican-font.html
27•bobbiechen•6h ago•5 comments

Show HN: A terminal-native idle factory game, written in Rust with ratatui

https://gitlab.com/snipedbywifi/terminactory
154•snipedbywifi•17h ago•38 comments

Reverse engineering a vintage diode-transistor logic chip

https://www.righto.com/2026/11/signetics-st680a-dtl-nand.html
106•dverlaeckt80•6d ago•9 comments