Repository navigation
perf(session): rebuild transcript time stamps once a minute while streaming - #236
Merged
Merged
Conversation
The projection cache keyed its time stamps on the current second, so while a reply streamed, the first batch of every new second missed the streaming fast path and rebuilt every entry, the stamps and the new-messages mark on the main thread. Stamps only show minutes (and Today turns into Yesterday on a minute), so the key is now the minute, or the second while the last prompt has no time of its own and may read as sent now. Ports iOS #300 (4c26741a). Measured on the VM's JVM with real-format IDs: a streamed batch costs 14-95 us; the once-a-second rebuild cost 0.24 ms (1,000 rows) to 1.5 ms (6,000 rows). That rebuild now happens once a minute. Verified: ported iOS stampsRebuildOnTheMinuteNotTheSecond into TranscriptBenchmarkTests (70 one-second batches rebuild once); it fails on dev's code. Full scripts/check.sh on the Android VM.
A server whose clock is ahead of the phone's mints prompt IDs that read as now. While that lasts, the prompt's pause stamp can cross its one-hour threshold on any second, and keying by the minute held it back until the next minute. Such a prompt now keys by the second, like an untimed one; this differs from iOS, which only checks untimed prompts. Tests: the stamp tests move to their own Robolectric class (TranscriptStreamWorkTests, same file) so the two older tests stay plain JVM. The rollover test asserts the one rebuild lands on second 60; new tests cover an untimed last prompt (rebuilds each second, then minute keying once it has a time) and the skewed-server pause stamp. ID formatting uses Locale.ROOT. Parity: Tests table row for TranscriptStreamWorkTests.swift, row sentence notes the difference. Verified on the Android VM: the new tests pass; dev's per-second key, the previous commit's untimed-only rule and an unconditional minute key each fail at least one of them. Full scripts/check.sh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While a reply streams, the transcript's time stamps, and the whole entry list built with them, were rebuilt on the main thread once a second. Stamps only show minutes, so now they're rebuilt once a minute, or once a second while the last prompt reads as now: it has no time of its own, or it comes from a server clock ahead of the phone's (where a pause stamp can appear on any second). Nothing visible changes. Ports the stamp part of iOS #300 (4c26741a); checking the skewed-server case is Android-only.
On the VM's JVM (not a phone), the once-a-second rebuild took 0.24 ms at 1,000 rows and 1.5 ms at 6,000 rows, against 14–95 µs for a normal streamed batch.
Verified: ported iOS
stampsRebuildOnTheMinuteNotTheSecond(the one rebuild lands on second 60), plus tests for an untimed prompt and a skewed server's pause stamp; dev's logic fails them. Fullscripts/check.shon the Android VM.