-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Early release stale rowsets after compaction. #5056
[Enhancement] Early release stale rowsets after compaction. #5056
Conversation
Experimental setupTable contains 10800 columns, and divided into 100 bucket. Memory Before optimizationThe peak of rss is about 81.7G, the peak of tablet meta memory is 34.6G, the peak of column_reader_index_mem is 17.8G, and the peak of column_reader_meta_mem is 16.8G. Memory after sharing data field between ColumnReader optimiztion #4875Rss peaks at about 74.2G, tablet meta memory peaks at 27.3G, column_reader_index_mem peaks at 15.3G, and column_reader_meta_mem peaks at 11.9G, the memory of column_reader_meta_mem significantly lower than before. Memory after early releasing stale rowsets #5056Rss peaks at about 40G, tablet meta memory peaks at 4.5G, the memory footprint of the tablet meta data is significantly reduced |
be/src/storage/compaction.cpp
Outdated
@@ -245,6 +245,10 @@ Status Compaction::_merge_rowsets_vertically(size_t segment_iterator_num, Statis | |||
TRACE_COUNTER_SCOPE_LATENCY_US("merge_rowsets_latency_us"); | |||
auto mask_buffer = std::make_unique<RowSourceMaskBuffer>(_tablet->tablet_id(), _tablet->data_dir()->path()); | |||
auto source_masks = std::make_unique<std::vector<RowSourceMask>>(); | |||
// ensure all input rowsets are loaded into memory | |||
for (auto& rowset : _input_rowsets) { | |||
RETURN_IF_ERROR(rowset->load()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can this operation assure that rowset won't be released?
I think other thread can release these rowsets after loading()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only stale rowsets can be released and rowsets can only transfer from not-stale to stale. Now the compaction has not begun, the input rowsets are all not-stale. So i think no other threads can release these rowsets?
If the code is written correctly, rowset should be loaded into memory here. Just in case, I've added three lines safeguards here, because the segments of rowsets will be used directly later.
a38f858
to
2ba39e8
Compare
@Mergifyio rebase |
❌ Base branch update has failedGit reported the following error:
err-code: 5F68D |
After compaction, the stale rowsets will still stay in memory for a long time before gc thread free them. And these stale rowsets take up a lot of memory. In fact, there may be a few old readers still read the stale rowsets, all new readers will read the new rowset generated by the compaction, so we can free the stale rowsets if there are no readers on it. Experiments show that this optimization significantly reduces the memory footprint of rowsets meta data.
1e59c3e
to
4e3060c
Compare
@Mergifyio rebase |
❌ Base branch update has failedGit reported the following error:
err-code: D7F44 |
be/src/storage/tablet.cpp
Outdated
@@ -276,6 +276,7 @@ void Tablet::modify_rowsets(const std::vector<RowsetSharedPtr>& to_add, const st | |||
|
|||
// add rs_metas_to_delete to tracker | |||
_timestamped_version_tracker.add_stale_path_version(rs_metas_to_delete); | |||
Rowset::close_rowsets(to_delete); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I don't think this is a good place to close_rowsets.
I think caller should do this things.
This function just do meta modification. It don't know if the rowsets will be closed.
I think the compaction manager will decide if these rowsets should be closed not this function.
Signed-off-by: xyz <a997647204@gmail.com>
@@ -59,6 +59,11 @@ Status VerticalCompactionTask::_vertical_compaction_data(Statistics* statistics) | |||
"size:$1", | |||
max_rows_per_segment, column_groups.size()); | |||
|
|||
// ensure all input rowsets are loaded into memory | |||
for (auto& rowset : _input_rowsets) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When these _input_rowsets is acquired and when is these rowsets is released?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I move these lines in tablet reader prepare() function. I will first acquire these rowsets and then loads them to ensure there input rowsets are not freed.
Also i move the tablet reader prepare()
function before the direct use of rowset's segment()
function. Thus these segments are always loaded into the memory.
Signed-off-by: xyz <a997647204@gmail.com>
Signed-off-by: xyz <a997647204@gmail.com>
run starrocks_clang-format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…s#5056) * [optimize] Early release stale rowsets after compaction. After compaction, the stale rowsets will still stay in memory for a long time before gc thread free them. And these stale rowsets take up a lot of memory. In fact, there may be a few old readers still read the stale rowsets, all new readers will read the new rowset generated by the compaction, so we can free the stale rowsets if there are no readers on it. Experiments show that this optimization significantly reduces the memory footprint of rowsets meta data.
…s#5056) * [optimize] Early release stale rowsets after compaction. After compaction, the stale rowsets will still stay in memory for a long time before gc thread free them. And these stale rowsets take up a lot of memory. In fact, there may be a few old readers still read the stale rowsets, all new readers will read the new rowset generated by the compaction, so we can free the stale rowsets if there are no readers on it. Experiments show that this optimization significantly reduces the memory footprint of rowsets meta data.
…s#5056) * [optimize] Early release stale rowsets after compaction. After compaction, the stale rowsets will still stay in memory for a long time before gc thread free them. And these stale rowsets take up a lot of memory. In fact, there may be a few old readers still read the stale rowsets, all new readers will read the new rowset generated by the compaction, so we can free the stale rowsets if there are no readers on it. Experiments show that this optimization significantly reduces the memory footprint of rowsets meta data.
…s#5056) * [optimize] Early release stale rowsets after compaction. After compaction, the stale rowsets will still stay in memory for a long time before gc thread free them. And these stale rowsets take up a lot of memory. In fact, there may be a few old readers still read the stale rowsets, all new readers will read the new rowset generated by the compaction, so we can free the stale rowsets if there are no readers on it. Experiments show that this optimization significantly reduces the memory footprint of rowsets meta data.
* [optimize] Early release stale rowsets after compaction. After compaction, the stale rowsets will still stay in memory for a long time before gc thread free them. And these stale rowsets take up a lot of memory. In fact, there may be a few old readers still read the stale rowsets, all new readers will read the new rowset generated by the compaction, so we can free the stale rowsets if there are no readers on it. Experiments show that this optimization significantly reduces the memory footprint of rowsets meta data.
* [optimize] Early release stale rowsets after compaction. After compaction, the stale rowsets will still stay in memory for a long time before gc thread free them. And these stale rowsets take up a lot of memory. In fact, there may be a few old readers still read the stale rowsets, all new readers will read the new rowset generated by the compaction, so we can free the stale rowsets if there are no readers on it. Experiments show that this optimization significantly reduces the memory footprint of rowsets meta data.
(cherry picked from commit 1f27dbb) Co-authored-by: evelyn.zhaojie <everlyn.zhaojie@gmail.com>
After compaction, the stale rowsets will still stay in memory for a long time before gc thread free them. And these stale rowsets take up a lot of memory. In fact, there may be a few old readers still read the stale rowsets, all new readers will read the new rowset generated by the compaction, so we can free the stale rowsets if there are no readers on it. Experiments show that this optimization significantly reduces the memory footprint of rowsets metadata.
Signed-off-by: xyz a997647204@gmail.com
What type of PR is this:
Which issues of this PR fixes :
Fixes #4873
Problem Summary(Required) :
After compaction, the stale rowsets will still stay in memory for a long time before gc thread free them. And these stale rowsets take up a lot of memory. In fact, there may be a few old readers still reading the stale rowsets, all new readers will read the new rowset generated by the compaction, so we can free the stale rowsets if there are no readers on it. Experiments show that this optimization significantly reduces the memory footprint of rowsets metadata.