mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 21:12:28 +00:00
a34f42ca22
It looks redundant (added in 5ef51ed
), though it has "fix tests" in the
log message, but CI reports is not available for the commits from that
PR [1], so let's try.
[1]: https://github.com/ClickHouse/ClickHouse/pull/37543
Also this can be a big problem, since the code under that lock
(throttling or quotas with previous implementation that uses
boost::atomic_shared_ptr) may sleep.
Some numbers:
run | time
------------------------|------
max_threads=100 before | 23.1
max_threads=100 after | 15.1
max_threads=4500 before | 4.5
max_threads=4500 after | 2.3
Query:
select sum(number) from numbers_mt(2000000) settings max_threads=X, max_block_size = 1
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
#pragma once
|
|
#include <Common/Stopwatch.h>
|
|
#include <QueryPipeline/StreamLocalLimits.h>
|
|
#include <IO/Progress.h>
|
|
#include <mutex>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class QueryStatus;
|
|
using QueryStatusPtr = std::shared_ptr<QueryStatus>;
|
|
class EnabledQuota;
|
|
|
|
struct StorageLimits;
|
|
using StorageLimitsList = std::list<StorageLimits>;
|
|
|
|
|
|
class ReadProgressCallback
|
|
{
|
|
public:
|
|
void setQuota(const std::shared_ptr<const EnabledQuota> & quota_) { quota = quota_; }
|
|
void setProcessListElement(QueryStatusPtr elem);
|
|
void setProgressCallback(const ProgressCallback & callback) { progress_callback = callback; }
|
|
void addTotalRowsApprox(size_t value) { total_rows_approx += value; }
|
|
void addTotalBytes(size_t value) { total_bytes += value; }
|
|
|
|
/// Skip updating profile events.
|
|
/// For merges in mutations it may need special logic, it's done inside ProgressCallback.
|
|
void disableProfileEventUpdate() { update_profile_events = false; }
|
|
|
|
bool onProgress(uint64_t read_rows, uint64_t read_bytes, const StorageLimitsList & storage_limits);
|
|
|
|
private:
|
|
std::shared_ptr<const EnabledQuota> quota;
|
|
ProgressCallback progress_callback;
|
|
QueryStatusPtr process_list_elem;
|
|
|
|
/// The approximate total number of rows to read. For progress bar.
|
|
std::atomic_size_t total_rows_approx = 0;
|
|
/// The total number of bytes to read. For progress bar.
|
|
std::atomic_size_t total_bytes = 0;
|
|
|
|
Stopwatch total_stopwatch{CLOCK_MONOTONIC_COARSE}; /// Including waiting time
|
|
|
|
bool update_profile_events = true;
|
|
};
|
|
|
|
}
|