You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
MCOL-513 use thread pool for jobsteps
This commit is contained in:
@ -182,6 +182,7 @@ TupleAggregateStep::TupleAggregateStep(
|
||||
fAggregator(agg),
|
||||
fRowGroupOut(rgOut),
|
||||
fRowGroupIn(rgIn),
|
||||
fRunner(0),
|
||||
fUmOnly(false),
|
||||
fRm(jobInfo.rm),
|
||||
fBucketNum(0),
|
||||
@ -252,7 +253,7 @@ void TupleAggregateStep::run()
|
||||
{
|
||||
if (fDelivery == false)
|
||||
{
|
||||
fRunner.reset(new thread(Aggregator(this)));
|
||||
fRunner = jobstepThreadPool.invoke(Aggregator(this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +261,7 @@ void TupleAggregateStep::run()
|
||||
void TupleAggregateStep::join()
|
||||
{
|
||||
if (fRunner)
|
||||
fRunner->join();
|
||||
jobstepThreadPool.join(fRunner);
|
||||
}
|
||||
|
||||
|
||||
@ -4210,8 +4211,7 @@ void TupleAggregateStep::threadedAggregateRowGroups(uint32_t threadID)
|
||||
// maximum number is reached.
|
||||
if (threadID == 0 && fFirstPhaseThreadCount < fNumOfThreads &&
|
||||
dlIn->more(fInputIter)) {
|
||||
fFirstPhaseRunners[fFirstPhaseThreadCount].reset
|
||||
(new boost::thread(ThreadedAggregator(this, fFirstPhaseThreadCount)));
|
||||
fFirstPhaseRunners.push_back(jobstepThreadPool.invoke(ThreadedAggregator(this, fFirstPhaseThreadCount)));
|
||||
fFirstPhaseThreadCount++;
|
||||
}
|
||||
|
||||
@ -4482,24 +4482,21 @@ uint64_t TupleAggregateStep::doThreadedAggregate(ByteStream& bs, RowGroupDL* dlp
|
||||
fFirstPhaseThreadCount = fNumOfThreads;
|
||||
boost::shared_ptr<boost::thread> runner;
|
||||
for (i = 0; i < fNumOfThreads; i++)
|
||||
{
|
||||
runner.reset(new boost::thread(ThreadedAggregator(this, i)));
|
||||
fFirstPhaseRunners.push_back(runner);
|
||||
{
|
||||
fFirstPhaseRunners.push_back(jobstepThreadPool.invoke(ThreadedAggregator(this, i)))
|
||||
}
|
||||
*/
|
||||
|
||||
// This block of code starts one thread, relies on doThreadedAggregation()
|
||||
// to start more as needed
|
||||
fFirstPhaseRunners.resize(fNumOfThreads); // to prevent a resize during use
|
||||
fFirstPhaseRunners.clear();
|
||||
fFirstPhaseRunners.reserve(fNumOfThreads); // to prevent a resize during use
|
||||
fFirstPhaseThreadCount = 1;
|
||||
for (i = 1; i < fNumOfThreads; i++)
|
||||
// fill with valid thread objects to make joining work
|
||||
fFirstPhaseRunners[i].reset(new boost::thread());
|
||||
fFirstPhaseRunners[0].reset(new boost::thread(ThreadedAggregator(this, 0)));
|
||||
fFirstPhaseRunners.push_back(jobstepThreadPool.invoke(ThreadedAggregator(this, 0)));
|
||||
|
||||
for (i = 0; i < fNumOfThreads; i++)
|
||||
fFirstPhaseRunners[i]->join();
|
||||
fFirstPhaseRunners.clear();
|
||||
// Now wait for that thread plus all the threads it may have spawned
|
||||
jobstepThreadPool.join(fFirstPhaseRunners);
|
||||
fFirstPhaseRunners.clear();
|
||||
}
|
||||
|
||||
if (dynamic_cast<RowAggregationDistinct*>(fAggregator.get()) && fAggregator->aggMapKeyLength() > 0)
|
||||
@ -4509,8 +4506,7 @@ uint64_t TupleAggregateStep::doThreadedAggregate(ByteStream& bs, RowGroupDL* dlp
|
||||
{
|
||||
if (!fDoneAggregate)
|
||||
{
|
||||
vector<boost::shared_ptr<thread> > runners;
|
||||
boost::shared_ptr<thread> runner;
|
||||
vector<uint64_t> runners; // thread pool handles
|
||||
fRowGroupsDeliveredData.resize(fNumOfBuckets);
|
||||
|
||||
uint32_t bucketsPerThread = fNumOfBuckets/fNumOfThreads;
|
||||
@ -4519,13 +4515,12 @@ uint64_t TupleAggregateStep::doThreadedAggregate(ByteStream& bs, RowGroupDL* dlp
|
||||
//uint32_t bucketsPerThread = 1;
|
||||
//uint32_t numThreads = fNumOfBuckets;
|
||||
|
||||
runners.reserve(numThreads);
|
||||
for (i = 0; i < numThreads; i++)
|
||||
{
|
||||
runner.reset(new boost::thread(ThreadedSecondPhaseAggregator(this, i*bucketsPerThread, bucketsPerThread)));
|
||||
runners.push_back(runner);
|
||||
runners.push_back(jobstepThreadPool.invoke(ThreadedSecondPhaseAggregator(this, i*bucketsPerThread, bucketsPerThread)));
|
||||
}
|
||||
for (i = 0; i < numThreads; i++)
|
||||
runners[i]->join();
|
||||
jobstepThreadPool.join(runners);
|
||||
}
|
||||
|
||||
fDoneAggregate = true;
|
||||
|
Reference in New Issue
Block a user