-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
168 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
/// DISCLAIMER | ||
/// | ||
/// Copyright 2014-2024 ArangoDB GmbH, Cologne, Germany | ||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany | ||
/// | ||
/// Licensed under the Business Source License 1.1 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// https://github.com/arangodb/arangodb/blob/devel/LICENSE | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
/// | ||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "ThreadPoolScheduler.h" | ||
|
||
using namespace arangodb; | ||
|
||
void ThreadPoolScheduler::toVelocyPack(velocypack::Builder& builder) const {} | ||
Scheduler::QueueStatistics ThreadPoolScheduler::queueStatistics() const { | ||
return QueueStatistics(); | ||
} | ||
void ThreadPoolScheduler::trackCreateHandlerTask() noexcept {} | ||
void ThreadPoolScheduler::trackBeginOngoingLowPriorityTask() noexcept {} | ||
void ThreadPoolScheduler::trackEndOngoingLowPriorityTask() noexcept {} | ||
void ThreadPoolScheduler::trackQueueTimeViolation() {} | ||
void ThreadPoolScheduler::trackQueueItemSize(std::int64_t int64) noexcept {} | ||
|
||
uint64_t ThreadPoolScheduler::getLastLowPriorityDequeueTime() const noexcept { | ||
return 0; | ||
} | ||
|
||
void ThreadPoolScheduler::setLastLowPriorityDequeueTime( | ||
uint64_t time) noexcept {} | ||
|
||
std::pair<uint64_t, uint64_t> | ||
ThreadPoolScheduler::getNumberLowPrioOngoingAndQueued() const { | ||
return std::pair<uint64_t, uint64_t>(); | ||
} | ||
|
||
double ThreadPoolScheduler::approximateQueueFillGrade() const { return 0; } | ||
|
||
double ThreadPoolScheduler::unavailabilityQueueFillGrade() const { return 0; } | ||
|
||
bool ThreadPoolScheduler::queueItem(RequestLane lane, | ||
std::unique_ptr<WorkItemBase> item, | ||
bool bounded) { | ||
auto prio = PriorityRequestLane(lane); | ||
_threadPools[int(prio)]->push(std::move(item)); | ||
return true; | ||
} | ||
|
||
ThreadPoolScheduler::ThreadPoolScheduler(ArangodServer& server, | ||
uint64_t maxThreads) | ||
: Scheduler(server) { | ||
_threadPools.reserve(4); | ||
_threadPools.emplace_back( | ||
std::make_unique<ThreadPool>(std::min(std::ceil(maxThreads * 0.1), 2.))); | ||
_threadPools.emplace_back( | ||
std::make_unique<ThreadPool>(std::min(std::ceil(maxThreads * 0.6), 8.))); | ||
_threadPools.emplace_back( | ||
std::make_unique<ThreadPool>(std::min(std::ceil(maxThreads * 0.4), 4.))); | ||
_threadPools.emplace_back( | ||
std::make_unique<ThreadPool>(std::min(std::ceil(maxThreads * 0.4), 4.))); | ||
} | ||
|
||
void ThreadPoolScheduler::shutdown() { | ||
_stopping = true; | ||
Scheduler::shutdown(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
/// DISCLAIMER | ||
/// | ||
/// Copyright 2014-2024 ArangoDB GmbH, Cologne, Germany | ||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany | ||
/// | ||
/// Licensed under the Business Source License 1.1 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// https://github.com/arangodb/arangodb/blob/devel/LICENSE | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
/// | ||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "Scheduler.h" | ||
#include "SimpleThreadPool.h" | ||
|
||
namespace arangodb { | ||
|
||
struct ThreadPoolScheduler final : Scheduler { | ||
explicit ThreadPoolScheduler(ArangodServer& server, uint64_t maxThreads); | ||
void toVelocyPack(velocypack::Builder& builder) const override; | ||
QueueStatistics queueStatistics() const override; | ||
void trackCreateHandlerTask() noexcept override; | ||
void trackBeginOngoingLowPriorityTask() noexcept override; | ||
void trackEndOngoingLowPriorityTask() noexcept override; | ||
void trackQueueTimeViolation() override; | ||
void trackQueueItemSize(std::int64_t int64) noexcept override; | ||
uint64_t getLastLowPriorityDequeueTime() const noexcept override; | ||
void setLastLowPriorityDequeueTime(uint64_t time) noexcept override; | ||
std::pair<uint64_t, uint64_t> getNumberLowPrioOngoingAndQueued() | ||
const override; | ||
double approximateQueueFillGrade() const override; | ||
double unavailabilityQueueFillGrade() const override; | ||
|
||
void shutdown() override; | ||
|
||
protected: | ||
bool queueItem(RequestLane lane, std::unique_ptr<WorkItemBase> item, | ||
bool bounded) override; | ||
bool isStopping() override { return _stopping; } | ||
|
||
private: | ||
std::atomic<bool> _stopping; | ||
std::vector<std::unique_ptr<ThreadPool>> _threadPools; | ||
}; | ||
|
||
} // namespace arangodb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters