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
649•ls612•3h ago•446 comments

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

https://www.crissyfield.de/research/lovable-en/
627•armcat•7h ago•261 comments

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

https://retrocomputing.stackexchange.com/questions/17957
78•Skyfall106•2h ago•24 comments

A family tree of software job titles

https://zwischenzugs.com/2026/11/03/a-family-tree-of-software-job-titles/
199•umerf•7h ago•98 comments

Nvidia deliberately kept GPU prices high through circular financing deals

https://www.techspot.com/news/114558-nvidia-deliberately-kept-gpu-prices-high-through-circular.html
149•madihaa•2h ago•82 comments

KDE: The documentary [video]

https://tube.kockatoo.org/w/fFinNHfanLT7aBEb2B8y4c
378•mrkn1•11h ago•81 comments

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

https://blog.pypi.org/posts/2026-11-06-ui-updates-complete/
201•rbanffy•9h ago•90 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/
503•casi•4d ago•280 comments

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

https://github.com/Vaibhaav-Tiwari/deepseek-v3-jax
170•VaibhaavTiwari•10h ago•8 comments

Advancing science and engineering with Antigravity's /teamwork

https://research.google/blog/advancing-science-engineering-with-antigravitys-teamwork-feature/
160•acossta•11h ago•36 comments

Seagate's new hybrid drive raises some old questions

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

Write your own kernel optimiser

https://blog.csongor.co.uk/cachet-grids-and-tiles/
17•speckx•4d ago•0 comments

Oxford Molecular Motors

https://www.physics.ox.ac.uk/research/group/oxford-molecular-motors/research/bacterial-flagellar-...
6•handfuloflight•3d ago•1 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/
90•NaOH•2d ago•54 comments

Generative AI uses more energy on non-English text

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

Reverse engineering a vintage diode-transistor logic chip

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

Testing a trash can Faraday cage

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

LinkedIn, Monster take down over 1000 fake job postings after CBC investigation

https://www.cbc.ca/news/canada/linkedin-monster-take-down-over-1-000-fake-job-postings-after-cbc-...
183•gnabgib•6h ago•101 comments

Project Zero will disclose vulnerabilities 90 days after reporting

https://projectzero.google/2026/11/disclosure-policy.html
150•hacb•14h ago•37 comments

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

https://gitlab.com/snipedbywifi/terminactory
135•snipedbywifi•11h ago•27 comments

L3Harris statement on the Nov. 13 ground stop

https://www.l3harris.com/newsroom/press-release/2026/11/l3harris-statement-nov-13-ground-stop
58•taspeotis•2h ago•29 comments

The Sicilian Citrus Family Tree

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

Tech companies are trying to shift the concept of privacy again

https://www.eff.org/deeplinks/2026/11/tech-companies-are-trying-shift-entire-concept-privacy-again
458•gslin•12h ago•173 comments

Demystifying phone unlocking tools: A technical overview

https://osservatorionessuno.org/blog/2026/05/demystifying-phone-unlocking-tools-a-technical-overv...
72•iloveyoutwo•10h ago•6 comments

Let's Write a PostScript Interpreter

https://beyondloom.com/blog/postscript.html
107•RebelPotato•1d ago•17 comments

Italy fines Meta $887M over Android users' data access

https://www.reuters.com/world/italy-fines-meta-887-million-over-android-users-data-access-2026-11...
328•giuliomagnifico•11h ago•218 comments

A visual explanation of reinforcement learning

https://aatishb.com/myriad/how-brains-learn/
119•aatish•11h ago•6 comments

Creating a self booting ZIP archive

https://goliath32.com/blog/ziphead.html
49•gdgghhhhh•8h ago•7 comments

Dartmouth (Guarini) will not admit math PhD cohort this year

https://www.thedartmouth.com/article/2026/11/gandhi-fagell-guarini-will-not-admit-math-ph-d-cohor...
77•sebg•5h ago•26 comments

Show HN: Fursoy – Out-of-order RV64IMAFDV core in SystemVerilog (Linux 6.6)

https://github.com/FURSOY/fursoy-cpu
69•fursoy•11h ago•23 comments