Repository navigation
Closed
Description
Summary
High-concurrency sysbench point_select shows severe mutex contention in the trace control read path. The dominant mutex wait is not the txn close lock addressed by #25490; it is trace.Start repeatedly calling IsMOCtledSpan, which takes a global sync.Mutex for read-only access to mo_ctl controlled span configuration.
Workload
oltp_point_select1000vu,--db-ps-mode=auto(prepared)- clean table/data after removing read_write tombstone pollution
- file service cache: SHARED memory cache 8GB
- standalone mo-srv-129, 64 CPUs,
GOMEMLIMIT=40000MiB - Result: 150,941 TPS, avg 6.61ms, p95 27.17ms
- CPU profile: 1602.14s samples / 30s = ~53.4 cores, so CPU is high but not fully saturated on 64 CPUs
Profile Evidence
Mutex profile: /data/mo-prof/pprof/1000vu_clean_auto/mutex.pprof
Total mutex delay: 486.38hrs
IsMOCtledSpan 338.65hrs 69.63%
trace.Start 308.91hrs 63.51%
sync.Mutex.Unlock 410.50hrs 84.40% flat
txnClient.closeTxn 35.88hrs 7.38%
txnOperator.closeLocked 36.16hrs 7.44%
Line-level evidence:
github.com/matrixorigin/matrixone/pkg/util/trace.IsMOCtledSpan
338.65hrs cum, 69.63% of total mutex delay
config.go:210 MOCtledSpanEnableConfig.Lock()
config.go:211 defer MOCtledSpanEnableConfig.Unlock()
config.go:213 if state, exist := MOCtledSpanEnableConfig.KindToState[kind]; exist {
config.go:214 return true, state.Enable, state.Threshold
config.go:216 return false, false, 0
Current structure:
var MOCtledSpanEnableConfig struct {
sync.Mutex
NameToKind map[string]SpanKind
KindToState map[SpanKind]*MoCtledState
}IsMOCtledSpan is a hot read path under high concurrency, while SetMoCtledSpanState is a rare control operation. A global exclusive mutex serializes all concurrent trace-start reads.
Impact
- Large aggregate mutex wait under 1000vu point_select.
- CPU is not fully saturated despite high throughput, indicating goroutines spend significant time waiting.
- This is separate from perf(txn): drop redundant client.mu lock in closeTxn success path #25490: closeTxn remains only ~7.4% of mutex delay in this clean run, while trace control accounts for ~69.6%.
Suggested Direction
- Replace the read path lock with
RWMutex.RLock, or use atomic/copy-on-write configuration for mo_ctl span state. - Keep
SetMoCtledSpanStatewrite-side semantics safe. - Validate with mutex profile before/after under point_select clean auto 1000vu.
Acceptance
IsMOCtledSpanno longer dominates mutex delay in1000vu_clean_auto.- No data race in trace control configuration.
- TPS/latency do not regress.
Related profiling task: #25472.
Activity
VioletQwQ-0 commentedon Jul 8, 2026
Closing this as covered by the ongoing broader trace removal work. The profile evidence is still valid and useful as context: under point_select clean auto 1000vu,
IsMOCtledSpanaccounted for ~338.65h / 69.63% of aggregate mutex delay. However, since the trace path itself is being removed, we do not need a separate targeted fix for this mutex.