Fix: compare 3-byte key heads inline, and call https://t.co/obR2MNLz6y only on ties. If either key is ≤ 3 bytes, the length decides, with no heap read.
Then caching 3 field reads cut recordOK’s inline cost from 90 to 79 (budget 80), so it inlined.
Lesson: delete calls, not work.
My B-tree binary search in pure Go: 54.5 → ~23 ns (−58%) on a 180-key leaf, zero allocs.
The twist: my first “optimization” made it 10.7% slower (p < 0.001).🥲
What the disassembly showed
Go’s register ABI has no callee-saved general-purpose registers, so every call spills live values to the stack and reloads them.
Each probe made 2 non-inlined calls. My change removed one compare but added 2 live variables: more spills × ~8 calls per search.
wrote the whole paper up from a beginner's POV: comics, a worked example, the proofs without the math, and what it quietly assumes (that's post 2- coming soon...).
Read → Build → Break #1:
https://t.co/a5EuLOhV4L
corrections always welcome, that's the point.
a key was sitting in my B-tree and the lookup swore it didn't exist.
nobody's code was wrong.
turns out a 1981 paper fixed this exact bug with one extra pointer per node. postgres still uses it today 🧵
the one line that makes writes safe: write the new node FIRST, then the pointer to it.
build the bridge, then lift the barrier. swap the order and readers get sent to an empty shelf.
@DanielSmidstrup Currently I am you 194 days ago 👀
Tryna engaging with people through comments . But still don't know what to post about .
Any advice would be extremely helpful 😉!
@Shreyaazvp Was already interested in cloud and infra related stuff like docker , kubernetes, etc.. so this crack head🫠 decided why not learn how to build these rather than web dev or anything!
@Harry_The_Nerd With you bruhhh .... 2nd , 4th , 6th , 7th done 1st going on but with a twist of making it etcd inspired ...
Eager to connect with some like you !!
@itsmenikhitha Agree . Giving up feels much better bcoz haven't put any considerable efforts in it.
I think building for learning and not for selling might make a difference!!
What's ur take?