Skip to content
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

add min tso scheduler for each resource group #8072

Merged
merged 27 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
25ef095
refine MinTSOScheduler for resource control
guo-shaoge Sep 8, 2023
53c15ed
Merge branch 'master' of github.com:pingcap/tiflash into resource_con…
guo-shaoge Sep 14, 2023
d7335e2
refine metric
guo-shaoge Sep 14, 2023
3b66abd
detail -> entry
guo-shaoge Sep 14, 2023
8da9c62
case; refine
guo-shaoge Sep 14, 2023
2a78ab9
rename tso metric name
guo-shaoge Sep 14, 2023
3dd452b
rename metric name
guo-shaoge Sep 14, 2023
e5cc3a5
fix case
guo-shaoge Sep 14, 2023
e77b04e
refine
guo-shaoge Sep 14, 2023
5aedfbd
refine
guo-shaoge Sep 14, 2023
c51248f
fix
guo-shaoge Sep 14, 2023
fea6f0a
fmt
guo-shaoge Sep 14, 2023
4c40a00
Merge branch 'master' into resource_control_part_4
guo-shaoge Sep 15, 2023
e6cf492
unit test for TokenBucket::compact()
guo-shaoge Sep 15, 2023
3de0125
Merge branch 'resource_control_part_4' of github.com:guo-shaoge/tifla…
guo-shaoge Sep 15, 2023
8a9313d
Merge branch 'master' into resource_control_part_4
guo-shaoge Sep 19, 2023
c7f0d53
refine compact()
guo-shaoge Sep 19, 2023
c159c8a
Merge branch 'resource_control_part_4' of github.com:guo-shaoge/tifla…
guo-shaoge Sep 19, 2023
26efb8b
Update dbms/src/Flash/Mpp/MinTSOScheduler.cpp
guo-shaoge Sep 19, 2023
5a7f854
Update dbms/src/Flash/Mpp/MinTSOScheduler.cpp
guo-shaoge Sep 19, 2023
acff759
RUNTIME_CHECK -> assert
guo-shaoge Sep 19, 2023
7d7e4e9
Merge branch 'resource_control_part_4' of github.com:guo-shaoge/tifla…
guo-shaoge Sep 20, 2023
c47e0a9
scheduler_entries -> group_entries; mustGetGroupEntry
guo-shaoge Sep 20, 2023
d4cd18b
add metric for group_entry count
guo-shaoge Sep 20, 2023
bae1018
refine metric
guo-shaoge Sep 20, 2023
59c0e70
fill_rate_ms
guo-shaoge Sep 20, 2023
eadc7c4
Merge branch 'master' into resource_control_part_4
ti-chi-bot[bot] Sep 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dbms/src/Common/TiFlashMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,12 @@ namespace DB
F(type_active_queries_count, {"type", "active_queries_count"}), \
F(type_waiting_tasks_count, {"type", "waiting_tasks_count"}), \
F(type_active_tasks_count, {"type", "active_tasks_count"}), \
F(type_global_estimated_thread_usage, {"type", "global_estimated_thread_usage"}), \
F(type_estimated_thread_usage, {"type", "estimated_thread_usage"}), \
F(type_thread_soft_limit, {"type", "thread_soft_limit"}), \
F(type_thread_hard_limit, {"type", "thread_hard_limit"}), \
F(type_hard_limit_exceeded_count, {"type", "hard_limit_exceeded_count"})) \
F(type_hard_limit_exceeded_count, {"type", "hard_limit_exceeded_count"}), \
F(type_group_entry_count, {"type", "group_entry_count"})) \
M(tiflash_task_scheduler_waiting_duration_seconds, \
"Bucketed histogram of task waiting for scheduling duration", \
Histogram, \
Expand Down Expand Up @@ -705,7 +707,7 @@ namespace DB
F(type_fsync, {{"type", "fsync"}}, ExpBuckets{0.0001, 2, 20})) \
M(tiflash_storage_delta_index_cache, "", Counter, F(type_hit, {"type", "hit"}), F(type_miss, {"type", "miss"})) \
M(tiflash_resource_group, \
"meta infos of resource groups", \
"meta info of resource group", \
Gauge, \
F(type_remaining_tokens, {"type", "remaining_tokens"}), \
F(type_avg_speed, {"type", "avg_speed"}), \
Expand Down
5 changes: 0 additions & 5 deletions dbms/src/Flash/Executor/PipelineExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ ExecutionResult PipelineExecutor::execute(ResultHandler && result_handler)
}
LOG_TRACE(log, "query finish with {}", exec_context.getQueryProfileInfo().toJson());

// For read_ru, only report it to GAC for now.
LocalAdmissionController::global_instance->consumeResource(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will consume read_ru in next pr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exec_context.getResourceGroupName(),
dagContext().getReadRU(),
0);
return exec_context.toExecutionResult();
}

Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Flash/Mpp/MPPTaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ bool MPPTaskManager::tryToScheduleTask(MPPTaskScheduleEntry & schedule_entry)
return scheduler->tryToSchedule(schedule_entry, *this);
}

void MPPTaskManager::releaseThreadsFromScheduler(const int needed_threads)
void MPPTaskManager::releaseThreadsFromScheduler(const String & resource_group_name, const int needed_threads)
{
std::lock_guard lock(mu);
scheduler->releaseThreadsThenSchedule(needed_threads, *this);
scheduler->releaseThreadsThenSchedule(resource_group_name, needed_threads, *this);
}
} // namespace DB
2 changes: 1 addition & 1 deletion dbms/src/Flash/Mpp/MPPTaskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class MPPTaskManager : private boost::noncopyable

bool tryToScheduleTask(MPPTaskScheduleEntry & schedule_entry);

void releaseThreadsFromScheduler(int needed_threads);
void releaseThreadsFromScheduler(const String & resource_group_name, int needed_threads);

std::pair<MPPTunnelPtr, String> findTunnelWithTimeout(
const ::mpp::EstablishMPPConnectionRequest * request,
Expand Down
5 changes: 3 additions & 2 deletions dbms/src/Flash/Mpp/MPPTaskScheduleEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ MPPTaskScheduleEntry::~MPPTaskScheduleEntry()
{
if (schedule_state == ScheduleState::SCHEDULED)
{
manager->releaseThreadsFromScheduler(needed_threads);
manager->releaseThreadsFromScheduler(getResourceGroupName(), needed_threads);
schedule_state = ScheduleState::COMPLETED;
}
}
Expand Down Expand Up @@ -63,7 +63,8 @@ void MPPTaskScheduleEntry::waitForSchedule()
std::unique_lock lock(schedule_mu);
schedule_cv.wait(lock, [&] { return schedule_state != ScheduleState::WAITING; });
time_cost = stopwatch.elapsedSeconds();
GET_METRIC(tiflash_task_scheduler_waiting_duration_seconds).Observe(time_cost);
GET_RESOURCE_GROUP_METRIC(tiflash_task_scheduler_waiting_duration_seconds, getResourceGroupName())
.Observe(time_cost);

if (schedule_state == ScheduleState::EXCEEDED)
{
Expand Down
2 changes: 2 additions & 0 deletions dbms/src/Flash/Mpp/MPPTaskScheduleEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class MPPTaskScheduleEntry

const MPPTaskId & getMPPTaskId() const;

const String & getResourceGroupName() const { return id.gather_id.query_id.resource_group_name; }

~MPPTaskScheduleEntry();

MPPTaskScheduleEntry(MPPTaskManager * manager_, const MPPTaskId & id_);
Expand Down
Loading