Skip to content

Commit e2c77f0

Browse files
author
Qi Li (leeli4)
committed
fix python and Javavm boot up collection issue - complain by customer
1 parent 98c100a commit e2c77f0

File tree

5 files changed

+94
-54
lines changed

5 files changed

+94
-54
lines changed

collect.sh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ log_verbose() {
1919
fi
2020
}
2121

22+
if [[ $OUTPUT_FILE == *"python3"* ]]; then
23+
PYTHON_SWITCH=1
24+
else
25+
PYTHON_SWITCH=0
26+
fi
27+
28+
2229
OUTPUT_DIR=$(dirname "$OUTPUT_FILE")
2330
mkdir -p "$OUTPUT_DIR"
2431

@@ -34,9 +41,9 @@ if [ ! -z "$SIGNAL_FILE" ]; then
3441
log_verbose "Start signal received. Beginning data collection for PID $PID..."
3542
fi
3643

37-
for (( i=0;i<=$DURATION;i++ ))
38-
do
39-
START_TIME=$(date +%s%N)
44+
# for (( i=0;i<=$DURATION;i++ ))
45+
# do
46+
# START_TIME=$(date +%s%N)
4047

4148
ALO_TOTAL=$(cat /proc/meminfo | grep 'Committed_AS' | awk -F' ' '{print $2}')
4249
Limit=$(cat /proc/meminfo | grep 'CommitLimit' | awk -F' ' '{print $2}')
@@ -52,14 +59,14 @@ do
5259
log_verbose "$i second is collected to $OUTPUT_FILE"
5360
fi
5461

55-
END_TIME=$(date +%s%N)
56-
ELAPSED=$(($END_TIME - $START_TIME))
57-
SLEEP_TIME=$(($NS - $ELAPSED))
62+
# END_TIME=$(date +%s%N)
63+
# ELAPSED=$(($END_TIME - $START_TIME))
64+
# SLEEP_TIME=$(($NS - $ELAPSED))
5865

59-
if (( SLEEP_TIME > 0 )); then
60-
SLEEP_SECONDS=$(awk "BEGIN {printf \"%.9f\", $SLEEP_TIME/$NS}")
61-
sleep $SLEEP_SECONDS
62-
fi
63-
done
66+
# if (( SLEEP_TIME > 0 )); then
67+
# SLEEP_SECONDS=$(awk "BEGIN {printf \"%.9f\", $SLEEP_TIME/$NS}")
68+
# sleep $SLEEP_SECONDS
69+
# fi
70+
# done
6471

65-
echo "Collection for PID $PID done"
72+
#echo "Collection for PID $PID done"

compare_mem_alloc.plt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ set format x '%H:%M:%S'
5656

5757
show style line
5858

59-
plot "data/python3/mem_total.log" using 1:5 with lines axes x1y1 lc 'red' lw 2 title "CommitLimit", \
60-
"data/python3/mem_total.log" using 1:4 with lines axes x1y1 title "Commited_AS", \
59+
plot "data/python3/mem_ncs.smp.log" using 1:5 with lines axes x1y1 lc 'red' lw 2 title "CommitLimit", \
60+
"data/python3/mem_ncs.smp.log" using 1:4 with lines axes x1y1 title "Commited_AS", \
6161
"data/ncs.smp/mem_ncs.smp.log" using 1:3 with lines axes x1y1 title "ncs.smp", \
6262
"data/python3/mem_total.log" using 1:3 with lines axes x1y1 title "PythonVM(Total)", \
6363
"data/NcsJVMLauncher/mem_NcsJVMLauncher.log" using 1:3 with lines axes x1y1 title "JavaVM"

compare_mem_rss.plt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ show style line
5959

6060

6161

