Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCompaction memory requirements are too high #4110
Comments
brian-brazil
added
the
component/local storage
label
Apr 24, 2018
This comment has been minimized.
This comment has been minimized.
|
Some additional information on an existing TSDB compaction. This is for a level 5 compaction, 6.75 days. (
The churn on this server is somewhat low, but it has a large ingestion rate and a lot of metrics. This compaction has a 3.6GB index and 62GB of chunks. |
This comment has been minimized.
This comment has been minimized.
|
Did you ever get the heap profiles when the compaction was happening? |
This comment has been minimized.
This comment has been minimized.
|
No, I haven't gotten to that yet, thanks for the reminder. |
brian-brazil
added
the
kind/more-info-needed
label
Jun 13, 2018
brian-brazil
changed the title
tsdb max block duration is too large
Compaction memory requirements are too high
Jun 13, 2018
brian-brazil
added
the
kind/bug
label
Jun 13, 2018
brian-brazil
referenced this issue
Jun 14, 2018
Closed
2.3.0 significatnt memory usage increase. #4254
This comment has been minimized.
This comment has been minimized.
|
In addition, could I get all the go memory metrics during the compaction spike? |
This comment has been minimized.
This comment has been minimized.
|
Does an msync actually reclaim space allocated to dirty pages? Could periodic msyncs reduce the usage? (tested it, it doesn't seem to, RSS drops once you unmap) On a more practical note, can storage.tsdb.max-block-duration be set on a pre-existing prom instance? It seems like reducing the block size could reduce the memory used here? |
ntindall
referenced this issue
Jul 1, 2018
Closed
[Intermittent] compaction failed after upgrade from 2.2.1 to 2.3.0 #4292
SuperQ
referenced this issue
Oct 19, 2018
Closed
TSDB Compaction failures bring to OOM shutdown #4757
This comment has been minimized.
This comment has been minimized.
|
Maybe some streaming during compaction could solve this. Instead of expanding all blocks at once do it in stages or something. |
This comment has been minimized.
This comment has been minimized.
|
With the PRs I've sent out, it's already as efficient as it's going to get. It seems that @SuperQ's issue was likely cardinality, which my PRs should address. |
This comment has been minimized.
This comment has been minimized.
|
@krasi-georgiev The issues we saw were with the default 10% max block size when compacting long retention times (365d). We tun our max block size to 7d, which helps. Once we have Brian's memory use optimizations in a release, I can do some re-testing. |
This comment has been minimized.
This comment has been minimized.
spjspjspj
commented
Dec 5, 2018
•
|
Why would entire block need to be loaded into memory? We observe high memory use (130GB) too upon (probably unclean) restart. Edit: this is actually unrelated to this issue. What we experienced I believe is actually #4842 On our dashboard, compaction seemingly happens once every hour and doesn't take much time or memory: retention 180d |
bandesz
pushed a commit
to alphagov/paas-cf
that referenced
this issue
Dec 10, 2018
bandesz
referenced this issue
Dec 10, 2018
Merged
[#162540011] Set Prometheus data retention to 450 days #1673
alext
added a commit
to alphagov/paas-cf
that referenced
this issue
Dec 11, 2018
This comment has been minimized.
This comment has been minimized.
|
Here's a comparison of 2.5.0 to 2.6.0: Looking at the data, it seems we still see about a 20-25% spike in RSS size when two compactions are run closely together. Oddly, the Perhaps we need to add some sleep time to the scheduling of compactions to avoid this? |
This comment has been minimized.
This comment has been minimized.
|
So, after some discussion with @brian-brazil, I think this is solved. Figuring out the RSS issue when compactions run is a separate problem. |



SuperQ commentedApr 24, 2018
Proposal
Reduce the default of the
--storage.tsdb.max-block-durationfrom 10% to 2% or 1%.Bug Report
When using a longer retention time on a high traffic Prometheus server, the 10% compaction level causes a number of users to get into crash loops. This seems to be due to the amount of memory used during the compaction.
For example, a server with a 365d retention time. This server is normally operating at ~20G RSS and needs an additional 6G of memory to perform a 2% compaction of ~60G of TSDB. If this were a full 10% compaction, it could need far more memory for this compaction, causing it to OOM.
There's also no need to generate such large blocks, with a 2% max block duration ratio, we would have under 60 TSDB blocks over a year.