defs.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. // unique tag to fix pragma once gcc glueing: ./library/actorlib/core/defs.h
  3. #include <library/cpp/actors/util/defs.h>
  4. #include <util/generic/hash.h>
  5. #include <util/string/printf.h>
  6. // Enables collection of
  7. // event send/receive counts
  8. // activation time histograms
  9. // event processing time histograms
  10. #define ACTORSLIB_COLLECT_EXEC_STATS
  11. namespace NActors {
  12. using TPoolId = ui8;
  13. using TPoolsMask = ui64;
  14. static constexpr TPoolId PoolBits = 6;
  15. static constexpr TPoolId MaxPools = (1 << PoolBits) - 1; // maximum amount of pools (poolid=63 is reserved)
  16. static constexpr TPoolsMask WaitPoolsFlag = (1ull << MaxPools); // wait-for-slow-workers flag bitmask
  17. // Special TPoolId values used by TCpuState
  18. static constexpr TPoolId CpuSpinning = MaxPools; // fast-worker is actively spinning, no slow-workers
  19. static constexpr TPoolId CpuBlocked = MaxPools + 1; // fast-worker is blocked, no slow-workers
  20. static constexpr TPoolId CpuStopped = TPoolId(-1); // special value indicating worker should stop
  21. static constexpr TPoolId CpuShared = MaxPools; // special value for `assigned` meaning balancer disabled, pool scheduler is used instead
  22. using TPoolWeight = ui16;
  23. static constexpr TPoolWeight MinPoolWeight = 1;
  24. static constexpr TPoolWeight DefPoolWeight = 32;
  25. static constexpr TPoolWeight MaxPoolWeight = 1024;
  26. using TWorkerId = ui16;
  27. static constexpr TWorkerId WorkerBits = 11;
  28. static constexpr TWorkerId MaxWorkers = 1 << WorkerBits;
  29. using TThreadId = ui64;
  30. static constexpr TThreadId UnknownThreadId = ui64(-1);
  31. struct TMailboxType {
  32. enum EType {
  33. Inherited = -1, // inherit mailbox from parent
  34. Simple = 0, // simplest queue under producer lock. fastest in no-contention case
  35. Revolving = 1, // somewhat outdated, tries to be wait-free. replaced by ReadAsFilled
  36. HTSwap = 2, // other simple lf queue, suggested for low-contention case
  37. ReadAsFilled = 3, // wait-free queue, suggested for high-contention or latency critical
  38. TinyReadAsFilled = 4, // same as 3 but with lower overhead
  39. //Inplace;
  40. //Direct;
  41. //Virtual
  42. };
  43. };
  44. struct TScopeId : std::pair<ui64, ui64> {
  45. using TBase = std::pair<ui64, ui64>;
  46. using TBase::TBase;
  47. static const TScopeId LocallyGenerated;
  48. };
  49. static inline TString ScopeIdToString(const TScopeId& scopeId) {
  50. return Sprintf("<%" PRIu64 ":%" PRIu64 ">", scopeId.first, scopeId.second);
  51. }
  52. }
  53. template<>
  54. struct hash<NActors::TScopeId> : hash<std::pair<ui64, ui64>> {};
  55. class TAffinity;