@@ -816,6 +816,11 @@ func TestUpdate(t *testing.T) {
816
816
0 : machine .MustParse ("1" ),
817
817
1 : machine .MustParse ("25" ),
818
818
}, 200 << 30 ),
819
+ makeContainerInfo ("uid4" , "default" , "pod4" , "c4" , consts .PodAnnotationQoSLevelReclaimedCores , nil ,
820
+ map [int ]machine.CPUSet {
821
+ 0 : machine .MustParse ("1" ),
822
+ 1 : machine .MustParse ("25" ),
823
+ }, 200 << 30 ),
819
824
},
820
825
pods : []* v1.Pod {
821
826
{
@@ -874,6 +879,62 @@ func TestUpdate(t *testing.T) {
874
879
},
875
880
},
876
881
},
882
+ {
883
+ ObjectMeta : metav1.ObjectMeta {
884
+ Name : "pod3" ,
885
+ Namespace : "default" ,
886
+ UID : "uid3" ,
887
+ Annotations : map [string ]string {
888
+ consts .PodAnnotationQoSLevelKey : consts .PodAnnotationQoSLevelSharedCores ,
889
+ },
890
+ Labels : map [string ]string {
891
+ consts .PodAnnotationQoSLevelKey : consts .PodAnnotationQoSLevelSharedCores ,
892
+ },
893
+ },
894
+ Spec : v1.PodSpec {
895
+ Containers : []v1.Container {
896
+ {
897
+ Name : "c3" ,
898
+ },
899
+ },
900
+ },
901
+ Status : v1.PodStatus {
902
+ ContainerStatuses : []v1.ContainerStatus {
903
+ {
904
+ Name : "c3" ,
905
+ ContainerID : "containerd://c3" ,
906
+ },
907
+ },
908
+ },
909
+ },
910
+ {
911
+ ObjectMeta : metav1.ObjectMeta {
912
+ Name : "pod4" ,
913
+ Namespace : "default" ,
914
+ UID : "uid4" ,
915
+ Annotations : map [string ]string {
916
+ consts .PodAnnotationQoSLevelKey : consts .PodAnnotationQoSLevelReclaimedCores ,
917
+ },
918
+ Labels : map [string ]string {
919
+ consts .PodAnnotationQoSLevelKey : consts .PodAnnotationQoSLevelReclaimedCores ,
920
+ },
921
+ },
922
+ Spec : v1.PodSpec {
923
+ Containers : []v1.Container {
924
+ {
925
+ Name : "c4" ,
926
+ },
927
+ },
928
+ },
929
+ Status : v1.PodStatus {
930
+ ContainerStatuses : []v1.ContainerStatus {
931
+ {
932
+ Name : "c4" ,
933
+ ContainerID : "containerd://c4" ,
934
+ },
935
+ },
936
+ },
937
+ },
877
938
},
878
939
wantHeadroom : * resource .NewQuantity (996 << 30 , resource .DecimalSI ),
879
940
nodeMetrics : defaultNodeMetrics ,
@@ -891,6 +952,18 @@ func TestUpdate(t *testing.T) {
891
952
podUID : "uid1" ,
892
953
containerName : "c1" ,
893
954
},
955
+ {
956
+ metricName : coreconsts .MetricMemCacheContainer ,
957
+ metricValue : metricutil.MetricData {Value : 5 << 30 },
958
+ podUID : "uid1" ,
959
+ containerName : "c1" ,
960
+ },
961
+ {
962
+ metricName : coreconsts .MetricMemMappedContainer ,
963
+ metricValue : metricutil.MetricData {Value : 2 << 30 },
964
+ podUID : "uid1" ,
965
+ containerName : "c1" ,
966
+ },
894
967
{
895
968
metricName : coreconsts .MetricMemInactiveAnonContainer ,
896
969
metricValue : metricutil.MetricData {Value : 1 << 30 },
@@ -939,9 +1012,21 @@ func TestUpdate(t *testing.T) {
939
1012
podUID : "uid2" ,
940
1013
containerName : "c2" ,
941
1014
},
1015
+ {
1016
+ metricName : coreconsts .MetricMemCacheContainer ,
1017
+ metricValue : metricutil.MetricData {Value : 3 << 30 },
1018
+ podUID : "uid2" ,
1019
+ containerName : "c2" ,
1020
+ },
1021
+ {
1022
+ metricName : coreconsts .MetricMemMappedContainer ,
1023
+ metricValue : metricutil.MetricData {Value : 2 << 30 },
1024
+ podUID : "uid2" ,
1025
+ containerName : "c2" ,
1026
+ },
942
1027
{
943
1028
metricName : coreconsts .MetricMemInactiveAnonContainer ,
944
- metricValue : metricutil.MetricData {Value : 1 << 30 },
1029
+ metricValue : metricutil.MetricData {Value : 2 << 30 },
945
1030
podUID : "uid2" ,
946
1031
containerName : "c2" ,
947
1032
},
@@ -975,6 +1060,126 @@ func TestUpdate(t *testing.T) {
975
1060
podUID : "uid2" ,
976
1061
containerName : "c2" ,
977
1062
},
1063
+ {
1064
+ metricName : coreconsts .MetricMemPsiAvg60Container ,
1065
+ metricValue : metricutil.MetricData {Value : 0.01 },
1066
+ podUID : "uid3" ,
1067
+ containerName : "c3" ,
1068
+ },
1069
+ {
1070
+ metricName : coreconsts .MetricMemUsageContainer ,
1071
+ metricValue : metricutil.MetricData {Value : 10 << 30 },
1072
+ podUID : "uid3" ,
1073
+ containerName : "c3" ,
1074
+ },
1075
+ {
1076
+ metricName : coreconsts .MetricMemCacheContainer ,
1077
+ metricValue : metricutil.MetricData {Value : 3 << 30 },
1078
+ podUID : "uid3" ,
1079
+ containerName : "c3" ,
1080
+ },
1081
+ {
1082
+ metricName : coreconsts .MetricMemMappedContainer ,
1083
+ metricValue : metricutil.MetricData {Value : 2 << 30 },
1084
+ podUID : "uid3" ,
1085
+ containerName : "c3" ,
1086
+ },
1087
+ {
1088
+ metricName : coreconsts .MetricMemInactiveAnonContainer ,
1089
+ metricValue : metricutil.MetricData {Value : 2 << 30 },
1090
+ podUID : "uid3" ,
1091
+ containerName : "c3" ,
1092
+ },
1093
+ {
1094
+ metricName : coreconsts .MetricMemInactiveFileContainer ,
1095
+ metricValue : metricutil.MetricData {Value : 1 << 30 },
1096
+ podUID : "uid3" ,
1097
+ containerName : "c3" ,
1098
+ },
1099
+ {
1100
+ metricName : coreconsts .MetricMemPgscanContainer ,
1101
+ metricValue : metricutil.MetricData {Value : 15000 },
1102
+ podUID : "uid3" ,
1103
+ containerName : "c3" ,
1104
+ },
1105
+ {
1106
+ metricName : coreconsts .MetricMemPgstealContainer ,
1107
+ metricValue : metricutil.MetricData {Value : 10000 },
1108
+ podUID : "uid3" ,
1109
+ containerName : "c3" ,
1110
+ },
1111
+ {
1112
+ metricName : coreconsts .MetricMemWorkingsetRefaultContainer ,
1113
+ metricValue : metricutil.MetricData {Value : 1000 },
1114
+ podUID : "uid3" ,
1115
+ containerName : "c3" ,
1116
+ },
1117
+ {
1118
+ metricName : coreconsts .MetricMemWorkingsetActivateContainer ,
1119
+ metricValue : metricutil.MetricData {Value : 1000 },
1120
+ podUID : "uid3" ,
1121
+ containerName : "c3" ,
1122
+ },
1123
+ {
1124
+ metricName : coreconsts .MetricMemPsiAvg60Container ,
1125
+ metricValue : metricutil.MetricData {Value : 0.01 },
1126
+ podUID : "uid4" ,
1127
+ containerName : "c4" ,
1128
+ },
1129
+ {
1130
+ metricName : coreconsts .MetricMemUsageContainer ,
1131
+ metricValue : metricutil.MetricData {Value : 10 << 30 },
1132
+ podUID : "uid4" ,
1133
+ containerName : "c4" ,
1134
+ },
1135
+ {
1136
+ metricName : coreconsts .MetricMemCacheContainer ,
1137
+ metricValue : metricutil.MetricData {Value : 2 << 30 },
1138
+ podUID : "uid4" ,
1139
+ containerName : "c4" ,
1140
+ },
1141
+ {
1142
+ metricName : coreconsts .MetricMemMappedContainer ,
1143
+ metricValue : metricutil.MetricData {Value : 2 << 30 },
1144
+ podUID : "uid4" ,
1145
+ containerName : "c4" ,
1146
+ },
1147
+ {
1148
+ metricName : coreconsts .MetricMemInactiveAnonContainer ,
1149
+ metricValue : metricutil.MetricData {Value : 1 << 30 },
1150
+ podUID : "uid4" ,
1151
+ containerName : "c4" ,
1152
+ },
1153
+ {
1154
+ metricName : coreconsts .MetricMemInactiveFileContainer ,
1155
+ metricValue : metricutil.MetricData {Value : 1 << 30 },
1156
+ podUID : "uid4" ,
1157
+ containerName : "c4" ,
1158
+ },
1159
+ {
1160
+ metricName : coreconsts .MetricMemPgscanContainer ,
1161
+ metricValue : metricutil.MetricData {Value : 15000 },
1162
+ podUID : "uid4" ,
1163
+ containerName : "c4" ,
1164
+ },
1165
+ {
1166
+ metricName : coreconsts .MetricMemPgstealContainer ,
1167
+ metricValue : metricutil.MetricData {Value : 10000 },
1168
+ podUID : "uid4" ,
1169
+ containerName : "c4" ,
1170
+ },
1171
+ {
1172
+ metricName : coreconsts .MetricMemWorkingsetRefaultContainer ,
1173
+ metricValue : metricutil.MetricData {Value : 1000 },
1174
+ podUID : "uid4" ,
1175
+ containerName : "c4" ,
1176
+ },
1177
+ {
1178
+ metricName : coreconsts .MetricMemWorkingsetActivateContainer ,
1179
+ metricValue : metricutil.MetricData {Value : 1000 },
1180
+ podUID : "uid4" ,
1181
+ containerName : "c4" ,
1182
+ },
978
1183
},
979
1184
cgroupMetrics : []cgroupMetric {
980
1185
{
@@ -1007,6 +1212,16 @@ func TestUpdate(t *testing.T) {
1007
1212
metricValue : metricutil.MetricData {Value : 4 << 30 },
1008
1213
cgroupPath : "/hdfs" ,
1009
1214
},
1215
+ {
1216
+ metricName : coreconsts .MetricMemCacheCgroup ,
1217
+ metricValue : metricutil.MetricData {Value : 3 << 30 },
1218
+ cgroupPath : "/hdfs" ,
1219
+ },
1220
+ {
1221
+ metricName : coreconsts .MetricMemMappedCgroup ,
1222
+ metricValue : metricutil.MetricData {Value : 1 << 30 },
1223
+ cgroupPath : "/hdfs" ,
1224
+ },
1010
1225
{
1011
1226
metricName : coreconsts .MetricMemInactiveAnonCgroup ,
1012
1227
metricValue : metricutil.MetricData {Value : 1 << 30 },
@@ -1024,19 +1239,37 @@ func TestUpdate(t *testing.T) {
1024
1239
{
1025
1240
CgroupPath : "/hdfs" ,
1026
1241
Values : map [string ]string {
1027
- string (memoryadvisor .ControlKnobKeySwapMax ): coreconsts .ControlKnobON ,
1242
+ string (memoryadvisor .ControlKnobKeySwapMax ): coreconsts .ControlKnobOFF ,
1028
1243
string (memoryadvisor .ControlKnowKeyMemoryOffloading ): "38654705" ,
1029
1244
},
1030
1245
},
1031
1246
},
1032
- ContainerEntries : []types.ContainerMemoryAdvices {{
1033
- PodUID : "uid1" ,
1034
- ContainerName : "c1" ,
1035
- Values : map [string ]string {
1036
- string (memoryadvisor .ControlKnobKeySwapMax ): coreconsts .ControlKnobON ,
1037
- string (memoryadvisor .ControlKnowKeyMemoryOffloading ): "96636764" ,
1247
+ ContainerEntries : []types.ContainerMemoryAdvices {
1248
+ {
1249
+ PodUID : "uid1" ,
1250
+ ContainerName : "c1" ,
1251
+ Values : map [string ]string {
1252
+ string (memoryadvisor .ControlKnobKeySwapMax ): coreconsts .ControlKnobOFF ,
1253
+ string (memoryadvisor .ControlKnowKeyMemoryOffloading ): "96636764" ,
1254
+ },
1038
1255
},
1039
- }},
1256
+ {
1257
+ PodUID : "uid3" ,
1258
+ ContainerName : "c3" ,
1259
+ Values : map [string ]string {
1260
+ string (memoryadvisor .ControlKnobKeySwapMax ): coreconsts .ControlKnobON ,
1261
+ string (memoryadvisor .ControlKnowKeyMemoryOffloading ): "96636764" ,
1262
+ },
1263
+ },
1264
+ //{
1265
+ // PodUID: "uid4",
1266
+ // ContainerName: "c4",
1267
+ // Values: map[string]string{
1268
+ // string(memoryadvisor.ControlKnobKeySwapMax): coreconsts.ControlKnobOFF,
1269
+ // string(memoryadvisor.ControlKnowKeyMemoryOffloading): "96636764",
1270
+ // },
1271
+ //},
1272
+ },
1040
1273
},
1041
1274
},
1042
1275
{
@@ -2226,12 +2459,15 @@ func TestUpdate(t *testing.T) {
2226
2459
transparentMemoryOffloadingConfiguration := tmo .NewTransparentMemoryOffloadingConfiguration ()
2227
2460
transparentMemoryOffloadingConfiguration .QoSLevelConfigs [consts .QoSLevelReclaimedCores ] = tmo .NewTMOConfigDetail (transparentMemoryOffloadingConfiguration .DefaultConfigurations )
2228
2461
transparentMemoryOffloadingConfiguration .QoSLevelConfigs [consts .QoSLevelReclaimedCores ].EnableTMO = true
2229
- transparentMemoryOffloadingConfiguration .QoSLevelConfigs [consts .QoSLevelReclaimedCores ].EnableSwap = true
2462
+ transparentMemoryOffloadingConfiguration .QoSLevelConfigs [consts .QoSLevelReclaimedCores ].EnableSwap = false
2463
+ transparentMemoryOffloadingConfiguration .QoSLevelConfigs [consts .QoSLevelSharedCores ] = tmo .NewTMOConfigDetail (transparentMemoryOffloadingConfiguration .DefaultConfigurations )
2464
+ transparentMemoryOffloadingConfiguration .QoSLevelConfigs [consts .QoSLevelSharedCores ].EnableTMO = true
2465
+ transparentMemoryOffloadingConfiguration .QoSLevelConfigs [consts .QoSLevelSharedCores ].EnableSwap = true
2230
2466
2231
2467
// cgroup level
2232
2468
transparentMemoryOffloadingConfiguration .CgroupConfigs ["/sys/fs/cgroup/hdfs" ] = tmo .NewTMOConfigDetail (transparentMemoryOffloadingConfiguration .DefaultConfigurations )
2233
2469
transparentMemoryOffloadingConfiguration .CgroupConfigs ["/sys/fs/cgroup/hdfs" ].EnableTMO = true
2234
- transparentMemoryOffloadingConfiguration .CgroupConfigs ["/sys/fs/cgroup/hdfs" ].EnableSwap = true
2470
+ transparentMemoryOffloadingConfiguration .CgroupConfigs ["/sys/fs/cgroup/hdfs" ].EnableSwap = false
2235
2471
2236
2472
advisor .conf .GetDynamicConfiguration ().TransparentMemoryOffloadingConfiguration = transparentMemoryOffloadingConfiguration
2237
2473
_ , advisorRecvChInterface := advisor .GetChannels ()
@@ -2256,7 +2492,7 @@ func TestUpdate(t *testing.T) {
2256
2492
ctx , cancel := context .WithCancel (context .Background ())
2257
2493
advisor .Run (ctx )
2258
2494
2259
- time .Sleep (10 * time .Millisecond ) // Wait some time because no signal will be sent to channel
2495
+ time .Sleep (100 * time .Millisecond ) // Wait some time because no signal will be sent to channel
2260
2496
if tt .needRecvAdvices {
2261
2497
result := <- recvCh
2262
2498
0 commit comments