fixup - #156
Merged
Merged
Conversation
TSO acquisition time was invisible in TraceMetrics: Begin()'s GenTs is not covered by any per-phase metric (showing up only as a gap between total_time_us and the sum of parts), and the forced FetchTso inside prewrite is indistinguishable from real prewrite work. Under high concurrency the TSO rwlock convoy makes both segments dominate the transaction latency. Add tso(time_us count) to TraceMetrics, accumulated at the five critical-path TSO call sites: Begin start_ts, prewrite physical_ts, 1pc/async-commit commit_ts, 2PC DoCommit and CommitPrimaryKey retry. The prewrite/commit portion overlaps the corresponding sdk_time_us by design; background heartbeat and lock-resolver calls are not counted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…cal time GenPhysicalTs unconditionally does Refresh + FetchTso under the process-wide tso write lock on every prewrite round and heartbeat. The fetched physical time only feeds lock_ttl (deadline granularity 20s), yet under high concurrency the lock convoy makes apparent tso latency grow linearly with thread count (queue depth x rpc RTT), dominating small-transaction latency; the Refresh also discards the GenTs batch cache, forcing Begin to refetch as well. Add TsoProvider::GetPhysicalTs: extrapolate current physical ms from an anchor (tso physical + steady_clock captured on every FetchTso) under the read lock, monotonically clamped, falling back to a real fetch only when the anchor is older than tso_anchor_max_age_us (default 60s). The anchor stays ms-fresh in practice since Begin's GenTs refetches after any idle gap beyond stale_period_us. Extrapolation error (50ms server tick + local clock drift) is negligible against the 19s ttl margin. Prewrite and heartbeat switch to it; start_ts/commit_ts/min_commit_ts still use GenTs for global ordering, and lock resolver is unchanged. 128-thread benchmark on a local cluster: per-txn tso time p50 26ms -> 45us, trace total-vs-parts gap p50 12.9ms -> 63us, throughput +50%, coordinator fetches 1.4 -> 0.14 per txn. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
chuandew
approved these changes
Jul 28, 2026
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.
No description provided.