aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/coroutine/engine/stack/stack_common.h
blob: d2d473a4261792bd1576bed960e478d248ffbd15 (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
#pragma once

#include <cstddef>

class TContExecutor;

namespace NCoro::NStack {

    static constexpr size_t PageSize = 4096;
    static constexpr size_t PageSizeMask = PageSize - 1; // for checks
    static constexpr size_t DebugOrSanStackMultiplier = 4; // for debug or sanitizer builds
    static constexpr size_t SmallStackMaxSizeInPages = 6;

    enum class EGuard {
        Canary, //!< writes some data to check it for corruption
        Page,   //!< prohibits access to page memory
    };

    struct TPoolAllocatorSettings {
        size_t RssPagesToKeep = 1;
        size_t SmallStackRssPagesToKeep = 1; // for stack less than SmallStackMaxSizeInPages
        size_t ReleaseRate = 8;
#if !defined(_san_enabled_) && defined(NDEBUG)
        size_t StacksPerChunk = 1024;
#else
        size_t StacksPerChunk = 2;
#endif
    };

    struct TAllocatorStats {
        size_t ReleasedSize = 0;
        size_t NotReleasedSize = 0;
        size_t NumOfAllocated = 0;
    };
}