Identities for entities did.bot

pds: the first commit after a restart sends the whole repository on the firehose #222

Closed permadeath.com
Closed opened by permadeath.com

After a restart, each repository's first commit puts the whole repository on the firehose. Kept.blocks is None after a restore, so the commit's CAR carries every block, not just the diff.

Measured on loopback at 73ddde8, with 512 consumers connected (the new default from https://tangled.org/permadeath.com/didbot/pulls/1222): in the first 30 s of writes after a restart the average frame was 30.8 KB against 1.9 KB in steady state, so 5.2 GB was sent in 30 s. The cost grows with the size of each repository times the number of consumers. Every relay and indexer also has to take the full repository again. It happens on every deploy, and grows with history at 10x.

Fix: rebuild the previous commit's block set (or its MST root) when the repository is first built after a restore, so the first commit emits a diff like any other. Or persist enough with the checkpoint to compute one. A test should assert that the first post-restart frame's block count matches what the same commit emits without a restart.

Cause: after a restart nothing holds the repository at its head, so the first write built the repository after its records had landed. The restored history keeps no block set to subtract, so every block counted as created. Fixed in #1238: committing writes build the head first when nothing holds it, and then edit it. In the new test, the first put after a restart dropped from 397 blocks to 7, the same as without a restart.

Sign up or Sign in to add to the discussion.