Skip to content

Commit a541cec

Browse files
committed
contest: loadavg: wait for dirty page writeback
It looks like AWS machines stall very painfully for some time after the builds because of pending disk IO. The b/w cap was increased on our instances but still there is a few minutes of lag between when we decide the that the load has gone down and when machine has recovered from the builds. Wait for dirty memory to go down to ~100MB. Since we have two conditions now lower the stable count to 3. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e5143b0 commit a541cec

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

contest/remote/lib/loadavg.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,32 @@
44
import time
55

66

7-
def wait_loadavg(target, check_ival=30, stable_cnt=4):
7+
def get_dirty_mem():
8+
""" Get amount of dirty mem, returns value in MB """
9+
with open("/proc/meminfo", "r") as fp:
10+
lines = fp.read().split("\n")
11+
dirty = list(filter(lambda a: "Dirty" in a, lines))[0]
12+
return int(dirty.split(" ")[-2]) / 1000
13+
14+
15+
def wait_loadavg(target, dirty_max=100, check_ival=30, stable_cnt=3):
816
"""
917
Wait for loadavg to drop but be careful at the start, the load
1018
may have not ramped up, yet, so if we ungate early whoever is waiting
1119
will experience the overload.
1220
"""
21+
22+
seen_stable = 0
1323
while target is not None:
1424
load, _, _ = os.getloadavg()
25+
dirty = get_dirty_mem()
1526

16-
if load <= target:
17-
if stable_cnt == 0:
27+
if load <= target and dirty <= dirty_max:
28+
if seen_stable >= stable_cnt:
1829
break
19-
stable_cnt -= 1
30+
seen_stable += 1
2031
else:
21-
stable_cnt = 0
32+
seen_stable = 0
2233

23-
print(f"Waiting for loadavg to decrease: {load} > {target} ({stable_cnt})")
34+
print(f"Waiting for loadavg to decrease: CPU: {load} > {target} Dirty Mem: {dirty} > {dirty_max} MB ({seen_stable})")
2435
time.sleep(check_ival)

0 commit comments

Comments
 (0)