@BridgetrollP@mummiezmom@Apex_willye When Hulk snapped I remember he said that he tried to bring Black Widow back but he couldn't. Maybe stones can't undo death.
GitHub is rebuilding how it stores Git repositories because of, well, AI agents. They published a blog post about it, and one idea that was very insightful was how it makes reading nearly free when nothing has changed. Here is how it works...
Today, even a very busy repository sees at most a few dozen writes per second. With hundreds of agents pushing to the same repository, GitHub wants thousands per second. Before we dig in, let us understand what a reference is. In Git, a reference is a name that points to a commit, like a branch:
- `main` points to commit `a1`
- `fix-login` points to commit `b1`
When you push, you add your new commit and then move a reference to it. For example, pushing to `fix-login` changes it from `b1` to `b2`. The push is only complete once that reference is updated.
When someone clones or fetches, the server cannot send anything until it looks up what each reference points to. "Give me `main`" means nothing until the server knows `main` is at `a1`.
GitHub first tried two designs for storing references on plain object storage:
- Keep all references in one log file. Reading is easy, because everything is in one place. But every push has to wait its turn to write to that one file, so it topped out at a few hundred writes per second.
- Split references across many files. Pushes can now write in parallel. But to get the full picture, a read has to check every file, so reads became slow.
Each design speeds up one side and slows down the other. So the team built a dedicated replicated log called Ref-CAS to track references. It does two things:
- Writes lock only the references they change. A push says "move `fix-login` from `b1` to `b2`, but only if it is still at `b1`", and only `fix-login` is locked while that check happens. An agent pushing to `add-tests` is not affected. Agents mostly push to their own branches, so they rarely wait on each other.
- Every successful change gets the next number. Moving `fix-login` is change 101, and creating `add-tests` is change 102. The version of the repository is the latest number, so it is 102 now. Ref-CAS can tell exactly what anyone holding an older number missed.
Now, how does this make reads faster?
The replicas that serve requests keep a local copy of the references, tagged with the version they last saw. Here is an example:
1. A replica has a copy at version 100: `main` is `a1`, `fix-login` is `b1`.
2. Two agents push at the same time. `fix-login` moves to `b2` (version 101), and a new branch, `add-tests`, appears at `c1` (version 102).
3. A read arrives. The replica asks Ref-CAS: "I am at version 100, anything new?"
4. Ref-CAS answers with the updated references and the new version, plus pointers to any pack data the replica needs: `fix-login` is now `b2`, `add-tests` is `c1`, and the version is 102. The replica updates its copy.
5. The next read asks "I am at version 102". Ref-CAS says "yes, you are current" and sends no references.
So when nothing has changed, a read costs one number comparison. The replica does not need to check every reference or every segment, which was the problem with the second design.
With the new architecture, GitHub reports 7,200 pushes per second to a single repository in internal tests, with 5,000 agents pushing at once.
Classic solution to a classic problem.
I know that something amazing is about to unfold in my life this October. I surrender to the Almighty and trust Him to take me where I am destined to be.