why on a stored writer (disk-first 2; abso Capacity). Version 218 of shared· capacity· Oct 15 (2026-10-15 05:21 UTC) · Not checked
A View reads atoms' numbers from their ids instead of reading each atom: building one from a plain set read every atom twice, and every mover once. keptThrough, the settle a line was kept through, looks only among the atoms that write or take out the file's lines (graph.eachAtomIn), and lays out the file just before that settle from a lazy prefix of the view's set when that set is closed. It used to read every atom in the history and list all the earlier ones. publishOf looks in shared before listing the named drafts, since listing them decodes each one's space. view.ts loses #eachMover, unused since 215. On abso's export, why for line 1 of issues/src/index.ts went from 41 s to 11 s on one opened writer, matching Project.load. The rest is trail's search for a moved line's origin among nearby changes.
Named tests: trail, named-drafts, files-reads, project, markers, version-files, draft-reads-stored, view, moves, drop (109 of 109); tsc and biome clean.
Version 217 · Files at version 218
3 files, 53 lines added, 25 removed.
--- a/src/engine/view.ts
+++ b/src/engine/view.ts
@@ -242,23 +242,24 @@
244 244 const inSet = new Uint8Array(graph.size); 245 − for (const id of set) {
246 − const atom = graph.atom(id);
247 − inSet[atom.seq] = 1;
248 − }
245 + // An atom's number is in its id (abso Capacity): reading the atom for it read the whole history on a stored graph. 246 + const seqIn = (id: AtomId): number => { 247 + const seq = seqOf(id); 248 + return seq >= 0 && seq < inSet.length && graph.idOfSeq(seq) === id ? seq : graph.atom(id).seq; 250 + for (const id of set) inSet[seqIn(id)] = 1; 249 251 // Validate one atom at a time. Keeping all decoded atoms here defeats 250 252 // storage-backed Graph reads even though the view only needs membership. 251 253 for (let seq = 0; seq < inSet.length; seq++) { 252 254 if (inSet[seq] !== 1) continue; 253 255 const atom = graph.atom(graph.idOfSeq(seq)); 254 256 for (const d of atom.deps) { 255 − if (inSet[graph.atom(d).seq] !== 1)
256 − throw new EngineError("not-closed", `set is not closed: ${atom.id} depends on ${d}`);
257 + if (inSet[seqIn(d)] !== 1) throw new EngineError("not-closed", `set is not closed: ${atom.id} depends on ${d}`); 259 260 this.graph = graph; 261 − this.#movers = graph.movers().filter((id) => inSet[graph.atom(id).seq] === 1);
262 + this.#movers = graph.movers().filter((id) => inSet[seqOf(id)] === 1); 262 263 this.#hasMoves = this.#movers.length > 0; 263 264 this.#relocs = this.#movers.length === 0 ? new Map() : undefined; 264 265 this.#relocsN = this.#movers.length === 0 ? new Map() : undefined; @@ -459,10 +460,6 @@
459 460 hasMoves(): boolean { 460 461 return this.#hasMoves; 462 − *#eachMover(): IterableIterator<AtomId> {
463 − if (this.#movers) yield* this.#movers;
464 − else for (const id of this.graph.movers()) if (this.#stable!.has(id)) yield id;
465 − }
467 464 /** The file a line is in, in this set: the one its chain of parents reaches. */ 468 465 fileOf(line: LineId): string { --- a/worker/project/blame.ts
+++ b/worker/project/blame.ts
@@ -4,7 +4,8 @@
4 4 // shared, with its message. Why adds the change's reasons, what it settled, 5 5 // and the reasons other changes give that point at it, and the line's 6 6 // earlier changes (trail.ts). 7 − import { type Atom, type AtomId, type LineId, type ReadView, View } from "../../src/engine/index.ts";
7 + import { type Atom, type AtomId, type LineId, type ReadView, seqOf, View } from "../../src/engine/index.ts"; 8 + import { isClosedSet, markClosed, StableSet } from "../../src/engine/state-source.ts"; 8 9 import { blocksIn, isMarkerLine } from "./markers.ts"; 9 10 import { pathKey } from "./pathkey.ts"; 10 11 import type { Project } from "./project.ts"; @@ -126,21 +127,28 @@
126 127 function keptThrough(project: Project, view: ReadView, file: string, line: LineId, author: Atom): Atom | undefined { 127 128 const graph = project.graph; 128 129 const set = view.set; 129 − for (const s of graph.atoms()) {
130 − if (s.seq <= author.seq || s.resolves.length === 0 || !set.has(s.id)) continue;
130 + // Only atoms that write or take out the file's lines can take out its markers (abso Capacity): every atom in the 131 + // history was read on a stored graph. 132 + for (const id of graph.eachAtomIn(file)) { 133 + if (seqOf(id) <= author.seq) continue; 134 + const s = graph.atom(id); 135 + if (s.resolves.length === 0 || !set.has(s.id)) continue; 131 136 const marks = s.deletes.filter((id) => { 132 137 const info = graph.line(id); 133 138 return info !== undefined && info.file === file && isMarkerLine(info.text); 135 140 if (marks.length === 0) continue; 136 − // The file just before the settle, markers and all.
141 + // The file just before the settle, markers and all: of a closed set, its atoms before the settle, which a 142 + // stored set answers one by one; otherwise listed. 137 143 const before = new View( 139 − graph
140 − .atoms()
141 − .slice(0, s.seq)
142 − .filter((a) => set.has(a.id))
143 − .map((a) => a.id),
146 + ? markClosed(new BeforeSet(set, s.seq)) 150 + .filter((a) => set.has(a.id)) 145 153 if (!before.hasFile(file)) continue; 146 154 const lines = before.lines(file); @@ -152,6 +160,28 @@
163 + /** A set's atoms numbered below a limit. Atoms depend only on earlier ones, so a closed set's prefix is closed. */ 164 + class BeforeSet extends StableSet<AtomId> { 165 + readonly #set: ReadonlySet<AtomId>; 166 + readonly #limit: number; 167 + readonly retainedBytes = 32; 168 + constructor(set: ReadonlySet<AtomId>, limit: number) { 171 + this.#limit = limit; 173 + has(id: AtomId): boolean { 174 + const seq = seqOf(id); 175 + return seq >= 0 && seq < this.#limit && this.#set.has(id); 177 + *values(): SetIterator<AtomId> { 178 + for (const id of this.#set) { 179 + const seq = seqOf(id); 180 + if (seq >= 0 && seq < this.#limit) yield id; 155 185 /** The settler's push that was held for this collision, newest first: its message is that side's reason. */ 156 186 function heldPush(project: Project, settle: Atom, file: string, after: number) { 157 187 const held = project --- a/worker/project/publish-of.ts
+++ b/worker/project/publish-of.ts
@@ -18,11 +18,12 @@
18 18 host: PublishOfHost, 20 20 ): { draft: string | null; version: number; agent: string; message: string; time: number } | undefined { 21 − const spaces = [
22 − host.shared(),
23 − ...[...host.spaces.values()].filter((s) => s.name !== SHARED).toSorted((a, b) => (a.name < b.name ? -1 : 1)),
24 − ];
25 − for (const space of spaces) {
21 + // Shared first, and the named drafts only when it isn't there: listing them reads each one's space. 22 + const spaces = function* (): Generator<Space> { 24 + yield* [...host.spaces.values()].filter((s) => s.name !== SHARED).toSorted((a, b) => (a.name < b.name ? -1 : 1)); 26 + for (const space of spaces()) { 26 27 const version = space.publishedIn.get(atom); 27 28 if (version === undefined) continue; 28 29 const p = space.versions[version]!;