-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: minimize TableDescriptor copies/re-allocation/serialization #74352
Description
descpb.TableDescriptor structs are 1104 bytes large (ignoring internal references). tabledesc.immutable structs embed a descpb.TableDescriptor and are 1168 byte large. Due to this size, we should strive to minimize the number of times that we copy, re-allocate, or serialize these structs on the hot path of query processing.
@ajwerner, a man ahead of his time, has TODOs that allude to this:
cockroach/pkg/sql/colfetcher/colbatch_scan.go
Lines 203 to 207 in 3471dc5
| // TODO(ajwerner): The need to construct an immutable here | |
| // indicates that we're probably doing this wrong. Instead we should be | |
| // just setting the ID and Version in the spec or something like that and | |
| // retrieving the hydrated immutable from cache. | |
| table := spec.BuildTableDescriptor() |
In recent experimentation, I've observed these copies in CPU and heap profiles. On a 100% read workload, immutable allocations are not only the second largest source of heap allocations (by size), but they also appear prominently in CPU profiles. For instance, in kv100 (which is CPU-bound), TableReaderSpec.BuildTableDescriptor is responsible for 1.33% of all CPU utilization.
Jira issue: CRDB-12042
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
