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

ChatGPT Desktop (Codex Desktop) for Linux

https://openai.com/codex/
102•allanrbo•4h ago•45 comments

DeepSeek V4 Pro 0813

https://openrouter.ai/deepseek/deepseek-v4-pro-0813
917•explosion-s•17h ago•373 comments

Tracking down the 16-year-old WAL-reset SQLite bug

https://tailscale.com/blog/sqlite-wal-reset-bug
1028•ropbear•19h ago•191 comments

Qwen3.8-2.4T

https://huggingface.co/Qwen/Qwen3.8-2.4T-A95B
616•Philpax•18h ago•145 comments

Delta

https://zed.dev/blog/introducing-delta
544•khy•15h ago•193 comments

Principia Mathematica is modern and insightful

https://okmij.org/ftp/Computation/Impressions/PrincipiaMathematica.html
149•matt_d•9h ago•67 comments

Antiqua–Fraktur dispute

https://en.wikipedia.org/wiki/Antiqua%E2%80%93Fraktur_dispute
82•buzzy_hacker•2d ago•13 comments

The punched card tabulator

https://www.ibm.com/history/punched-card-tabulator
9•Bluestein•5d ago•0 comments

Mushroom behind 'tiny people' hallucinations identified

https://phys.org/news/2026-08-qa-mushroom-tiny-people-hallucinations.html
139•wglb•5d ago•111 comments

2026 Eclipse Webcams

https://jonty.github.io/2026_eclipse_webcams/
485•zoenolan•21h ago•132 comments

uBlock Origin Is Giving Up the Fight to Keep Ads Off Facebook

https://digitalescapetools.com/2026/08/ublock-origin-stops-chasing-facebook-ads.html
489•Markoff•21h ago•591 comments

Happy 45th Birthday to the IBM PC and Model F/XT

https://sharktastica.co.uk/articles/pc-fxt-45
89•tart-lemonade•9h ago•22 comments

Flutter 3.47

https://flutter.dev/blog/whats-new-in-flutter-3-47
98•gumby271•9h ago•97 comments

Why Target Common Lisp for Code Generation?

http://funcall.blogspot.com/2026/08/why-vibe-code-in-lisp.html
96•oumua_don17•1d ago•82 comments

Tim King, AmigaDOS developer, has died

https://amiga-news.de/en/news/AN-2026-08-00070-EN.html
270•doener•19h ago•33 comments

HTML over WebSockets: real-time SPAs with barely any JavaScript

https://en.andros.dev/blog/ef4968f5/html-over-websockets-real-time-spas-with-barely-any-javascript/
194•redbell•16h ago•136 comments

Grok 4.6

https://x.ai/news/grok-4-6
541•iLuddite•17h ago•488 comments

Launch HN: Discovered Materials (YC P26) – AI agents to discover new materials

https://discoveredmaterials.com/research/
137•advaith08•1d ago•29 comments

From rubber boots to Copa: When MicroProse Soccer revolutionized football

https://spillhistorie.no/2026/08/08/fra-gummistovler-til-copa-da-microprose-soccer-revolusjonerte...
24•TMWNN•3d ago•1 comments

The Three-Stroke Problem

https://penpot.app/blog/the-three-stroke-problem/
10•elenathor•1w ago•0 comments

Thanks to social media, canned sardines are a scarcity on the supermarket shelf

https://corneroffifth.studio/why-cant-you-find-canned-sardines-right-now/
118•carabiner•11h ago•151 comments

Why tiny JPEGs look different in Chrome

https://guillaumetech.github.io/posts/jpg-scaling-chrome/
297•gutechh•19h ago•65 comments

Someone is running mass vulnerability scans, spoofing AI bots like ClaudeBot

https://knownagents.com/insights
275•gavinhking•19h ago•201 comments

Breaking the WAL

https://antithesis.com/blog/2026/wal-reset-bug/
106•wwilson•13h ago•42 comments

Build Wide, Ship Narrow

https://adapt.com/blog/build-wide-ship-narrow
84•ashumz•9h ago•24 comments

Pixel Watch 5

https://blog.google/products-and-platforms/devices/pixel/pixel-watch-5/
143•ortusdux•17h ago•277 comments

Shade Map

https://shademap.app
194•fredley•20h ago•49 comments

Lovable raises $400M Series C

https://lovable.dev/blog/series-c
141•thoughtpeddler•17h ago•146 comments

AI is removing the middle class of software engineering?

https://blog.florianherrengt.com/ai-removing-middle-class-software-engineering.html
874•florianherrengt•20h ago•782 comments

Show HN: Woxi - Open-source Mathematica / Wolfram Language reimplementation

https://woxi.ad-si.com
289•adius•23h ago•41 comments