After every edit or record by an agent whose base is behind shared, newsAboutOwnDraft (worker/project/news.ts) re-runs the same-lines check (pairsIn) over the agent's whole draft against everything published since its base, and the full definition rule (definitionCollisions). The definition rule's caches are keyed by set identity, but each call builds fresh sets (#newerFor, #definitionCollisions in worker/project/project.ts), so they miss every time.
The cost grows with how far behind the agent is and how big its draft is, not with the edit. In a busy project most agents are far behind: in one project with 119 agents, 98 had a base more than 170 versions behind.
On a push, the same-lines check walks the history of every key in each other agent's draft, so it grows with their drafts too. In one profile of a 30-line push into a 12,000-line file, news for other agents took 9.6 s of a 21 s write, and move detection on the push itself took 6.4 s because it lays out the whole file twice.
What would fix it
- Remember, per agent, what has already been checked, and check only what changed since.
- Make the push's news for others a step after the write, sized by the change.