aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/core/harmonizer.h
blob: ba98048e493e4c3a7b349c88ebe4558b5b157187 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once

#include "defs.h"
#include "config.h"

namespace NActors {
    class IExecutorPool;

    template <typename T>
    struct TWaitingStats;

    struct TPoolHarmonizerStats {
        ui64 IncreasingThreadsByNeedyState = 0;
        ui64 IncreasingThreadsByExchange = 0;
        ui64 DecreasingThreadsByStarvedState = 0;
        ui64 DecreasingThreadsByHoggishState = 0;
        ui64 DecreasingThreadsByExchange = 0;
        i64 MaxConsumedCpu = 0.0;
        i64 MinConsumedCpu = 0.0;
        i64 MaxBookedCpu = 0.0;
        i64 MinBookedCpu = 0.0;
        i16 PotentialMaxThreadCount = 0;
        bool IsNeedy = false;
        bool IsStarved = false;
        bool IsHoggish = false;
    };

    struct THarmonizerStats {
        i64 MaxConsumedCpu = 0.0;
        i64 MinConsumedCpu = 0.0;
        i64 MaxBookedCpu = 0.0;
        i64 MinBookedCpu = 0.0;

        double AvgAwakeningTimeUs = 0;
        double AvgWakingUpTimeUs = 0;
    };

    // Pool cpu harmonizer
    class IHarmonizer {
    public:
        virtual ~IHarmonizer() {}
        virtual void Harmonize(ui64 ts) = 0;
        virtual void DeclareEmergency(ui64 ts) = 0;
        virtual void AddPool(IExecutorPool* pool, TSelfPingInfo *pingInfo = nullptr) = 0;
        virtual void Enable(bool enable) = 0;
        virtual TPoolHarmonizerStats GetPoolStats(i16 poolId) const = 0;
        virtual THarmonizerStats GetStats() const = 0;
    };

    IHarmonizer* MakeHarmonizer(ui64 ts);
}