Speed up cold diffs and wrapped text measurement (#4676)

* perf(app): optimize wrapped measurements and checkpoint native layout experiment

Compute full grapheme geometry only for final wrap fragments. Preserve shaped-text search behavior while bounding additive wrap probes. Keep the Android background layout experiment isolated from the normal diff renderer; native renderer integration and iOS bindings remain unfinished.

* perf(server): reduce cold diff generation work

Keep active diff reads owned across invalidation and wait for the initial watcher inventory before cold generation. Batch patch and blob reads while preserving per-file size isolation, bounded output, and daemon responsiveness. Avoid constructing fallback tokens when full-file highlighting already covers both sides.

* test(server): exercise oversized highlighted diff rejection

The single-line fixture now bypasses highlighting under the long-line guard, so it no longer reaches the structured payload limit. Use short dense lines to keep testing oversized rejection and continued socket usability.

* fix(server): queue fresh diffs for forced reads

A forced request following a repository mutation must not reuse an older active build. Invalidate that result and coalesce waiting callers onto one subsequent build. Give the cache a named object input and completed-value type.

* test(server): share deferred diff loader setup

* test(server): name completed diff cache setup

* refactor(server): use aliases for new diff imports

* fix(server): keep shipped diff imports resolvable by Node

The TypeScript build preserves path aliases without a runtime resolver. Restore relative imports for shipped code and declarations, and correct the server import guideline that prompted the regression.
This commit is contained in:
Mohamed Boudra
2026-09-11 08:07:01 +02:00
committed by GitHub
parent 16d932651c
commit 33a52d0ae7
32 changed files with 1409 additions and 186 deletions
@@ -10,6 +10,7 @@ export interface CachedAsciiTextMetrics {
measure(text: string): number;
hasEveryGlyph(text: string): boolean;
measureAdvances(graphemes: readonly string[]): number[];
measureWidth(graphemes: readonly string[]): number;
}
const CODE_LIGATURE_CANDIDATE = /(?:===?|!==?|=>|<=|>=|->|::|\+\+|--)/;
@@ -68,6 +69,22 @@ export function createChunkedAdvanceMeasurer(
};
}
/** Preserve advance chunk boundaries when only the final width is needed. */
export function createChunkedWidthMeasurer(
measure: (graphemes: readonly string[]) => number,
): (graphemes: readonly string[]) => number {
return (graphemes) => {
let width = 0;
let start = 0;
while (start < graphemes.length) {
const end = chunkEnd(graphemes, start);
width += measure(graphemes.slice(start, end));
start = end;
}
return width;
};
}
/**
* Advance measurement for a backend that can only measure a whole string, which
* is every backend except a native paragraph shaper.
@@ -144,6 +161,11 @@ export function createCachedAsciiTextMetrics(primary: PrimaryTextFace): CachedAs
return true;
},
measureAdvances: additiveAdvances(measure),
measureWidth(graphemes) {
let width = 0;
for (const grapheme of graphemes) width += measure(grapheme);
return width;
},
};
}