stack_common.h 979 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <cstddef>
  3. class TContExecutor;
  4. namespace NCoro::NStack {
  5. static constexpr size_t PageSize = 4096;
  6. static constexpr size_t PageSizeMask = PageSize - 1; // for checks
  7. static constexpr size_t DebugOrSanStackMultiplier = 4; // for debug or sanitizer builds
  8. static constexpr size_t SmallStackMaxSizeInPages = 6;
  9. enum class EGuard {
  10. Canary, //!< writes some data to check it for corruption
  11. Page, //!< prohibits access to page memory
  12. };
  13. struct TPoolAllocatorSettings {
  14. size_t RssPagesToKeep = 1;
  15. size_t SmallStackRssPagesToKeep = 1; // for stack less than SmallStackMaxSizeInPages
  16. size_t ReleaseRate = 8;
  17. #if !defined(_san_enabled_) && defined(NDEBUG)
  18. size_t StacksPerChunk = 1024;
  19. #else
  20. size_t StacksPerChunk = 2;
  21. #endif
  22. };
  23. struct TAllocatorStats {
  24. size_t ReleasedSize = 0;
  25. size_t NotReleasedSize = 0;
  26. size_t NumOfAllocated = 0;
  27. };
  28. }