Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 262 to 263

Compare

+35 −2 in 3 places
Lines 30–41 at 263 (were 30–38 at 262)
3030 readonly #provider?: ReadViewProvider;
3131 readonly #cache = new Map<string | StableSet<AtomId>, View>();
3232
33− constructor(graph: Graph, provider?: (graph: Graph) => ReadViewProvider) {
33+ /** VIEW_BUDGET unless a test asks for less. */
34+ readonly #budget: number;
35+ constructor(graph: Graph, provider?: (graph: Graph) => ReadViewProvider, budget = VIEW_BUDGET) {
3436 this.#graph = graph;
3537 this.#provider = provider?.(graph);
38+ this.#budget = budget;
3639 }
3740 assertUnkeyedAllowed(): void {
3841 if (this.#provider) throw Error("unsupported unkeyed projection membership");
Lines 46–85 at 263 (were 43–52 at 262)
4346 * and #get weighs a view only when it is asked for again. A kept reader trims after each call.
4447 */
4548 trim(): void {
49+ const seen = new Set<object>();
50+ let total = 0;
51+ for (const v of this.#cache.values()) total += v.weight(seen);
52+ if (total > this.#budget) this.#shed(total - this.#budget);
4653 this.#trim();
4754 }
4855
4956 /**
57+ * Let go of the least recently used file layouts across every view, until about `over` bytes are freed (abso
58+ * Capacity). Evicting whole views dropped layouts just made along with old ones: compare 612 to 1224 on abso needs
59+ * both versions' layouts, about 25 MB, and evicting one whole after the call meant asking again laid it all out again.
60+ * A layout several views share goes from all of them.
61+ */
62+ #shed(over: number): void {
63+ // One entry per layout: a layout several views hold (a draft's view borrows its base's) is used as recently as
64+ // any of them used it, and goes from all of them at once, since only that frees it.
65+ const layouts = new Map<object, { used: number; bytes: number; holders: { view: View; path: string }[] }>();
66+ for (const view of this.#cache.values())
67+ for (const f of view.laidOut()) {
68+ const entry = layouts.get(f.layout);
69+ if (entry) {
70+ entry.used = Math.max(entry.used, f.used);
71+ entry.holders.push({ view, path: f.path });
72+ } else layouts.set(f.layout, { used: f.used, bytes: f.bytes, holders: [{ view, path: f.path }] });
73+ }
74+ let freed = 0;
75+ for (const entry of [...layouts.values()].sort((a, b) => a.used - b.used)) {
76+ if (freed >= over) break;
77+ for (const { view, path } of entry.holders) view.forget(path);
78+ freed += entry.bytes;
79+ }
80+ }
82+ /**
5083 * Keep the cached views under VIEW_BUDGET bytes (the website project, #43,
5184 * #46): each view holds every line its files ever had, so a few views of a
5285 * large generated file add up. At most VIEW_COUNT.
Lines 95–101 at 263 (were 62–68 at 262)
6295 for (const [key, v] of [...this.#cache].reverse()) {
6396 if (!full) {
6497 const w = v.weight(seen);
65− if (total + w <= VIEW_BUDGET && kept < VIEW_COUNT) {
98+ if (total + w <= this.#budget && kept < VIEW_COUNT) {
6699 total += w;
67100 kept++;
68101 continue;
MCP
compare on this site's /mcp
CLI
abso diff 262 263 worker/project/views.ts --json
JSON
/christopher/abso-core/compare/262..263?file=worker%2Fproject%2Fviews.ts&format=json