0

I have a bash script to do calculation. This calculation generates big scratch files as big as 12 GB and the disk usage of scratch folder is ~30 GB. I want to know how much total data is written to disk during the process and how much total data is read. This will help me to understand the disk IO bottlenecks and choose a better scratch disk type.

Question : Track written data (MB or GB) in a folder between a time interval. Similarly track read data from a folder between a time interval.

The present version of my script is below.

#!/bin/bash
# Running QM-JOB: helix HPC
    d="$1"  # .dal file
    m="$2"  # .mol file
    n="$3"  # number of CPU cores to be used for this calculation.
dir=$(pwd)
dt=$(date  +%Y-%m-%d:%H:%M:%S )
echo -e 'Job started @ '$dt'' >> /home/vayu/dalton/runlog.log
echo "-----------------------------------------------"
df -h /dev/md0
echo "-----------------------------------------------"

folder="<path/to/the/folder>" #Scratch folder

# start IO log on "scratch folder" (no idea how to implement this)
echo "-----------------------------------------------"

export OMP_NUM_THREADS=$n
source /opt/intel/parallel_studio_xe_2017.0.035/compilers_and_libraries_2017/linux/bin/compilervars.sh intel64
source /opt/intel/parallel_studio_xe_2017.0.035/compilers_and_libraries_2017/linux/mkl/bin/mklvars.sh intel64
source /opt/intel/parallel_studio_xe_2017.0.035/compilers_and_libraries_2017/linux/mpi/bin64/mpivars.sh intel64

./application_script "$d" "$m" "$n" "$folder"

    dt2=$(date '+%d/%m/%Y %H:%M:%S');

#stop "scratch folder" IO log
#print total data written in "scratch folder"
#print total data read from "scratch folder"
1
  • It's not a standard (already installed) utility, but you might find pv (pipe viewer) to come in handy for this sort of thing.
    – Wildcard
    Jun 6, 2017 at 7:16

1 Answer 1

1

You can read the I/O stats from /proc/self/io before and after your task, and subtract the values from the "write_bytes" and "read_bytes" lines. See "man proc" for some details. It does not differentiate by device or folder, though.

Here's an example:

#!/bin/bash
cat /proc/$$/io
dd if=/dev/zero of=/tmp/iotest bs=1M count=5
sync
cat /proc/$$/io
rm /tmp/iotest
4
  • I checked those numbers, but found that on those numbers are not changing. Weird.
    – ankit7540
    Jun 8, 2017 at 13:24
  • How did you check? Did you run your program with realistic data? If you just write a little bit, the data might not even be written to disk but stays in buffers until forced out by "sync" for example. Jun 8, 2017 at 13:29
  • I checked with running calculation during which ~ 250 MB was written to disk as per du -h
    – ankit7540
    Jun 8, 2017 at 13:36
  • Added a short example, using $$ for the pid (self doesn't work actually) Jun 8, 2017 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .