diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-04-04 23:08:03 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-04-04 23:08:03 +0000 |
commit | 14443fdcab31276ae11684981bf4bb055e3bffdc (patch) | |
tree | 0c95dfce00a12073fe39412bd6d5bc3c231f6056 /staging_vespalib | |
parent | 416ff1764ce98954b3b15fcae0f6a50d76b38323 (diff) |
Also allow for testing of the adaptive task executor.
Diffstat (limited to 'staging_vespalib')
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp b/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp index aa43bfaae7d..2688a35fc6c 100644 --- a/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "sequencedtaskexecutor.h" +#include "adaptive_sequenced_executor.h" #include "singleexecutor.h" #include <vespa/vespalib/util/blockingthreadstackexecutor.h> @@ -16,16 +17,20 @@ constexpr uint32_t stackSize = 128 * 1024; std::unique_ptr<ISequencedTaskExecutor> SequencedTaskExecutor::create(uint32_t threads, uint32_t taskLimit, OptimizeFor optimize) { - auto executors = std::make_unique<std::vector<std::unique_ptr<vespalib::SyncableThreadExecutor>>>(); - executors->reserve(threads); - for (uint32_t id = 0; id < threads; ++id) { - if (optimize == OptimizeFor::THROUGHPUT) { - executors->push_back(std::make_unique<SingleExecutor>(taskLimit)); - } else { - executors->push_back(std::make_unique<BlockingThreadStackExecutor>(1, stackSize, taskLimit)); + if (optimize == OptimizeFor::ADAPTIVE) { + return std::make_unique<AdaptiveSequencedExecutor>(threads, threads, taskLimit/100, taskLimit); + } else { + auto executors = std::make_unique<std::vector<std::unique_ptr<SyncableThreadExecutor>>>(); + executors->reserve(threads); + for (uint32_t id = 0; id < threads; ++id) { + if (optimize == OptimizeFor::THROUGHPUT) { + executors->push_back(std::make_unique<SingleExecutor>(taskLimit, taskLimit/100, 1ms)); + } else { + executors->push_back(std::make_unique<BlockingThreadStackExecutor>(1, stackSize, taskLimit)); + } } + return std::unique_ptr<ISequencedTaskExecutor>(new SequencedTaskExecutor(std::move(executors))); } - return std::unique_ptr<ISequencedTaskExecutor>(new SequencedTaskExecutor(std::move(executors))); } SequencedTaskExecutor::~SequencedTaskExecutor() |