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.
This commit is contained in:
ed
2026-07-26 21:15:16 -04:00
parent 0d51c3541d
commit 0f80938a55
6 changed files with 165 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

@@ -0,0 +1,55 @@
---
title: "So I can liter error checks around stuff with little actual cost,"
author: "NOTimothyLottes"
handle: "@NOTimothyLottes"
post_url: "https://x.com/NOTimothyLottes/status/2076893128515112995"
post_id: "2076893128515112995"
timestamp: "2026-07-14 04:54:43"
post_count: 6
reply_count: 0
repost_count: 0
like_count: 3
view_count: 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](./media/2076888631508107561_1.png)
## 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](./media/2076890340057878586_1.png)
## 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](./media/2076891161898143906_1.png)
## 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](./media/2076892038314741815_1.png)
## 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].
@@ -0,0 +1,110 @@
{
"root_post_id": "2076893128515112995",
"posts": [
{
"post_id": "2076888631508107561",
"author": "NOTimothyLottes",
"handle": "NOTimothyLottes",
"text": "Another round of getting optimized error checking. Disassembly [after syscall] shows that it works. \n(1.) Volatile store __LINE__\n(2.) Volatile store \"error code\"\n(3.) TEST if error\n(4.) Conditional forward branch on error [static prediction untaken]\nAS_MINIMAL_AS_ONE_CAN_GET",
"timestamp": "2026-07-14 04:36:51",
"media_urls": [
"https://pbs.twimg.com/media/HNKWJZqXwAADMnN?format=png&name=orig"
],
"reply_to_id": null,
"quote_of_id": null,
"metrics": {
"reply_count": 2,
"repost_count": 0,
"like_count": 8,
"view_count": 1903
}
},
{
"post_id": "2076890340057878586",
"author": "NOTimothyLottes",
"handle": "NOTimothyLottes",
"text": "A macro cheat sheet to try to explain how it works ...",
"timestamp": "2026-07-14 04:43:38",
"media_urls": [
"https://pbs.twimg.com/media/HNKX5DhXIAE1BG6?format=png&name=orig"
],
"reply_to_id": "2076888631508107561",
"quote_of_id": null,
"metrics": {
"reply_count": 2,
"repost_count": 0,
"like_count": 7,
"view_count": 567
}
},
{
"post_id": "2076891161898143906",
"author": "NOTimothyLottes",
"handle": "NOTimothyLottes",
"text": "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.",
"timestamp": "2026-07-14 04:46:54",
"media_urls": [
"https://pbs.twimg.com/media/HNKY8qFXQAAF9Db?format=png&name=orig"
],
"reply_to_id": "2076890340057878586",
"quote_of_id": null,
"metrics": {
"reply_count": 1,
"repost_count": 0,
"like_count": 5,
"view_count": 350
}
},
{
"post_id": "2076892038314741815",
"author": "NOTimothyLottes",
"handle": "NOTimothyLottes",
"text": "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.",
"timestamp": "2026-07-14 04:50:23",
"media_urls": [
"https://pbs.twimg.com/media/HNKZyFTXYAAETnU?format=png&name=orig"
],
"reply_to_id": "2076891161898143906",
"quote_of_id": null,
"metrics": {
"reply_count": 1,
"repost_count": 0,
"like_count": 2,
"view_count": 143
}
},
{
"post_id": "2076892591216341089",
"author": "NOTimothyLottes",
"handle": "NOTimothyLottes",
"text": "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().",
"timestamp": "2026-07-14 04:52:35",
"media_urls": [],
"reply_to_id": "2076892038314741815",
"quote_of_id": null,
"metrics": {
"reply_count": 1,
"repost_count": 0,
"like_count": 2,
"view_count": 449
}
},
{
"post_id": "2076893128515112995",
"author": "NOTimothyLottes",
"handle": "NOTimothyLottes",
"text": "So I can liter error checks around stuff with little actual cost,\n(1.) Two stores\n(2.) A CMP or TEST\n(3.) An ignored on no-error branch on the first execution! [this code almost never runs 2 times].",
"timestamp": "2026-07-14 04:54:43",
"media_urls": [],
"reply_to_id": "2076892591216341089",
"quote_of_id": null,
"metrics": {
"reply_count": 0,
"repost_count": 0,
"like_count": 3,
"view_count": 419
}
}
],
"source_url": "https://x.com/NOTimothyLottes/status/2076893128515112995"
}