Skip to content

Commit

Permalink
Add CPU model name to trace_file and TraceRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
skrakau committed May 15, 2023
1 parent 77c286e commit 85a72dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class TraceRecord implements Serializable {
syscw: 'num', // -- /proc/$pid/io
read_bytes: 'mem', // -- /proc/$pid/io
write_bytes:'mem', // -- /proc/$pid/io
cpu_model: 'str', // -- /proc/cpuinfo field 'model name'
attempt: 'num',
workdir: 'str',
script: 'str',
Expand Down Expand Up @@ -448,6 +449,10 @@ class TraceRecord implements Serializable {
this.put(name, val)
break

case 'cpu_model':
this.put(name, value)
break

default:
def val = parseLong(value, file, name)
this.put(name, val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ nxf_trace_linux() {
## https://stackoverflow.com/questions/27508531/calculate-cpu-per-process/27514562##27514562
## https://stackoverflow.com/questions/16726779/how-do-i-get-the-total-cpu-usage-of-an-application-from-proc-pid-stat
local num_cpus=$(< /proc/cpuinfo grep '^processor' -c)
local cpu_model=$(< /proc/cpuinfo grep '^model name' | head -n 1 | awk 'BEGIN{FS="\t: "} { print $2 }')
local tot_time0=$(grep '^cpu ' /proc/stat | awk '{sum=$2+$3+$4+$5+$6+$7+$8+$9; printf "%.0f",sum}')
local cpu_time0=$(2> /dev/null < /proc/$pid/stat awk '{printf "%.0f", ($16+$17)*10 }' || echo -n 'X')
local io_stat0=($(2> /dev/null < /proc/$pid/io sed 's/^.*:\s*//' | head -n 6 | tr '\n' ' ' || echo -n '0 0 0 0 0 0'))
Expand Down Expand Up @@ -199,6 +200,7 @@ nxf_trace_linux() {
echo "nextflow.trace/v2" > $trace_file
echo "realtime=$wall_time" >> $trace_file
echo "%cpu=$ucpu" >> $trace_file
echo "cpu_model=$cpu_model" >> $trace_file
echo "rchar=${io_stat1[0]}" >> $trace_file
echo "wchar=${io_stat1[1]}" >> $trace_file
echo "syscr=${io_stat1[2]}" >> $trace_file
Expand Down

0 comments on commit 85a72dd

Please sign in to comment.