aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/coroutine/engine/stack/stack_common.h
blob: ed2d74d296df5bb6b26c5a3c8f97772de07fbc8c (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 <cstdint>

class TContExecutor;

namespace NCoro::NStack {

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

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

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

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