@@ -12,6 +12,39 @@ ui64 GetPercent(float percent, ui64 value) {
12
12
return static_cast <ui64>(static_cast <double >(value) * (percent / 100.0 ));
13
13
}
14
14
15
+ #define GET_LIMIT (name ) \
16
+ inline ui64 Get##name##Bytes(const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) { \
17
+ if (config.Has ##name##Percent () && config.Has ##name##Bytes ()) { \
18
+ return Min (GetPercent (config.Get ##name##Percent (), hardLimitBytes), config.Get ##name##Bytes ()); \
19
+ } \
20
+ if (config.Has ##name##Bytes ()) { \
21
+ return config.Get ##name##Bytes (); \
22
+ } \
23
+ return GetPercent (config.Get ##name##Percent (), hardLimitBytes); \
24
+ }
25
+
26
+ #define GET_MIN_LIMIT (name ) \
27
+ inline ui64 Get##name##MinBytes(const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) { \
28
+ if (config.Has ##name##MinPercent () && config.Has ##name##MinBytes ()) { \
29
+ return Max (GetPercent (config.Get ##name##MinPercent (), hardLimitBytes), config.Get ##name##MinBytes ()); \
30
+ } \
31
+ if (config.Has ##name##MinBytes ()) { \
32
+ return config.Get ##name##MinBytes (); \
33
+ } \
34
+ return GetPercent (config.Get ##name##MinPercent (), hardLimitBytes); \
35
+ }
36
+
37
+ #define GET_MAX_LIMIT (name ) \
38
+ inline ui64 Get##name##MaxBytes(const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) { \
39
+ if (config.Has ##name##MaxPercent () && config.Has ##name##MaxBytes ()) { \
40
+ return Min (GetPercent (config.Get ##name##MaxPercent (), hardLimitBytes), config.Get ##name##MaxBytes ()); \
41
+ } \
42
+ if (config.Has ##name##MaxBytes ()) { \
43
+ return config.Get ##name##MaxBytes (); \
44
+ } \
45
+ return GetPercent (config.Get ##name##MaxPercent (), hardLimitBytes); \
46
+ }
47
+
15
48
};
16
49
17
50
inline ui64 GetHardLimitBytes (const NKikimrConfig::TMemoryControllerConfig& config, const TProcessMemoryInfo& info, bool & hasMemTotalHardLimit) {
@@ -32,84 +65,16 @@ inline ui64 GetHardLimitBytes(const NKikimrConfig::TMemoryControllerConfig& conf
32
65
return 512_MB; // fallback
33
66
}
34
67
35
- inline ui64 GetSoftLimitBytes (const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) {
36
- if (config.HasSoftLimitPercent () && config.HasSoftLimitBytes ()) {
37
- return Min (GetPercent (config.GetSoftLimitPercent (), hardLimitBytes), config.GetSoftLimitBytes ());
38
- }
39
- if (config.HasSoftLimitBytes ()) {
40
- return config.GetSoftLimitBytes ();
41
- }
42
- return GetPercent (config.GetSoftLimitPercent (), hardLimitBytes);
43
- }
44
-
45
- inline ui64 GetTargetUtilizationBytes (const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) {
46
- if (config.HasTargetUtilizationPercent () && config.HasTargetUtilizationBytes ()) {
47
- return Min (GetPercent (config.GetTargetUtilizationPercent (), hardLimitBytes), config.GetTargetUtilizationBytes ());
48
- }
49
- if (config.HasTargetUtilizationBytes ()) {
50
- return config.GetTargetUtilizationBytes ();
51
- }
52
- return GetPercent (config.GetTargetUtilizationPercent (), hardLimitBytes);
53
- }
54
-
55
- inline ui64 GetActivitiesLimitBytes (const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) {
56
- if (config.HasActivitiesLimitPercent () && config.HasActivitiesLimitBytes ()) {
57
- return Min (GetPercent (config.GetActivitiesLimitPercent (), hardLimitBytes), config.GetActivitiesLimitBytes ());
58
- }
59
- if (config.HasActivitiesLimitBytes ()) {
60
- return config.GetActivitiesLimitBytes ();
61
- }
62
- return GetPercent (config.GetActivitiesLimitPercent (), hardLimitBytes);
63
- }
64
-
65
- inline ui64 GetMemTableMinBytes (const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) {
66
- if (config.HasMemTableMinPercent () && config.HasMemTableMinBytes ()) {
67
- return Max (GetPercent (config.GetMemTableMinPercent (), hardLimitBytes), config.GetMemTableMinBytes ());
68
- }
69
- if (config.HasMemTableMinBytes ()) {
70
- return config.GetMemTableMinBytes ();
71
- }
72
- return GetPercent (config.GetMemTableMinPercent (), hardLimitBytes);
73
- }
68
+ GET_LIMIT (SoftLimit)
69
+ GET_LIMIT (TargetUtilization)
70
+ GET_LIMIT (ActivitiesLimit)
74
71
75
- inline ui64 GetMemTableMaxBytes (const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) {
76
- if (config.HasMemTableMaxPercent () && config.HasMemTableMaxBytes ()) {
77
- return Min (GetPercent (config.GetMemTableMaxPercent (), hardLimitBytes), config.GetMemTableMaxBytes ());
78
- }
79
- if (config.HasMemTableMaxBytes ()) {
80
- return config.GetMemTableMaxBytes ();
81
- }
82
- return GetPercent (config.GetMemTableMaxPercent (), hardLimitBytes);
83
- }
72
+ GET_MIN_LIMIT (MemTable)
73
+ GET_MAX_LIMIT (MemTable)
84
74
85
- inline ui64 GetSharedCacheMinBytes (const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) {
86
- if (config.HasSharedCacheMinPercent () && config.HasSharedCacheMinBytes ()) {
87
- return Max (GetPercent (config.GetSharedCacheMinPercent (), hardLimitBytes), config.GetSharedCacheMinBytes ());
88
- }
89
- if (config.HasSharedCacheMinBytes ()) {
90
- return config.GetSharedCacheMinBytes ();
91
- }
92
- return GetPercent (config.GetSharedCacheMinPercent (), hardLimitBytes);
93
- }
94
-
95
- inline ui64 GetSharedCacheMaxBytes (const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) {
96
- if (config.HasSharedCacheMaxPercent () && config.HasSharedCacheMaxBytes ()) {
97
- return Min (GetPercent (config.GetSharedCacheMaxPercent (), hardLimitBytes), config.GetSharedCacheMaxBytes ());
98
- }
99
- if (config.HasSharedCacheMaxBytes ()) {
100
- return config.GetSharedCacheMaxBytes ();
101
- }
102
- return GetPercent (config.GetSharedCacheMaxPercent (), hardLimitBytes);
103
- }
75
+ GET_MIN_LIMIT (SharedCache)
76
+ GET_MAX_LIMIT (SharedCache)
104
77
105
- inline ui64 GetQueryExecutionLimitBytes (const NKikimrConfig::TMemoryControllerConfig& config, ui64 hardLimitBytes) {
106
- if (config.HasQueryExecutionLimitPercent () && config.HasQueryExecutionLimitBytes ()) {
107
- return Min (GetPercent (config.GetQueryExecutionLimitPercent (), hardLimitBytes), config.GetQueryExecutionLimitBytes ());
108
- }
109
- if (config.HasQueryExecutionLimitBytes ()) {
110
- return config.GetQueryExecutionLimitBytes ();
111
- }
112
- return GetPercent (config.GetQueryExecutionLimitPercent (), hardLimitBytes);
113
- }
78
+ GET_LIMIT (QueryExecutionLimit)
114
79
115
80
}
0 commit comments