Files
manual_slop/docs/twitter/2076893128515112995/thread.md
T
ed 0f80938a55 docs(twitter): add 2076893128515112995 corpus (NOTimothyLottes error-check disasm)
6-post single-author walkthrough of the fast-path error-check pattern:
volatile store __LINE__ + error code, TEST, conditional forward branch
to a distant Err() call. Companion to the 2063733456144597200 thread
which established the macro system via the conversation with
@winning_tactic.
2026-07-26 21:15:16 -04:00

2.1 KiB

title, author, handle, post_url, post_id, timestamp, post_count, reply_count, repost_count, like_count, view_count
title author handle post_url post_id timestamp post_count reply_count repost_count like_count view_count
So I can liter error checks around stuff with little actual cost, NOTimothyLottes @NOTimothyLottes https://x.com/NOTimothyLottes/status/2076893128515112995 2076893128515112995 2026-07-14 04:54:43 6 0 0 3 419

@NOTimothyLottes — So I can liter error checks around stuff with little actual cost,

Post 1 (2026-07-14 04:36:51)

Another round of getting optimized error checking. Disassembly [after syscall] shows that it works. (1.) Volatile store LINE (2.) Volatile store "error code" (3.) TEST if error (4.) Conditional forward branch on error [static prediction untaken] AS_MINIMAL_AS_ONE_CAN_GET

Media 1

Post 2 (2026-07-14 04:43:38) — reply to Post 1

A macro cheat sheet to try to explain how it works ...

Media 1

Post 3 (2026-07-14 04:46:54) — reply to Post 2

I have a collection of force inline wrappers that test returns from syscalls/functions for error and return the return. These all leverage builtin_expect so the compiler knows to make them fall through in the common case.

Media 1

Post 4 (2026-07-14 04:50:23) — reply to Post 3

Those force inlines call Err() on terminal error. The Err() function ensures the {LINE, error} stores are visible, then triggers the console drawing code to kill the app with printed error. Then it sleeps until the termination.

Media 1

Post 5 (2026-07-14 04:52:35) — reply to Post 4

Compiler eventually screws up, but at least it gets the fast path correct, and the slow error path gets an extra call. Effectively it conditionally forward branches to a distant call to Err() instead of just branching to the Err().

Post 6 (2026-07-14 04:54:43) — reply to Post 5

So I can liter error checks around stuff with little actual cost, (1.) Two stores (2.) A CMP or TEST (3.) An ignored on no-error branch on the first execution! [this code almost never runs 2 times].