Files
ARCADIA-Studio/harness/experiments/text-diagnostics-20260913/reviews/annotation-performance-rationale.md
T
sorokin.oleg.edu 9fd76aef3a Add current-draft diagnostic underlines and passive hover
Preserve raw include diagnostic provenance and derive bands from the existing shaped editor. Retain deferred tooltip paragraphs through rendering. Include source, regression, failure and native-trial evidence; corrected native acceptance remains pending.
2026-09-13 01:43:22 -07:00

4.0 KiB
Raw Blame History

Prepared annotation performance evaluator

Private unrun snippet prepared-annotation-performance.rs, intended as a child test module of source_annotations only after parent review. One ignored manual test, no tracked edits, Cargo, build, GUI or shared-target changes. The current correctness tests remain separate.

Question: does projection cost follow visible annotation work, or also hidden wrapping/diagnostic density? Four real-layout specimens compare a 4,000-paragraph ordinary file at top/deep with a 138,000-byte single paragraph at top/deep. The single paragraph must have over1,000 actual wraps; its deep viewport must be beyond all1,500 diagnostic ranges. Real scroll/logical-line/wrap preconditions assert rather than silently skip. PlainText graphics editor is built/shaped outside timers.

Each specimen prints five nonwarmup per-call samples and min/median/max for dense Index construction (batch1), actual layout_runs enumeration, bands with zero diagnostics, one visible diagnostic, dense diagnostics, and dense diagnostics under an entirely rejecting clip (each batch8). One excluded warmup precedes each phase. Allocation is included, result destruction excluded and black_box consumes results. Inputs, visibility counts, dense output count and actual scroll are printed. No fixed millisecond threshold or automated speed pass. Parent records environment/source hashes/stdout and interprets distribution ratios; repeat only if noisy or a concrete code change needs comparison.

Controls are discriminating: sparse visible glyph must produce bands; empty diagnostics and fully rejected clip must produce none; deep single-line diagnostics must all be offscreen, despite residing in the same logical paragraph. Comparing layout-runs-only top/deep isolates hidden-wrap enumeration. Comparing zero/sparse/dense distinguishes iterator overhead, paragraph source validation and range scanning. Rejected clip illustrates work done before final clipping; it is not expected to be a speed improvement in current code. The output correctness assertions are not performance limits.

Static costly cases in current source_annotations.rs, not measured results:

  • Cosmic LayoutRunIter begins layout_i=0 within scroll.line and visits preceding wrapped layout rows until scroll.vertical is consumed. A deep single paragraph therefore incurs O(hidden wrapped rows) even if Index has no diagnostics.
  • Index::bands visits every Part on a visible logical line and scans that run's glyphs for every part. Thousands of diagnostics earlier in the same paragraph incur O(visible runs × line parts × run glyphs) even when all diagnostic bytes precede visible text.
  • The exact source paragraph equality test is repeated for each visible run. Distinct source/buffer storage can require comparing the full logical paragraph repeatedly, adding O(visible runs × paragraph bytes); it is useful defense but not whole-publication authority.
  • An entirely rejecting ancestor clip is applied after candidate/glyph interval work, so it does not currently avoid that cost.

Potential bounded followups if distributions confirm material cost: validate each logical paragraph once per projection; skip visibly nonintersecting ranges using precomputed candidate bounds; reject wholly clipped runs before glyph processing. Hidden wrap enumeration belongs to the actual buffer iterator, so measure before proposing a dependency extension or caching actual layout offsets. Never substitute a guessed uniform-font scroll mapping or stale geometry cache. Repeated overlapping real diagnostics can inherently require many output bands; do not hide those via silent truncation.

Limitations: CPU layout/projection only; no syntax-font reflow, pointer-frequency integration, allocator peak-memory measurement, GPU/native responsiveness or tooltip layout. The standalone cost phase is sequential and can show thermal/order effects; the five samples expose dispersion but do not justify universal performance claims. Parent should not infer production hover cost solely from this synthetic evaluator.