{"version":240,"agent":"capacity","message":"Path names kept in memory once read (disk-first 2; abso Capacity).\n\nAfter 239, collisions on website spent most of its 4.6 s naming files: finding a deleted line's file ends at a file's start node, and Graph.#nodeName read the stored path list for it every time, through the row cache. Line records, line files and an atom's files read it the same way.\n\nGraph.#pathName keeps path names by index in memory, up to 4,096, and clears them whenever the graph accepts an atom, so a name a rolled-back add made never stays.\n\nOn website adopted fresh, cold, one opened writer: collisions 4.6 s to 1.6 s (replay 0.4 s), matching replay. typescript-rs: all 27 answers match.\n\nNamed tests: every engine test (290 of 290), every worker/project test (341 of 341); tsc and biome clean.","time":1792066650781,"timeIso":"2026-10-15T12:17:30.781Z","changes":1,"change":3716,"files":["src/engine/graph.ts"],"draft":null,"diff":[{"path":"src/engine/graph.ts","added":28,"removed":5,"diff":"--- a/src/engine/graph.ts\n+++ b/src/engine/graph.ts\n@@ -267,6 +267,8 @@\n /** A run written in another file under one of a file's lines: [the parent's n, the run's file index]. */\n export type PackedCrossing = [number, number];\n const EMPTY_NUMBERS: readonly number[] = Object.freeze([]);\n+/** At most this many path names kept in memory (Graph.#pathName). */\n+const PATH_NAMES = 4096;\n /** Lines longer than this aren't packed with their file; their text is read on its own. */\n const PACKED_TEXT = 4096;\n \n@@ -881,7 +883,7 @@\n \t\t\tid,\n \t\t\tatom: this.idOfSeq(seq),\n \t\t\tk: n - this.#lineBase[seq]!,\n-\t\t\tfile: this.#paths[this.#lineFile.at(n)]!,\n+\t\t\tfile: this.#pathName(this.#lineFile.at(n)),\n \t\t\tparent: this.#nodeName(this.#lineParent.at(n)),\n \t\t\ttext: this.#text(n),\n \t\t};\n@@ -902,7 +904,7 @@\n \t/** The file a line was written in, or undefined: line(id).file without making the record. */\n \tlineFile(id: LineId): string | undefined {\n \t\tconst n = this.#lineN(id);\n-\t\treturn n < 0 ? undefined : this.#paths[this.#lineFile.at(n)];\n+\t\treturn n < 0 ? undefined : this.#pathName(this.#lineFile.at(n));\n \t}\n \n \t/** The node a line was written after, or undefined: line(id).parent without making the record. */\n@@ -1014,7 +1016,7 @@\n \n \t/** The file line n was written in. */\n \twrittenIn(n: number): string {\n-\t\treturn this.#paths[this.#lineFile.at(n)]!;\n+\t\treturn this.#pathName(this.#lineFile.at(n));\n \t}\n \n \t/** The code of the node line n was written after. */\n@@ -1177,9 +1179,30 @@\n \t}\n \n \t#nodeName(code: number): NodeId {\n-\t\treturn code >= 0 ? this.#lineName(code) : startNode(this.#paths[-1 - code]!);\n+\t\treturn code >= 0 ? this.#lineName(code) : startNode(this.#pathName(-1 - code));\n \t}\n \n+\t/**\n+\t * A path's name by its index, kept in memory once read (abso Capacity): finding a deleted line's file names the file\n+\t * it reaches, and a stored graph read the path list each time. Cleared when the graph accepts an atom, so a name a\n+\t * rolled-back add made never stays.\n+\t */\n+\t#pathName(index: number): string {\n+\t\tif (this.#pathNamesAt !== this.#accepted) {\n+\t\t\tthis.#pathNames.clear();\n+\t\t\tthis.#pathNamesAt = this.#accepted;\n+\t\t}\n+\t\tlet name = this.#pathNames.get(index);\n+\t\tif (name === undefined) {\n+\t\t\tname = this.#paths[index]!;\n+\t\t\tif (this.#pathNames.size >= PATH_NAMES) this.#pathNames.clear();\n+\t\t\tthis.#pathNames.set(index, name);\n+\t\t}\n+\t\treturn name;\n+\t}\n+\treadonly #pathNames = new Map<number, string>();\n+\t#pathNamesAt = -1;\n+\n \t#pathOf(file: string): number {\n \t\tlet p = this.#pathIndex.get(file);\n \t\tif (p === undefined) {\n@@ -1689,7 +1712,7 @@\n \t\t}\n \t\tconst files = new Set<string>();\n \t\tfor (const run of atom.inserts) files.add(run.file);\n-\t\tfor (const n of deletedNumbers(this)) files.add(this.#paths[this.#lineFile.at(n)]!);\n+\t\tfor (const n of deletedNumbers(this)) files.add(this.#pathName(this.#lineFile.at(n)));\n \t\tfor (const a of frozen.attrs ?? []) files.add(a.file);\n \t\tfor (const m of frozen.moves ?? []) {\n \t\t\tfiles.add(this.lineFile(m.line)!);"}],"ci":null}