diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-04-05 19:27:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 19:27:10 +0200 |
commit | a4132d1d8bc228bad9de8e986a777fa1e9e6939d (patch) | |
tree | 28d19408c5a2f2a3ce976d55ac4de5e33580a6d3 /staging_vespalib | |
parent | 14443fdcab31276ae11684981bf4bb055e3bffdc (diff) | |
parent | da7e22058e25ff752090981209203b281633e5f8 (diff) |
Merge branch 'master' into balder/move-sequenced-task-executors-to-staging_vespalib
Diffstat (limited to 'staging_vespalib')
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/util/singleexecutor.cpp | 13 | ||||
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/util/singleexecutor.h | 3 |
2 files changed, 3 insertions, 13 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/singleexecutor.cpp b/staging_vespalib/src/vespa/vespalib/util/singleexecutor.cpp index 6492c301fe5..90eb18c23ef 100644 --- a/staging_vespalib/src/vespa/vespalib/util/singleexecutor.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/singleexecutor.cpp @@ -6,10 +6,6 @@ namespace vespalib { SingleExecutor::SingleExecutor(uint32_t taskLimit) - : SingleExecutor(taskLimit, taskLimit/10, 5ms) -{ } - -SingleExecutor::SingleExecutor(uint32_t taskLimit, uint32_t watermark, duration napTime) : _taskLimit(vespalib::roundUp2inN(taskLimit)), _wantedTaskLimit(_taskLimit.load()), _rp(0), @@ -23,13 +19,10 @@ SingleExecutor::SingleExecutor(uint32_t taskLimit, uint32_t watermark, duration _wakeupConsumerAt(0), _producerNeedWakeupAt(0), _wp(0), - _watermark(watermark), - _napTime(napTime), _closed(false) { _thread.start(); } - SingleExecutor::~SingleExecutor() { shutdown(); sync(); @@ -109,10 +102,10 @@ SingleExecutor::run() { while (!_thread.stopped()) { drain_tasks(); _producerCondition.notify_all(); - _wakeupConsumerAt.store(_wp.load(std::memory_order_relaxed) + _watermark, std::memory_order_relaxed); + _wakeupConsumerAt.store(_wp.load(std::memory_order_relaxed) + (_taskLimit.load(std::memory_order_relaxed) / 4), std::memory_order_relaxed); Lock lock(_mutex); if (numTasks() <= 0) { - _consumerCondition.wait_for(lock, _napTime); + _consumerCondition.wait_for(lock, 10ms); } _wakeupConsumerAt.store(0, std::memory_order_relaxed); } @@ -151,7 +144,7 @@ SingleExecutor::wait_for_room(Lock & lock) { } _queueSize.add(numTasks()); while (numTasks() >= _taskLimit.load(std::memory_order_relaxed)) { - sleepProducer(lock, _napTime, wp - _watermark); + sleepProducer(lock, 10ms, wp - taskLimit/4); } } diff --git a/staging_vespalib/src/vespa/vespalib/util/singleexecutor.h b/staging_vespalib/src/vespa/vespalib/util/singleexecutor.h index cb78f8448f4..3d759769ea3 100644 --- a/staging_vespalib/src/vespa/vespalib/util/singleexecutor.h +++ b/staging_vespalib/src/vespa/vespalib/util/singleexecutor.h @@ -19,7 +19,6 @@ namespace vespalib { class SingleExecutor final : public vespalib::SyncableThreadExecutor, vespalib::Runnable { public: explicit SingleExecutor(uint32_t taskLimit); - SingleExecutor(uint32_t taskLimit, uint32_t watermark, duration napTime); ~SingleExecutor() override; Task::UP execute(Task::UP task) override; void setTaskLimit(uint32_t taskLimit) override; @@ -57,8 +56,6 @@ private: std::atomic<uint64_t> _wakeupConsumerAt; std::atomic<uint64_t> _producerNeedWakeupAt; std::atomic<uint64_t> _wp; - const uint32_t _watermark; - const duration _napTime; bool _closed; }; |