-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: record CPU seconds per statement #87213
Description
Currently, it's not possible to understand what fraction of each query's latency was CPU time. This is frustrating for users, who want to be able to see CPU information alongside the other things that we do collect like disk bytes, network, memory. (See #60628 which I'm closing in favor of this now that we have some more details on how it'll work)
Now that @irfansharif's foundational work for #82625 has landed, it's possible to ask Go to return the number of CPU seconds that have been consumed by a goroutine, with this API:
cockroach/pkg/util/grunning/grunning.go
Lines 19 to 22 in da00c3a
| // Time returns the time spent by the current goroutine in the running state. | |
| func Time() time.Duration { | |
| return time.Duration(grunningnanos()) | |
| } |
Much of SQL uses just a single goroutine. This changes when we run a DistSQL query, or emit remote KV reads. I think we should start by recording CPU time on just the main SQL runner goroutine, and reporting that. Reporting CPU time spent across the cluster comes with some caveats, so we should think about it from a product perspective - how will we represent in the UI.
- Record CPU seconds per statement, similar to how we record end to end latency per statement
- Record CPU seconds, including remote KV reads
- Record CPU seconds, including DistSQL CPU
Jira issue: CRDB-19217
gz#21392
Metadata
Metadata
Assignees
Labels
Type
Projects
Status