-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Compaction] Use separate thread pool for base and cumulative compaction #5618
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,8 +239,10 @@ class StorageEngine { | |
| void _compaction_tasks_producer_callback(); | ||
| vector<TabletSharedPtr> _compaction_tasks_generator(CompactionType compaction_type, | ||
| std::vector<DataDir*> data_dirs); | ||
| void _push_tablet_into_submitted_compaction(TabletSharedPtr tablet); | ||
| void _pop_tablet_from_submitted_compaction(TabletSharedPtr tablet); | ||
| void _push_tablet_into_submitted_base_compaction(TabletSharedPtr tablet); | ||
| void _pop_tablet_from_submitted_base_compaction(TabletSharedPtr tablet); | ||
| void _push_tablet_into_submitted_cumulative_compaction(TabletSharedPtr tablet); | ||
| void _pop_tablet_from_submitted_cumulative_compaction(TabletSharedPtr tablet); | ||
|
|
||
| private: | ||
| struct CompactionCandidate { | ||
|
|
@@ -334,12 +336,15 @@ class StorageEngine { | |
|
|
||
| HeartbeatFlags* _heartbeat_flags; | ||
|
|
||
| std::unique_ptr<ThreadPool> _compaction_thread_pool; | ||
| std::unique_ptr<ThreadPool> _base_compaction_thread_pool; | ||
| std::unique_ptr<ThreadPool> _cumulative_compaction_thread_pool; | ||
|
|
||
| CompactionPermitLimiter _permit_limiter; | ||
|
|
||
| std::mutex _tablet_submitted_compaction_mutex; | ||
| std::map<DataDir*, vector<TTabletId>> _tablet_submitted_compaction; | ||
| RWMutex _tablet_submitted_base_compaction_mutex; | ||
| std::map<DataDir*, std::set<TTabletId>> _tablet_submitted_base_compaction; | ||
| RWMutex _tablet_submitted_cumulative_compaction_mutex; | ||
| std::map<DataDir*, std::set<TTabletId>> _tablet_submitted_cumulative_compaction; | ||
|
Comment on lines
+339
to
+347
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about use a two elements array, one for base compaction, the other for cumulative compaction, to simplify code?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
OK, Thank you. |
||
|
|
||
| AtomicInt32 _wakeup_producer_flag; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -681,7 +681,8 @@ void TabletManager::get_tablet_stat(TTabletStatResult* result) { | |
|
|
||
| TabletSharedPtr TabletManager::find_best_tablet_to_compaction( | ||
| CompactionType compaction_type, DataDir* data_dir, | ||
| std::vector<TTabletId>& tablet_submitted_compaction) { | ||
| std::set<TTabletId>* tablet_submitted_base_compaction, | ||
| std::set<TTabletId>* tablet_submitted_cumulative_compaction) { | ||
| int64_t now_ms = UnixMillis(); | ||
| const string& compaction_type_str = | ||
| compaction_type == CompactionType::BASE_COMPACTION ? "base" : "cumulative"; | ||
|
|
@@ -693,12 +694,16 @@ TabletSharedPtr TabletManager::find_best_tablet_to_compaction( | |
| ReadLock rlock(tablets_shard.lock.get()); | ||
| for (const auto& tablet_map : tablets_shard.tablet_map) { | ||
| for (const TabletSharedPtr& tablet_ptr : tablet_map.second.table_arr) { | ||
| std::vector<TTabletId>::iterator it_tablet = | ||
| find(tablet_submitted_compaction.begin(), tablet_submitted_compaction.end(), | ||
| tablet_ptr->tablet_id()); | ||
| if (it_tablet != tablet_submitted_compaction.end()) { | ||
| std::set<TTabletId>::iterator it_tablet = | ||
| (*tablet_submitted_base_compaction).find(tablet_ptr->tablet_id()); | ||
| if (it_tablet != (*tablet_submitted_base_compaction).end()) { | ||
| continue; | ||
| } | ||
| it_tablet = (*tablet_submitted_cumulative_compaction).find(tablet_ptr->tablet_id()); | ||
| if (it_tablet != (*tablet_submitted_cumulative_compaction).end()) { | ||
| continue; | ||
| } | ||
|
|
||
|
Comment on lines
+697
to
+706
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We need to judge whether an element exists in |
||
| AlterTabletTaskSharedPtr cur_alter_task = tablet_ptr->alter_task(); | ||
| if (cur_alter_task != nullptr && cur_alter_task->alter_state() != ALTER_FINISHED && | ||
| cur_alter_task->alter_state() != ALTER_FAILED) { | ||
|
|
||
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.
They are not mutable, use CONF_Int32 instead.
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.
OK, thanks.