Count what the transcript draws, not just how long drawing took

"Drawing costs too much" and "drawing was skipped and still costs too
much" need opposite fixes, and a millisecond figure cannot tell them
apart. So the report now carries how many rows were drawn, how many were
skipped, and the height of the tallest one that was drawn.

The first reading answers it. Skipping works -- 854 rows drawn against
24,078 skipped, so 97% of the transcript is correctly not being recorded
-- and the tallest row that *is* drawn is 36,982px. One assistant message
about twenty-five screens tall, whose display list holds every glyph of
it, re-recorded whenever drawing is invalidated. A row that size is a
hundred short rows as far as the draw phase is concerned, and no amount
of skipping its neighbours helps while it is the one on screen.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
irisandClaude Opus 5 committed 2026-08-31 02:28:58 -04:00
1 parent f9432b69cc
commit dffa365e54
2 files changed
+23 -2

No files matched your search

@@ -33,6 +33,15 @@ object DebugStats {
at(counts, name).addAndGet(by) at(counts, name).addAndGet(by)
} }
/** Keeps [name] at the largest value it has been given, for a high-water mark. */
fun atLeast(name: String, value: Long) {
val slot = at(counts, name)
while (true) {
val had = slot.get()
if (value <= had || slot.compareAndSet(had, value)) break
}
}
/** Records one occurrence of [name] that took [elapsed] nanoseconds. */ /** Records one occurrence of [name] that took [elapsed] nanoseconds. */
fun record(name: String, elapsed: Long) { fun record(name: String, elapsed: Long) {
count(name) count(name)
@@ -138,8 +138,20 @@ class TranscriptScroll(internal val scroll: ScrollState) {
val top = tops.getOrNull(index) ?: return true val top = tops.getOrNull(index) ?: return true
val viewportTop = scroll.maxValue - scroll.value val viewportTop = scroll.maxValue - scroll.value
val margin = scroll.viewportSize val margin = scroll.viewportSize
return top + height >= viewportTop - margin && val near =
top <= viewportTop + scroll.viewportSize + margin top + height >= viewportTop - margin &&
top <= viewportTop + scroll.viewportSize + margin
// Counted so that "drawing costs too much" can be told apart from "drawing was skipped and
// still costs too much". They need opposite fixes: the first is a row that should not have
// been drawn, the second is a single row too tall to record cheaply -- and one enormous
// reply on screen records as many glyph runs as a hundred short ones.
if (near) {
DebugStats.count("row drawn")
DebugStats.atLeast("tallest drawn row px", height.toLong())
} else {
DebugStats.count("row skipped")
}
return near
} }
/** Where the last touch went down, in the content's own coordinates. */ /** Where the last touch went down, in the content's own coordinates. */