Skip to content

Commit

Permalink
Add support for idletime profiling
Browse files Browse the repository at this point in the history
Idletime profiling allows a benchmark to run while filling the
idle cycles on the server, hence giving you some metric of how
much pressure the system is under. This is useful to be able
to profile and compare changes in a setup or driver, for instance.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
fio-prf authored and axboe committed Jan 30, 2013
1 parent 771e58b commit f2a2ce0
Show file tree
Hide file tree
Showing 11 changed files with 597 additions and 1 deletion.
15 changes: 15 additions & 0 deletions HOWTO
Original file line number Diff line number Diff line change
Expand Up @@ -1693,3 +1693,18 @@ write Write 'length' bytes beginning from 'offset'
sync fsync() the file
datasync fdatasync() the file
trim trim the given file from the given 'offset' for 'length' bytes


9.0 CPU idleness profiling

In some cases, we want to understand CPU overhead in a test. For example,
we test patches for the specific goodness of whether they reduce CPU usage.
fio implements a balloon approach to create a thread per CPU that runs at
idle priority, meaning that it only runs when nobody else needs the cpu.
By measuring the amount of work completed by the thread, idleness of each
CPU can be derived accordingly.

An unit work is defined as touching a full page of unsigned characters. Mean
and standard deviation of time to complete an unit work is reported in "unit
work" section. Options can be chosen to report detailed percpu idleness or
overall system idleness by aggregating percpu stats.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
engines/mmap.c engines/sync.c engines/null.c engines/net.c \
memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \
helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.c
helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.c \
idletime.c

ifdef CONFIG_64BIT_LLP64
CFLAGS += -DBITS_PER_LONG=32
Expand Down
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ $ fio
--max-jobs Maximum number of threads/processes to support
--server=args Start backend server. See Client/Server section.
--client=host Connect to specified backend.
--idle-prof=option Report cpu idleness on a system or percpu basis
(option=system,percpu) or run unit work
calibration only (option=calibrate).


Any parameters following the options will be assumed to be job files,
Expand Down
8 changes: 8 additions & 0 deletions backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "memalign.h"
#include "server.h"
#include "lib/getrusage.h"
#include "idletime.h"

static pthread_t disk_util_thread;
static struct fio_mutex *disk_thread_mutex;
Expand Down Expand Up @@ -1499,6 +1500,8 @@ static void run_threads(void)

if (fio_gtod_offload && fio_start_gtod_thread())
return;

fio_idle_prof_init();

set_sig_handlers();

Expand Down Expand Up @@ -1556,6 +1559,9 @@ static void run_threads(void)
}
}

/* start idle threads before io threads start to run */
fio_idle_prof_start();

set_genesis_time();

while (todo) {
Expand Down Expand Up @@ -1718,6 +1724,8 @@ static void run_threads(void)
usleep(10000);
}

fio_idle_prof_stop();

update_io_ticks();
fio_unpin_memory();
}
Expand Down
3 changes: 3 additions & 0 deletions fio.1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ Background a fio server, writing the pid to the given pid file.
.TP
.BI \-\-client \fR=\fPhost
Instead of running the jobs locally, send and run them on the given host.
.TP
.BI \-\-idle\-prof \fR=\fPoption
Report cpu idleness on a system or percpu basis (\fIoption\fP=system,percpu) or run unit work calibration only (\fIoption\fP=calibrate).
.SH "JOB FILE FORMAT"
Job files are in `ini' format. They consist of one or more
job definitions, which begin with a job name in square brackets and
Expand Down
Loading

0 comments on commit f2a2ce0

Please sign in to comment.