@@ -114,26 +114,28 @@ nxf_mem_watch() {
114
114
done
115
115
116
116
## result struct: pid %mem vmem rss peak_vmem peak_rss
117
- echo "%mem=${nxf_stat_ret[1]}" >> $trace_file
118
- echo "vmem=${nxf_stat_ret[2]}" >> $trace_file
119
- echo "rss=${nxf_stat_ret[3]}" >> $trace_file
120
- echo "peak_vmem=${nxf_stat_ret[4]}" >> $trace_file
121
- echo "peak_rss=${nxf_stat_ret[5]}" >> $trace_file
122
- echo "vol_ctxt=${nxf_stat_ret[6]}" >> $trace_file
123
- echo "inv_ctxt=${nxf_stat_ret[7]}" >> $trace_file
117
+ printf "%s\n" \
118
+ "%mem=${nxf_stat_ret[1]}" \
119
+ "vmem=${nxf_stat_ret[2]}" \
120
+ "rss=${nxf_stat_ret[3]}" \
121
+ "peak_vmem=${nxf_stat_ret[4]}" \
122
+ "peak_rss=${nxf_stat_ret[5]}" \
123
+ "vol_ctxt=${nxf_stat_ret[6]}" \
124
+ "inv_ctxt=${nxf_stat_ret[7]}" >> "$trace_file" || >&2 echo "Error: Failed to append to file: $trace_file"
124
125
}
125
126
126
127
nxf_write_trace() {
127
- echo "nextflow.trace/v2" > $trace_file
128
- echo "realtime=$wall_time" >> $trace_file
129
- echo "%cpu=$ucpu" >> $trace_file
130
- echo "cpu_model=$cpu_model" >> $trace_file
131
- echo "rchar=${io_stat1[0]}" >> $trace_file
132
- echo "wchar=${io_stat1[1]}" >> $trace_file
133
- echo "syscr=${io_stat1[2]}" >> $trace_file
134
- echo "syscw=${io_stat1[3]}" >> $trace_file
135
- echo "read_bytes=${io_stat1[4]}" >> $trace_file
136
- echo "write_bytes=${io_stat1[5]}" >> $trace_file
128
+ printf "%s\n" \
129
+ "nextflow.trace/v2" \
130
+ "realtime=$wall_time" \
131
+ "%cpu=$ucpu" \
132
+ "cpu_model=$cpu_model" \
133
+ "rchar=${io_stat1[0]}" \
134
+ "wchar=${io_stat1[1]}" \
135
+ "syscr=${io_stat1[2]}" \
136
+ "syscw=${io_stat1[3]}" \
137
+ "read_bytes=${io_stat1[4]}" \
138
+ "write_bytes=${io_stat1[5]}" > "$trace_file" || >&2 echo "Error: Failed to write to file: $trace_file"
137
139
}
138
140
139
141
nxf_trace_mac() {
@@ -199,16 +201,17 @@ nxf_trace_linux() {
199
201
local wall_time=$((end_millis-start_millis))
200
202
[ $NXF_DEBUG = 1 ] && echo "+++ STATS %CPU=$ucpu TIME=$wall_time I/O=${io_stat1[*]}"
201
203
202
- echo "nextflow.trace/v2" > $trace_file
203
- echo "realtime=$wall_time" >> $trace_file
204
- echo "%cpu=$ucpu" >> $trace_file
205
- echo "cpu_model=$cpu_model" >> $trace_file
206
- echo "rchar=${io_stat1[0]}" >> $trace_file
207
- echo "wchar=${io_stat1[1]}" >> $trace_file
208
- echo "syscr=${io_stat1[2]}" >> $trace_file
209
- echo "syscw=${io_stat1[3]}" >> $trace_file
210
- echo "read_bytes=${io_stat1[4]}" >> $trace_file
211
- echo "write_bytes=${io_stat1[5]}" >> $trace_file
204
+ printf "%s\n" \
205
+ "nextflow.trace/v2" \
206
+ "realtime=$wall_time" \
207
+ "%cpu=$ucpu" \
208
+ "cpu_model=$cpu_model" \
209
+ "rchar=${io_stat1[0]}" \
210
+ "wchar=${io_stat1[1]}" \
211
+ "syscr=${io_stat1[2]}" \
212
+ "syscw=${io_stat1[3]}" \
213
+ "read_bytes=${io_stat1[4]}" \
214
+ "write_bytes=${io_stat1[5]}" > "$trace_file" || >&2 echo "Error: Failed to write to file: $trace_file"
212
215
213
216
## join nxf_mem_watch
214
217
[ -e /proc/$mem_proc ] && eval "echo 'DONE' >&$mem_fd" || true
0 commit comments