Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate Interrupted system call on trace_file writes #5397

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,28 @@ nxf_mem_watch() {
done

## result struct: pid %mem vmem rss peak_vmem peak_rss
echo "%mem=${nxf_stat_ret[1]}" >> $trace_file
echo "vmem=${nxf_stat_ret[2]}" >> $trace_file
echo "rss=${nxf_stat_ret[3]}" >> $trace_file
echo "peak_vmem=${nxf_stat_ret[4]}" >> $trace_file
echo "peak_rss=${nxf_stat_ret[5]}" >> $trace_file
echo "vol_ctxt=${nxf_stat_ret[6]}" >> $trace_file
echo "inv_ctxt=${nxf_stat_ret[7]}" >> $trace_file
printf "%s\n" \
"%mem=${nxf_stat_ret[1]}" \
"vmem=${nxf_stat_ret[2]}" \
"rss=${nxf_stat_ret[3]}" \
"peak_vmem=${nxf_stat_ret[4]}" \
"peak_rss=${nxf_stat_ret[5]}" \
"vol_ctxt=${nxf_stat_ret[6]}" \
"inv_ctxt=${nxf_stat_ret[7]}" >> "$trace_file" || >&2 echo "Error: Failed to append to file: $trace_file"
}

nxf_write_trace() {
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
echo "syscw=${io_stat1[3]}" >> $trace_file
echo "read_bytes=${io_stat1[4]}" >> $trace_file
echo "write_bytes=${io_stat1[5]}" >> $trace_file
printf "%s\n" \
"nextflow.trace/v2" \
"realtime=$wall_time" \
"%cpu=$ucpu" \
"cpu_model=$cpu_model" \
"rchar=${io_stat1[0]}" \
"wchar=${io_stat1[1]}" \
"syscr=${io_stat1[2]}" \
"syscw=${io_stat1[3]}" \
"read_bytes=${io_stat1[4]}" \
"write_bytes=${io_stat1[5]}" > "$trace_file" || >&2 echo "Error: Failed to write to file: $trace_file"
}

nxf_trace_mac() {
Expand Down Expand Up @@ -199,16 +201,17 @@ nxf_trace_linux() {
local wall_time=$((end_millis-start_millis))
[ $NXF_DEBUG = 1 ] && echo "+++ STATS %CPU=$ucpu TIME=$wall_time I/O=${io_stat1[*]}"

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
echo "syscw=${io_stat1[3]}" >> $trace_file
echo "read_bytes=${io_stat1[4]}" >> $trace_file
echo "write_bytes=${io_stat1[5]}" >> $trace_file
printf "%s\n" \
"nextflow.trace/v2" \
"realtime=$wall_time" \
"%cpu=$ucpu" \
"cpu_model=$cpu_model" \
"rchar=${io_stat1[0]}" \
"wchar=${io_stat1[1]}" \
"syscr=${io_stat1[2]}" \
"syscw=${io_stat1[3]}" \
"read_bytes=${io_stat1[4]}" \
"write_bytes=${io_stat1[5]}" > "$trace_file" || >&2 echo "Error: Failed to write to file: $trace_file"

## join nxf_mem_watch
[ -e /proc/$mem_proc ] && eval "echo 'DONE' >&$mem_fd" || true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,28 @@ nxf_mem_watch() {
count=$((count+1))
done

echo "%mem=${nxf_stat_ret[1]}" >> $trace_file
echo "vmem=${nxf_stat_ret[2]}" >> $trace_file
echo "rss=${nxf_stat_ret[3]}" >> $trace_file
echo "peak_vmem=${nxf_stat_ret[4]}" >> $trace_file
echo "peak_rss=${nxf_stat_ret[5]}" >> $trace_file
echo "vol_ctxt=${nxf_stat_ret[6]}" >> $trace_file
echo "inv_ctxt=${nxf_stat_ret[7]}" >> $trace_file
printf "%s\n" \
"%mem=${nxf_stat_ret[1]}" \
"vmem=${nxf_stat_ret[2]}" \
"rss=${nxf_stat_ret[3]}" \
"peak_vmem=${nxf_stat_ret[4]}" \
"peak_rss=${nxf_stat_ret[5]}" \
"vol_ctxt=${nxf_stat_ret[6]}" \
"inv_ctxt=${nxf_stat_ret[7]}" >> "$trace_file" || >&2 echo "Error: Failed to append to file: $trace_file"
}

nxf_write_trace() {
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
echo "syscw=${io_stat1[3]}" >> $trace_file
echo "read_bytes=${io_stat1[4]}" >> $trace_file
echo "write_bytes=${io_stat1[5]}" >> $trace_file
printf "%s\n" \
"nextflow.trace/v2" \
"realtime=$wall_time" \
"%cpu=$ucpu" \
"cpu_model=$cpu_model" \
"rchar=${io_stat1[0]}" \
"wchar=${io_stat1[1]}" \
"syscr=${io_stat1[2]}" \
"syscw=${io_stat1[3]}" \
"read_bytes=${io_stat1[4]}" \
"write_bytes=${io_stat1[5]}" > "$trace_file" || >&2 echo "Error: Failed to write to file: $trace_file"
}

nxf_trace_mac() {
Expand Down Expand Up @@ -173,16 +175,17 @@ nxf_trace_linux() {
local wall_time=$((end_millis-start_millis))
[ $NXF_DEBUG = 1 ] && echo "+++ STATS %CPU=$ucpu TIME=$wall_time I/O=${io_stat1[*]}"

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
echo "syscw=${io_stat1[3]}" >> $trace_file
echo "read_bytes=${io_stat1[4]}" >> $trace_file
echo "write_bytes=${io_stat1[5]}" >> $trace_file
printf "%s\n" \
"nextflow.trace/v2" \
"realtime=$wall_time" \
"%cpu=$ucpu" \
"cpu_model=$cpu_model" \
"rchar=${io_stat1[0]}" \
"wchar=${io_stat1[1]}" \
"syscr=${io_stat1[2]}" \
"syscw=${io_stat1[3]}" \
"read_bytes=${io_stat1[4]}" \
"write_bytes=${io_stat1[5]}" > "$trace_file" || >&2 echo "Error: Failed to write to file: $trace_file"

[ -e /proc/$mem_proc ] && eval "echo 'DONE' >&$mem_fd" || true
wait $mem_proc 2>/dev/null || true
Expand Down