Skip to content

Commit 70e8f1f

Browse files
gladkovaalexgl-github
authored andcommitted
Do not report memory utilization as zero for missing PID.
1 parent 4d45a1c commit 70e8f1f

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

ci/buildspec.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ phases:
1515
- pip install twine
1616
- pip install pytest-mock -U
1717
- pip install requests
18-
- pip install -U -e .[mxnet]
18+
- pip install -U -e .
19+
- pip install mxnet==1.5.0
1920
- cd model-archiver/ && pip install -U -e . && cd ../
2021

2122
build:

frontend/server/src/main/java/com/amazonaws/ml/mms/metrics/MetricCollector.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,14 @@ public void run() {
117117
if (tokens.length != 2) {
118118
continue;
119119
}
120-
121-
Integer pid = Integer.valueOf(tokens[0]);
122-
WorkerThread worker = workerMap.get(pid);
123-
worker.setMemory(Long.parseLong(tokens[1]));
120+
try {
121+
Integer pid = Integer.valueOf(tokens[0]);
122+
WorkerThread worker = workerMap.get(pid);
123+
worker.setMemory(Long.parseLong(tokens[1]));
124+
} catch (NumberFormatException e) {
125+
logger.warn("Failed to parse memory utilization metrics: " + line);
126+
continue;
127+
}
124128
}
125129
}
126130
} catch (IOException e) {

mms/metrics/process_memory_metric.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import psutil
1919

20-
2120
def get_cpu_usage(pid):
2221
"""
2322
use psutil for cpu memory
@@ -27,10 +26,13 @@ def get_cpu_usage(pid):
2726
try:
2827
process = psutil.Process(int(pid))
2928
except psutil.Error:
30-
logging.error("Failed get process for pid: %s", pid, exc_info=True)
29+
logging.error("Failed to get process for pid: %s", pid, exc_info=True)
3130
return 0
3231

3332
mem_utilization = process.memory_info()[0]
33+
if mem_utilization == 0:
34+
logging.error("Failed to get memory utilization for pid: %s", pid, exc_info=True)
35+
return 0
3436
return mem_utilization
3537

3638

@@ -45,4 +47,6 @@ def check_process_mem_usage(stdin):
4547
for process in process_list:
4648
if not process:
4749
continue
48-
logging.info("%s:%d", process, get_cpu_usage(process))
50+
mem_utilization = get_cpu_usage(process)
51+
if mem_utilization != 0:
52+
logging.info("%s:%d", process, mem_utilization)

0 commit comments

Comments
 (0)