Skip to content

Commit 8bb7d71

Browse files
Rongxin Xiameta-codesync[bot]
authored andcommitted
Add PSI full memory pressure soft/hard limit ratio to LoadShedConfiguration
Summary: Add PSI full memory pressure soft/hard limit ratio to LoadShedConfiguration Differential Revision: D95131570 fbshipit-source-id: ade88f8b91527625a230170d98ad3cb084b3e319
1 parent cfc7676 commit 8bb7d71

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

wangle/acceptor/LoadShedConfiguration.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ void LoadShedConfiguration::checkIsSane(const SysParams& sysParams) const {
9595
CHECK_GE(udpMemSoftLimitRatio_, 0.0);
9696
CHECK_LE(udpMemSoftLimitRatio_, udpMemHardLimitRatio_);
9797

98+
// PSI full memory pressure soft/hard limit ratios must have values in
99+
// the range of [0-1], inclusive, where the hard limit must be greater
100+
// than or equal to the soft limit.
101+
CHECK_GE(memPressureFullHardLimitRatio_, 0.0);
102+
CHECK_LE(memPressureFullHardLimitRatio_, 1.0);
103+
CHECK_GE(memPressureFullSoftLimitRatio_, 0.0);
104+
CHECK_LE(memPressureFullSoftLimitRatio_, memPressureFullHardLimitRatio_);
105+
98106
// Period must be greater than or equal to 0.
99107
CHECK_GE(period_.count(), std::chrono::milliseconds(0).count());
100108
}

wangle/acceptor/LoadShedConfiguration.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,32 @@ class LoadShedConfiguration {
269269
return nicHardLimitRatio_;
270270
}
271271

272+
/**
273+
* Set/get the PSI full memory pressure avg10 soft limit ratio.
274+
* Various shedding protections should engage when above this limit.
275+
*/
276+
void setMemPressureFullSoftLimitRatio(double limit) {
277+
CHECK_GE(limit, 0.0);
278+
CHECK_LE(limit, 1.0);
279+
memPressureFullSoftLimitRatio_ = limit;
280+
}
281+
double getMemPressureFullSoftLimitRatio() const {
282+
return memPressureFullSoftLimitRatio_;
283+
}
284+
285+
/**
286+
* Set/get the PSI full memory pressure avg10 hard limit ratio.
287+
* More extreme shedding protections should engage when above this limit.
288+
*/
289+
void setMemPressureFullHardLimitRatio(double limit) {
290+
CHECK_GE(limit, 0.0);
291+
CHECK_LE(limit, 1.0);
292+
memPressureFullHardLimitRatio_ = limit;
293+
}
294+
double getMemPressureFullHardLimitRatio() const {
295+
return memPressureFullHardLimitRatio_;
296+
}
297+
272298
void setLoadUpdatePeriod(std::chrono::milliseconds period) {
273299
period_ = period;
274300
}
@@ -325,6 +351,9 @@ class LoadShedConfiguration {
325351
double nicSoftLimitRatio_{1.0};
326352
double nicHardLimitRatio_{1.0};
327353

354+
double memPressureFullSoftLimitRatio_{1.0};
355+
double memPressureFullHardLimitRatio_{1.0};
356+
328357
std::chrono::milliseconds period_;
329358

330359
bool loadSheddingEnabled_{true};

wangle/acceptor/test/LoadShedConfigurationTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ TEST(LoadShedConfigurationTest, TestSettersAndGetters) {
3535
lsc.setCpuHardLimitRatio(0.4);
3636
EXPECT_EQ(0.4, lsc.getCpuHardLimitRatio());
3737

38+
lsc.setMemPressureFullSoftLimitRatio(0.5);
39+
EXPECT_EQ(0.5, lsc.getMemPressureFullSoftLimitRatio());
40+
41+
lsc.setMemPressureFullHardLimitRatio(0.6);
42+
EXPECT_EQ(0.6, lsc.getMemPressureFullHardLimitRatio());
43+
3844
EXPECT_EQ(0, lsc.getCpuUsageExceedWindowSize());
3945
lsc.setCpuUsageExceedWindowSize(12);
4046
EXPECT_EQ(12, lsc.getCpuUsageExceedWindowSize());

0 commit comments

Comments
 (0)