From: Jens Axboe Date: Mon, 26 Feb 2007 11:28:58 +0000 (+0100) Subject: Speedup init_disk_util() when dealing with many jobs X-Git-Tag: fio-1.12~8 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=c0a6b0d8fcf07512fad42ba16613da83ceec4475;ds=sidebyside Speedup init_disk_util() when dealing with many jobs sysfs lookups can take quite a while, so check against last device to avoid having to iterate through sysfs again. Signed-off-by: Jens Axboe --- diff --git a/stat.c b/stat.c index 34b2b6a5..a8f2b026 100644 --- a/stat.c +++ b/stat.c @@ -11,6 +11,7 @@ static struct itimerval itimer; static struct list_head disk_list = LIST_HEAD_INIT(disk_list); +static dev_t last_dev; /* * Cheasy number->string conversion, complete with carry rounding error. @@ -273,6 +274,17 @@ void init_disk_util(struct thread_data *td) if (disk_util_exists(dev)) return; + + /* + * for an fs without a device, we will repeatedly stat through + * sysfs which can take oodles of time for thousands of files. so + * cache the last lookup and compare with that before going through + * everything again. + */ + if (dev == last_dev) + return; + + last_dev = dev; sprintf(foo, "/sys/block"); if (!find_block_dir(dev, foo))