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

DeepSeek V4 Flash 0731

https://arcprize.org/results/deepseek-v4-flash-0731
305•tosh•3h ago•186 comments

Assembly Hall of Shame

https://github.com/xoreaxeaxeax/asm-hall-of-shame
155•piotrgrabowski•3h ago•34 comments

Ancient Library – 1,060 Greek/Latin texts, click any word to parse it

https://ancientlibrary.net/
80•aagha•2h ago•25 comments

Responding to the next frontier of critical cyber capabilities

https://openai.com/index/responding-next-frontier-critical-cyber-capabilities/
125•artninja1988•5h ago•138 comments

An all-sky map of half a million supermassive black holes

https://www.sdss.org/black-hole-mapper-release-20/
113•MarcoDewey•6h ago•30 comments

What happens if an entire class of workers loses faith in their careers

https://www.noemamag.com/why-is-everyone-in-tech-so-sad/
239•RickJWagner•9h ago•378 comments

Oracle bans AI-generated code from OpenJDK

https://app.dealroom.co/news/feed/oracle-bans-ai-generated-code-from-openjdk-despite-ellison-s-cl...
304•delduca•4h ago•218 comments

Guarded Methods in OCaml

https://xvw.lol/en/articles/oop-refl.html
24•birdculture•4d ago•1 comments

App Store Rejection of the Week: Dark Hours

https://daringfireball.net/2026/08/app_store_rejection_of_the_week_dark_hours
177•_da_•2h ago•76 comments

Carl's Required Reading

https://carlkolon.com/reading/
57•cckolon•6d ago•5 comments

Psychological Warfare in Reverse Engineering (2015)

https://github.com/xoreaxeaxeax/repsych
26•theanonymousone•2h ago•2 comments

Databricks drove down AI coding spend 70%

https://www.databricks.com/blog/managing-ai-coding-costs-scale
130•moonikakiss•3h ago•104 comments

Making Postgres 300x faster for analytics: batching, operator fusion, and SIMD

https://malisper.me/how-we-made-postgres-hundreds-of-times-faster-the-query-engine/
214•poly2it•10h ago•93 comments

Water system controllers don't belong on the internet, says ex-NSA chief

https://www.theregister.com/security/2026/08/07/water-system-controllers-dont-belong-on-the-inter...
12•Bender•28m ago•0 comments

Kitesurf: Agent-first browser that runs in V8 isolates

https://blog.cloudflare.com/kitesurf/
128•m3h•11h ago•33 comments

A year of fighting scrapers on my 1.5 million-page website

https://patronview.com/news/99-percent-of-my-website-traffic-is-bots/
341•petercooper•6h ago•322 comments

2027 memory capacity is reportedly sold out

https://www.ign.com/articles/ramageddon-continues-another-year-as-2027-memory-capacity-is-reporte...
159•inigyou•13h ago•140 comments

Möbius-Strip Crosswords

https://quuxplusone.github.io/blog/2026/08/04/mobius-crossword/
45•ibobev•6h ago•4 comments

Show HN: textlog – A quiet, text-only microblogging platform, open-source, no JS

https://textlog.cc/about
116•stagas•10h ago•51 comments

Radical Study Suggests Life on Earth Arose Twice

https://www.sciencealert.com/radical-study-suggests-life-on-earth-arose-from-non-living-matter-twice
64•jnord•9h ago•70 comments

Britain's New World of Tobacco (2017)

https://www.historytoday.com/archive/feature/britains-new-world-tobacco
15•benbreen•1w ago•0 comments

Why Are There Statues of Beavers on Top of This Oxford Street Shop?

https://londonist.com/london/history/oxford-street-beavers
48•bookofjoe•4d ago•22 comments

Show HN: Wyzer Programming Language

https://github.com/Wyzer-Lang/wyzer
159•v0id_isgood•9h ago•92 comments

Petri Nets as a Music Sequencer

https://blog.stackdump.com/posts/petri-net-sequencer
55•m_kos•4d ago•19 comments

Building community out of strangers (2023)

https://tracydurnell.com/2023/11/30/building-community-out-of-strangers/
27•surprisetalk•3d ago•1 comments

New Mexico court orders Meta to pay $567m over harms to children’s mental health

https://www.theguardian.com/technology/2026/aug/06/new-mexico-court-meta
697•boplicity•21h ago•375 comments

Energizing a vacuum-tube flip-flop module from a 1948 IBM system

https://www.righto.com/2026/07/ibm-604-trigger-tube-module.html
10•geerlingguy•5d ago•3 comments

São Paulo resident transforms degraded area into urban forest

https://saopaulosecreto.com/en/tiquatira-linear-park-en/
312•rmason•6d ago•117 comments

AMD acquires Taalas to boost inference performance by etching models in silicon

https://www.theregister.com/systems/2026/08/06/amd-acquires-ai-chip-startup-taalas-to-boost-infer...
869•itvision•1d ago•652 comments

Thoroughly Understanding C++ ABI (2024)

https://ykiko.me/en/articles/692886292/
53•rramadass•5d ago•59 comments