62-
plot "data/python3/mem_total.log" using 1:5 with lines axes x1y1 lc 'red' lw 2 title "CommitLimit", \
63-
"data/python3/mem_total.log" using 1:4 with lines axes x1y1 title "Commited_AS", \
64-
"data/ncs.smp/mem_ncs.smp.log" using 1:2 with lines axes x1y1 title "ncs.smp", \
62+
plot "data/ncs.smp/mem_ncs.smp.log" using 1:2 with lines axes x1y1 title "ncs.smp", \
6563
"data/python3/mem_total.log" using 1:2 with lines axes x1y1 title "PythonVM(Total)", \
6664
"data/NcsJVMLauncher/mem_NcsJVMLauncher.log" using 1:2 with lines axes x1y1 title "JavaVM"

graphs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mkdir graphs/$1
2828

2929
for filename in data/$1/*.log; do
3030
if [ $PY_CHECK -eq 1 ]; then
31-
name=$(echo $filename | awk -F'/' '{print $NF}' | awk -F'mem_|\.log' '{print $2}')
31+
name=$(echo $filename | awk -F'/' '{print $NF}' | awk -F'mem_|.log' '{print $2}')
3232
else
3333
name=$1
3434
fi

plot.sh

Lines changed: 71 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -79,47 +79,82 @@ rm -f "$SIGNAL_FILE"
7979
# Find and collect for each process type
8080
echo "Starting collection processes..."
8181

82-
# Collect ncs.smp or beam.smp NSO process
83-
NCS_PID=$(pgrep -f "\.smp.*-ncs true")
84-
if [ ! -z "$NCS_PID" ]; then
85-
echo "Starting collection for ncs.smp PID $NCS_PID"
86-
bash collect.sh $NCS_PID "data/ncs.smp/mem_ncs.smp.log" $DURATION $VERBOSE "$SIGNAL_FILE" &
87-
fi
88-
89-
# Collect NcsJVMLauncher process
90-
JVM_PID=$(pgrep -f NcsJVMLauncher)
91-
if [ ! -z "$JVM_PID" ]; then
92-
echo "Starting collection for NcsJVMLauncher PID $JVM_PID"
93-
bash collect.sh $JVM_PID "data/NcsJVMLauncher/mem_NcsJVMLauncher.log" $DURATION $VERBOSE "$SIGNAL_FILE" &
94-
fi
82+
NS=1000000000
83+
84+
mkdir -p data/python3
85+
for (( i=0;i<=$DURATION;i++ ))
86+
do
87+
START_TIME=$(date +%s%N)
88+
PYTHON_PIDS=$(pgrep -f "python.* .*startup\.py")
89+
JVM_PID=$(pgrep -f NcsJVMLauncher)
90+
NCS_PID=$(pgrep -f "\.smp.*-ncs true")
91+
92+
# Collect ncs.smp or beam.smp NSO process
93+
if [ ! -z "$NCS_PID" ]; then
94+
#echo "Starting collection for ncs.smp PID $NCS_PID"
95+
COLLECT_PIDS=$(pgrep -f ".*collect.sh.* $NCS_PID")
96+
if [ -z "$COLLECT_PIDS" ]; then
97+
bash collect.sh $NCS_PID "data/ncs.smp/mem_ncs.smp.log" $DURATION $VERBOSE "$SIGNAL_FILE" &
98+
fi
99+
fi
95100

96-
# Collect Python processes
97-
PYTHON_PIDS=$(pgrep -f "python.* .*startup\.py")
98-
if [ ! -z "$PYTHON_PIDS" ]; then
99-
mkdir -p data/python3
100-
for pid in $PYTHON_PIDS; do
101-
PYTHON_SCRIPT=$(ps -p $pid -o command | tail -n 1 | awk -F' ' '{print $9}')
102-
SCRIPT_NAME=$(basename "$PYTHON_SCRIPT" .py 2>/dev/null || echo "python_$pid")
103-
if [ ! -z "$PYTHON_SCRIPT" ]; then
104-
echo "Starting collection for Python process PID $pid: $SCRIPT_NAME"
105-
bash collect.sh $pid "data/python3/mem_$SCRIPT_NAME.log" $DURATION $VERBOSE "$SIGNAL_FILE" &
101+
# Collect NcsJVMLauncher process
102+
if [ ! -z "$JVM_PID" ]; then
103+
#echo "Starting collection for NcsJVMLauncher PID $JVM_PID"
104+
COLLECT_PIDS=$(pgrep -f ".*collect.sh.* $JVM_PID")
105+
if [ -z "$COLLECT_PIDS" ]; then
106+
bash collect.sh $JVM_PID "data/NcsJVMLauncher/mem_NcsJVMLauncher.log" $DURATION $VERBOSE "$SIGNAL_FILE" &
106107
fi
107-
done
108-
else
109-
echo "No Python processes found to collect"
110-
fi
108+
fi
111109

112-
# Give a moment for all processes to register
113-
sleep 1
110+
# Collect Python processes
111+
if [ ! -z "$PYTHON_PIDS" ]; then
112+
for pid in $PYTHON_PIDS; do
113+
COLLECT_PIDS=$(pgrep -f ".*collect.sh.* $pid")
114+
if [ -z "$COLLECT_PIDS" ]; then
115+
#echo "Not Found Collection Process for Python process PID $pid. Spwaning new Collection Process."
116+
PYTHON_SCRIPT=$(ps -p $pid -o command | tail -n 1 | awk -F' ' '{print $9}')
117+
SCRIPT_NAME=$(basename "$PYTHON_SCRIPT" .py 2>/dev/null || echo "python_$pid")
118+
if [ ! -z "$PYTHON_SCRIPT" ]; then
119+
#echo "Starting collection for Python process PID $pid: $SCRIPT_NAME"
120+
bash collect.sh $pid "data/python3/mem_$SCRIPT_NAME.log" $DURATION-$i $VERBOSE "$SIGNAL_FILE" &
121+
fi
122+
# else
123+
# echo "Collection Process already running for Python process PID $pid"
124+
fi
125+
done
126+
# else
127+
# echo "No Python processes found to collect. for second $i"
128+
fi
129+
130+
131+
132+
END_TIME=$(date +%s%N)
133+
ELAPSED=$(($END_TIME - $START_TIME))
134+
SLEEP_TIME=$(($NS - $ELAPSED))
135+
if (( SLEEP_TIME > 0 )); then
136+
SLEEP_SECONDS=$(awk "BEGIN {printf \"%.9f\", $SLEEP_TIME/$NS}")
137+
#echo $SLEEP_SECONDS
138+
sleep $SLEEP_SECONDS
139+
fi
114140

115-
# Signal all processes to start collecting
116-
echo "All collection processes started. Signaling to begin data collection..."
117-
touch "$SIGNAL_FILE"
141+
# Signal all processes to start collecting
142+
touch "$SIGNAL_FILE"
143+
wait
144+
echo -ne "Data Collection - $i second out of $DURATION second"\\r
118145

119-
wait
146+
# Clean up signal file
147+
rm -f "$SIGNAL_FILE"
148+
pkill -f collect.sh
149+
# # Give a moment for all processes to register
150+
# sleep 1
151+
done
152+
153+
echo ""
154+
echo "Data Collection - OK!"
155+
156+
sleep 2
120157

121-
# Clean up signal file
122-
rm -f "$SIGNAL_FILE"
123158

124159
if [ ! -z "$PYTHON_PIDS" ]; then
125160
create_combined_python_log
@@ -146,4 +181,4 @@ echo "===================================== Ploting graph for python3 processes
146181
echo "====================================== Ploting graph to compare between process ========================================================"
147182
bash graphs_compare.sh $VERBOSE
148183
echo -e "====================================== Ploting graph to compare between process done ========================================================\n"
149-
echo "===================================== Ploting graph to all process done ================================================="
184+
echo "===================================== Ploting graph to all process done ================================================="

0 commit comments

Comments
 (0)