You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-5044 This patch replaces PriorityThreadPool with FairThreadPool that uses a simple
operations + morsel size weight model to equally allocate CPU b/w parallel query morsels. This patch delivers better parallel query timings distribution(timings graph resembles normal distribution with a bigger left side thus more queries runs faster comparing with PrioThreadPool-based single-node installation). See changes in batchprimitiveprocessor-jl.h and comments in fair_threadpool.h for important implementation details
This commit is contained in:
committed by
Roman Nozdrin
parent
0f0b3a2bed
commit
fd8ba33f21
@ -39,6 +39,12 @@
|
||||
|
||||
namespace threadpool
|
||||
{
|
||||
// The idea of this thread pool is to run morsel jobs(primitive job) is to equaly distribute CPU time
|
||||
// b/w multiple parallel queries(thread maps morsel to query using txnId). Query(txnId) has its weight
|
||||
// stored in PriorityQueue that thread increases before run another morsel for the query. When query is
|
||||
// done(ThreadPoolJobsList is empty) it is removed from PQ and the Map(txn to ThreadPoolJobsList).
|
||||
// I tested multiple morsels per one loop iteration in ::threadFcn. This approach reduces CPU consumption
|
||||
// and increases query timings.
|
||||
class FairThreadPool
|
||||
{
|
||||
public:
|
||||
@ -92,23 +98,6 @@ class FairThreadPool
|
||||
*/
|
||||
void dump();
|
||||
|
||||
// If a job is blocked, we want to temporarily increase the number of threads managed by the pool
|
||||
// A problem can occur if all threads are running long or blocked for a single query. Other
|
||||
// queries won't get serviced, even though there are cpu cycles available.
|
||||
// These calls are currently protected by respondLock in sendThread(). If you call from other
|
||||
// places, you need to consider atomicity.
|
||||
void incBlockedThreads()
|
||||
{
|
||||
blockedThreads++;
|
||||
}
|
||||
void decBlockedThreads()
|
||||
{
|
||||
blockedThreads--;
|
||||
}
|
||||
uint32_t blockedThreadCount() const
|
||||
{
|
||||
return blockedThreads;
|
||||
}
|
||||
size_t queueSize() const
|
||||
{
|
||||
return weightedTxnsQueue_.size();
|
||||
@ -165,9 +154,6 @@ class FairThreadPool
|
||||
using Txn2ThreadPoolJobsListMap = std::unordered_map<TransactionIdxT, ThreadPoolJobsList*>;
|
||||
Txn2ThreadPoolJobsListMap txn2JobsListMap_;
|
||||
WeightedTxnPrioQueue weightedTxnsQueue_;
|
||||
std::atomic<uint32_t> blockedThreads;
|
||||
std::atomic<uint32_t> extraThreads;
|
||||
bool stopExtra;
|
||||
};
|
||||
|
||||
} // namespace threadpool
|
Reference in New Issue
Block a user