aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/shared_threading_service.cpp
blob: f9333aa18a5805d1cab2df85cfad15d05dcfd6b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "shared_threading_service.h"
#include <vespa/vespalib/util/blockingthreadstackexecutor.h>
#include <vespa/vespalib/util/isequencedtaskexecutor.h>
#include <vespa/vespalib/util/sequencedtaskexecutor.h>
#include <vespa/vespalib/util/size_literals.h>

VESPA_THREAD_STACK_TAG(proton_field_writer_executor)
VESPA_THREAD_STACK_TAG(proton_shared_executor)
VESPA_THREAD_STACK_TAG(proton_warmup_executor)

namespace proton {

using SharedFieldWriterExecutor = ThreadingServiceConfig::ProtonConfig::Feeding::SharedFieldWriterExecutor;

SharedThreadingService::SharedThreadingService(const SharedThreadingServiceConfig& cfg)
    : _warmup(cfg.warmup_threads(), 128_Ki, proton_warmup_executor),
      _shared(std::make_shared<vespalib::BlockingThreadStackExecutor>(cfg.shared_threads(), 128_Ki,
                                                                      cfg.shared_task_limit(), proton_shared_executor)),
      _field_writer()
{
    const auto& fw_cfg = cfg.field_writer_config();
    if (fw_cfg.shared_field_writer() == SharedFieldWriterExecutor::DOCUMENT_DB) {
        _field_writer = vespalib::SequencedTaskExecutor::create(proton_field_writer_executor,
                                                                fw_cfg.indexingThreads() * 3,
                                                                fw_cfg.defaultTaskLimit(),
                                                                fw_cfg.optimize(),
                                                                fw_cfg.kindOfwatermark(),
                                                                fw_cfg.reactionTime());
    }
}

}