Introduce per-table cache of ColumnsDescription for parts to reduce memory usage#89352
Introduce per-table cache of ColumnsDescription for parts to reduce memory usage#89352azat merged 2 commits intoClickHouse:masterfrom
Conversation
|
Workflow [PR], commit [e8f5478] Summary: ❌
|
20f1eee to
e83e721
Compare
…emory usage I've seen a setup where 7GiB (and this is jemalloc statistics w/o memory fragmentation) out of 90 was used by the ColumnsDescription, and it is only for 20K parts (but there are 6.5e6 parts columns). Also I've seen that with stopped merges, due to metric_log, the server may consume ~512MiB for a couple of hours with doing almost nothing.
5ee386b to
a3473b8
Compare
|
I didn't read this PR in detail but based on the PR description, average readers won't understand how caching helps to reduce memory consumption. Are you saying that, previously the same ColumnDescription existed multiple times in memory, and now it exists once (in the cache) and we are somehow referencing it? |
Yes
I've updated the description to make it cleaner. |
|
I've rolled out to ci-logs, and the memory consumption reduced (though there is still more), and it is stable. UPD: |
It is actually correct, we should not have it too big, more or less the same size as number of tables, and it indeed looks similar |
b1234a4
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Introduce a per-table cache of
ColumnsDescriptionfor parts, reducing memory usage when tables contain many parts and many columns.Details
Each
partcurrently stores its ownColumnsDescription(information about all columns). This includes not only full column metadata (including comments), but alsoIHints, which are used for correcting user input and are not trivial to decouple.When a table has many columns, this structure becomes large, and storing a full copy for every part leads to significant memory consumption.
In one production setup, 12 GiB out of 73 GiB of memory was occupied by
ColumnsDescriptionobjects for 20 K parts with 6.5 M part columns.As another example, even on an empty server with merges stopped,
metric_logalone could cause the server to consume roughly 512 MiB over a few hours while doing almost nothing.