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

HackerTube: YouTube built from videos recommended by HN

https://karpathy.bearblog.dev/hacker-tube/
23•karpathy•37m ago•14 comments

TCP Use-After-Free: CVE-2026-98432 / CVSS 9.8

https://atlasum.net/blog/cve-2026-98432-linux-ipv4-tcp-uaf
75•oger•1h ago•40 comments

The Duty of a Scholar

https://www.daemonology.net/blog/2026-10-31-The-Duty-of-a-Scholar.html
42•gslin•1h ago•8 comments

GPT-5.6 Sol can beat Factorio on peaceful mode

https://ryanmadden.net/gpt-56-beats-factorio/
87•ryanmadden•1h ago•82 comments

It's the Memory Latency, Stupid

https://pivotlake.io/blog/its-the-memory-latency-stupid/
36•ntur1337•1h ago•6 comments

Show HN: NES Contra (1987) port (ASM –> C and then C –> WebAssembly)

https://epoyraz.github.io/nes-contra-us/
10•tevlon•1h ago•4 comments

Molly (Signal fork) has not been updated since 3 months and is vulnerable

https://piefed.world/post/1503394
265•DeepLogin•10h ago•158 comments

Jepsen: ParticleDB 1.1.4

https://jepsen.io/analyses/particledb-1.1.4
118•aphyr•6h ago•55 comments

Much Ado About None: Sentinel Values in Python

https://florianwilhelm.info/2026/10/sentinel_values/
15•sebg•1d ago•4 comments

Show HN: A language model that lives in a boot sector

https://github.com/kerlenton/bootgpt
17•kerlenton•7h ago•0 comments

Do the math: How we took over ChatGPT accounts

https://www.parameter.ai/labs/we-found-a-gap-at-openai
279•armcat•10h ago•130 comments

Noctua Fan Swap on a Calnex Rb/GPS Frequency Reference

https://www.jeffgeerling.com/blog/2026/noctua-fan-swap-calnex-rb-gps-frequency-reference/
21•aray07•2d ago•10 comments

Redox: Ring Buffers Project Summary

https://www.redox-os.org/news/nlnet-rb-summary/
34•g0xA52A2A•3d ago•4 comments

William Nordhaus has died

https://news.yale.edu/2026/10/31/william-nordhaus-nobel-laureate-who-integrated-economics-and-cli...
27•ilreb•2h ago•2 comments

I post trained a model on Demoscenes

https://datavorous.com/writing/demoscener/
30•datavorous_•2h ago•16 comments

Simple circuits can create complex behaviors

https://aatishb.com/myriad/lets-build-a-brain/
171•aatish•4d ago•56 comments

5 years of OqtaDrive: Microdrive emulation to Sinclair Network over the internet

https://oqtadrive.org/10.other/5-years/
4•xelalex•1d ago•1 comments

Reading and writing are less symmetric than you (probably) think

https://fgiesen.wordpress.com/2015/10/25/reading-and-writing-are-less-symmetric-than-you-probably...
55•luu•3d ago•18 comments

Switch Lowering in GCC

https://xoranth.net/gcc-switch/
178•signa11•12h ago•34 comments

Serbia just elected the world's brainiest parliament

https://www.science.org/content/article/serbia-just-elected-world-s-brainiest-parliament
737•input_sh•10h ago•427 comments

Digital minimalism

https://vitalik.eth.limo/general/2026/10/31/digital_minimalism.html
270•wilbertliu•14h ago•201 comments

Casio Watches of the 1980s

https://www.casio.com/us/watches/50th/Heritage/1980s/
165•karagenit•4h ago•86 comments

Show HN: Ghostman – A fast, keyboard-driven TUI API client and webhook inspector

https://github.com/4yk5/Ghostman
29•4yk5•1d ago•23 comments

Malware uses LLMs to rank victims by how much they're worth

https://blog.talosintelligence.com/appraisal-by-ai-model-driven-victim-prioritization-in-the-volt...
208•khalidkhair•6h ago•114 comments

Hackers hijack Egypt highway billboard and Malaysian screens to show porn

https://www.cairoreport.org/p/egypt-brazil-iraq-billboard-hack
41•entryleveljobsc•2h ago•46 comments

AI, Lean, and the Future of Formal Verification, with Lean Creator Leo de Moura

https://thedataexchange.media/leo-de-moura-lean-aws/
171•datascientist•2d ago•38 comments

Show HN: A USB-C LTE modem that gives my computer a phone line

https://github.com/Koppar-AI/koppar-lte-modem
22•abijahkaj•4h ago•9 comments

The Impact of Generative AI on Critical Thinking: Self-Reported (2025)

https://dl.acm.org/doi/full/10.1145/3706598.3713778
61•the-mitr•2h ago•40 comments

Show HN: Marelleo, an open-source story box I built for my kids using ESP32

https://zebra.rodeo/en/blog/marelleo/
172•foOg•4d ago•47 comments

What is a light-day? The milestone Voyager 1 is closing in on

https://science.nasa.gov/mission/voyager/voyager-1/voyager-1-what-is-a-light-day/
67•geox•4h ago•34 comments