Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00C42C433F5 for ; Wed, 17 Nov 2021 06:54:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB25C61875 for ; Wed, 17 Nov 2021 06:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233983AbhKQG45 (ORCPT ); Wed, 17 Nov 2021 01:56:57 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:44933 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234008AbhKQG44 (ORCPT ); Wed, 17 Nov 2021 01:56:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1637132038; x=1668668038; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=k5CpW0YAKO975INV2cKBZcbyClbfR04bt//8jOxIX88=; b=KochdqR88qkUgV5BXiFHcHcgUPjeELNg6bS05GNxg39UUdOUWriV1Q/l ZAFXzeI8Iv3Yz7tWWqxSEcM6QzMWMnmTmp8CXNqb417G0uomn+/fi0t1b ySFO4e0AZ5OLqH5vWzLOcAwSEnikWsCBuSsdx9K5nxt6Sperk9CSPCMQv tmTp0OjyZsyKK2oc9FMfW1ken+dbNPTpbm9qgZuCbO0R9SsMJ7cZo77nM Jqm/2zL2gH67kb0aZJI7pv+eUbR2lzIpDByj6ZzzD4jj+XHGxN7wgpG6s JO/limr2rwJ611eK4Yo5McvXBZ/ZUEHg2X55pOOaibgnBS02xGhzos1rZ g==; X-IronPort-AV: E=Sophos;i="5.87,240,1631548800"; d="scan'208";a="289754312" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 17 Nov 2021 14:53:57 +0800 IronPort-SDR: lexOglXyCHw6MIPmgWoQ5w59b+fUsFewgwkkOeHYPFbjeYaPm/+PejoyBYKoETFGH+vXqxANcs 3j8l8uAbt2Uy5tupysHKnJVeeZF2DcWuocAexF3Ka56fmr5MGpn9taErXH5PAZp4FpnCMsrByj fQvY/ZqK6dbmBXPLDwTXlFlrq8lpglOk3sD+8tspCIqI7YLZh6I8ZyNk+qLAHO1P30++C9hxbt pGpErUhIPKJ/oXaVEUH5yw9ClXswfAqxYmlJzCdd6DSJb2tOaOF9jXsrpCj7zqnS57DdNLVQcK +vuKEoybjGzPGKq/HZoLlntd Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2021 22:28:59 -0800 IronPort-SDR: bzaPY2nQH8/qgW/Vk7ic0PyXqXN59b7dbjTWxzE6miQXll64ndoZfNMy24w+bDISdfy4tVbXXe sf2l81+pnm+dBzX/Yuj3yjL2DqdOSsgILZhxnPJ54qH3hwyuk32+lCG8fE01BKApwLqd/lvvib /EZ08n8IkCciS0G5FZEJkZFaYXEFO1zAeLA0y1J+TimFAowj2M5KVEiMIq+S/6zhk7H2jJEWJv oLYjnhhtw9OzKxCJY7F26XElZIxfEdfSXF2Cd7JbY2B9LOteGIZvknoTMiz1fkyo3IrAI7KEhs 0Qo= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2021 22:53:57 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HvDDN0W3dz1RtVn for ; Tue, 16 Nov 2021 22:53:56 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:x-mailer:message-id:date:subject:to:from; s=dkim; t=1637132035; x=1639724036; bh=k5CpW0YAKO975INV2cKBZcbyClbfR04b t//8jOxIX88=; b=JgklfbjQiD66Uezt0HZ7xC6e5WCwWDaZPWBCnlaUA+QHClfE wsE4tB7xhOIvu733Ag8UjRJTQ/DRMwJBm/pooaNCianusHhZ/tIMOnoaRVNtCart frx2ktSxNdcNqLMsVVNWo/xRlesTpc0HuriRNmCH1xOK6ZNJFxmgaSq494xWmLTl BdpwLoRVLfkp3LnMvG8j2pV4wko2ncQKe8fmoCwKWwU2BJX6jIZ34q5YJyfmlGFd 8leYr+nWM07h45BjUurUGOkJ0MsfMR04ywvSDr/sLILE5f7PEIA4Dj9fUZ4aMt0U lWefG7GBgH4D6Bkk75JU3XMrMrjYqb6XJOVyLw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id BZjXQu-W4sfG for ; Tue, 16 Nov 2021 22:53:55 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HvDDM05pxz1RtVl; Tue, 16 Nov 2021 22:53:54 -0800 (PST) From: Damien Le Moal To: fio@vger.kernel.org, Jens Axboe Subject: [PATCH] fio: Introduce the log_entries option Date: Wed, 17 Nov 2021 15:52:13 +0900 Message-Id: <20211117065213.124658-1-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: fio@vger.kernel.org When iops, latency, or bw logging options are used, fio will by default log information for any I/O that completes. The initial number of I/O log entries is 1024, as defined by (DEF_LOG_ENTRIES). When all log entries are used, new log entries are dynamically allocated by get_new_log(). This dynamic log entry allocation can negatively impact time-related statistics such as the I/O tail latencies (e.g. 99.9 percentile completion latency) as growing the logs causes a temporary I/O stall (IO quiesce), which disturbs the workload steady state. The effect of this is especially noticeable with workloads using IO priorities: the tail latencies of high priority I/Os increase if the IO log needs to be grown. For example, running the following fio command on a SATA disk supporting NCQ priority: fio --name=3Dprio-randread --filename=3D/dev/sdg \ --random_generator=3Dtausworthe64 --ioscheduler=3Dnone \ --write_lat_log=3Drandread.log --log_prio=3D1 --rw=3Drandread --bs=3D= 128k \ --ioengine=3Dlibaio --iodepth=3D32 --direct=3D1 --cmdprio_class=3D1 =C2= =A5 --cmdprio_percentage=3D30 --runtime=3D900 (128KB random read workload at QD=3D32 and 30% of commands issued with a high priority), with an inital number of log entries equal to the default of 1024, depending on the machine memory state, the completion latency statistics may show imprecise percentiles such as shown below. high prio (30.75%) clat percentiles (msec): | 1.00th=3D[ 14], 5.00th=3D[ 17], 10.00th=3D[ 20], 20.00th=3D[ = 23], | 30.00th=3D[ 27], 40.00th=3D[ 32], 50.00th=3D[ 40], 60.00th=3D[ = 53], | 70.00th=3D[ 71], 80.00th=3D[ 104], 90.00th=3D[ 169], 95.00th=3D[ = 243], | 99.00th=3D[ 514], 99.50th=3D[ 676], 99.90th=3D[ 1485], 99.95th=3D[ 1= 502], | 99.99th=3D[ 1552] low prio (69.25%) clat percentiles (msec): | 1.00th=3D[ 16], 5.00th=3D[ 24], 10.00th=3D[ 37], 20.00th=3D[ = 68], | 30.00th=3D[ 105], 40.00th=3D[ 146], 50.00th=3D[ 199], 60.00th=3D[ = 255], | 70.00th=3D[ 330], 80.00th=3D[ 439], 90.00th=3D[ 592], 95.00th=3D[ = 718], | 99.00th=3D[ 885], 99.50th=3D[ 986], 99.90th=3D[ 1469], 99.95th=3D[ 1= 536], | 99.99th=3D[ 1586] All completion latency percentiles above the 99.90th percentile are similar for the high and low priority commands, which is not consistent with the drive expected execution of prioritized read commands. To solve this issue and get more precise latency statistics, this patch introduces the new "log_entries" option to allow specifying a larger initial number of IO log entries to avoid run-time allocation. This option value defaults to DEF_LOG_ENTRIES and its maximum value is MAX_LOG_ENTRIES to be consistent with get_new_log() allocation. Also simplify get_new_log() by using calloc() instead of malloc, thus removing the need for the local variable new_size. Adding the "--log_entries=3D65536" option to the previous command line example, the completion latency results obtained are more stable: high prio (30.72%) clat percentiles (msec): | 1.00th=3D[ 15], 5.00th=3D[ 17], 10.00th=3D[ 19], 20.00th=3D[ = 22], | 30.00th=3D[ 24], 40.00th=3D[ 27], 50.00th=3D[ 32], 60.00th=3D[ = 36], | 70.00th=3D[ 46], 80.00th=3D[ 57], 90.00th=3D[ 81], 95.00th=3D[ = 105], | 99.00th=3D[ 161], 99.50th=3D[ 188], 99.90th=3D[ 271], 99.95th=3D[ = 275], | 99.99th=3D[ 363] low prio (69.28%) clat percentiles (msec): | 1.00th=3D[ 16], 5.00th=3D[ 27], 10.00th=3D[ 43], 20.00th=3D[ = 80], | 30.00th=3D[ 123], 40.00th=3D[ 176], 50.00th=3D[ 236], 60.00th=3D[ = 313], | 70.00th=3D[ 401], 80.00th=3D[ 506], 90.00th=3D[ 634], 95.00th=3D[ = 718], | 99.00th=3D[ 844], 99.50th=3D[ 885], 99.90th=3D[ 953], 99.95th=3D[ = 995], | 99.99th=3D[ 1053] All completion percentiles clearly now show shorter latencies for high priority commands, as expected. The 99.99th percentile for low prirotiy commands is also improved compared to the previous case as the measurements are not impacted by the log dynamic allocation. Suggested-by: Shin'ichiro Kawasaki Signed-off-by: Damien Le Moal --- HOWTO | 12 ++++++++++++ cconv.c | 2 ++ fio.1 | 11 +++++++++++ options.c | 12 ++++++++++++ server.h | 2 +- stat.c | 12 +++++------- thread_options.h | 2 ++ 7 files changed, 45 insertions(+), 8 deletions(-) diff --git a/HOWTO b/HOWTO index 196bca6c..a3b3acfe 100644 --- a/HOWTO +++ b/HOWTO @@ -3537,6 +3537,18 @@ Measurements and reporting :option:`write_bw_log` for details about the filename format and `Log File Formats`_ for how data is structured within the file. =20 +.. option:: log_entries=3Dint + + By default, fio will log an entry in the iops, latency, or bw log for + every I/O that completes. The initial number of I/O log entries is 1024= . + When the log entries are all used, new log entries are dynamically + allocated. This dynamic log entry allocation may negatively impact + time-related statistics such as I/O tail latencies (e.g. 99.9th percent= ile + completion latency). This option allows specifying a larger initial + number of log entries to avoid run-time allocations of new log entries, + resulting in more precise time-related I/O statistics. + Also see :option:`log_avg_msec`. Defaults to 1024. + .. option:: log_avg_msec=3Dint =20 By default, fio will log an entry in the iops, latency, or bw log for e= very diff --git a/cconv.c b/cconv.c index 2104308c..4f8d27eb 100644 --- a/cconv.c +++ b/cconv.c @@ -187,6 +187,7 @@ void convert_thread_options_to_cpu(struct thread_opti= ons *o, o->rand_repeatable =3D le32_to_cpu(top->rand_repeatable); o->allrand_repeatable =3D le32_to_cpu(top->allrand_repeatable); o->rand_seed =3D le64_to_cpu(top->rand_seed); + o->log_entries =3D le32_to_cpu(top->log_entries); o->log_avg_msec =3D le32_to_cpu(top->log_avg_msec); o->log_hist_msec =3D le32_to_cpu(top->log_hist_msec); o->log_hist_coarseness =3D le32_to_cpu(top->log_hist_coarseness); @@ -416,6 +417,7 @@ void convert_thread_options_to_net(struct thread_opti= ons_pack *top, top->rand_repeatable =3D cpu_to_le32(o->rand_repeatable); top->allrand_repeatable =3D cpu_to_le32(o->allrand_repeatable); top->rand_seed =3D __cpu_to_le64(o->rand_seed); + top->log_entries =3D cpu_to_le32(o->log_entries); top->log_avg_msec =3D cpu_to_le32(o->log_avg_msec); top->log_max =3D cpu_to_le32(o->log_max); top->log_offset =3D cpu_to_le32(o->log_offset); diff --git a/fio.1 b/fio.1 index e3c3feae..a6469541 100644 --- a/fio.1 +++ b/fio.1 @@ -3243,6 +3243,17 @@ logging (see \fBlog_avg_msec\fR) has been enabled.= See \fBwrite_bw_log\fR for details about the filename format and \fBLOG FILE FORMATS\fR for how data is structured within the file. .TP +.BI log_entries \fR=3D\fPint +By default, fio will log an entry in the iops, latency, or bw log for +every I/O that completes. The initial number of I/O log entries is 1024. +When the log entries are all used, new log entries are dynamically +allocated. This dynamic log entry allocation may negatively impact +time-related statistics such as I/O tail latencies (e.g. 99.9th percenti= le +completion latency). This option allows specifying a larger initial +number of log entries to avoid run-time allocation of new log entries, +resulting in more precise time-related I/O statistics. +Also see \fBlog_avg_msec\fR as well. Defaults to 1024. +.TP .BI log_avg_msec \fR=3D\fPint By default, fio will log an entry in the iops, latency, or bw log for ev= ery I/O that completes. When writing to the disk log, that can quickly grow = to a diff --git a/options.c b/options.c index 460cf4ff..102bcf56 100644 --- a/options.c +++ b/options.c @@ -4244,6 +4244,18 @@ struct fio_option fio_options[FIO_MAX_OPTS] =3D { .category =3D FIO_OPT_C_LOG, .group =3D FIO_OPT_G_INVALID, }, + { + .name =3D "log_entries", + .lname =3D "Log entries", + .type =3D FIO_OPT_INT, + .off1 =3D offsetof(struct thread_options, log_entries), + .help =3D "Initial number of entries in a job IO log", + .def =3D __fio_stringify(DEF_LOG_ENTRIES), + .minval =3D DEF_LOG_ENTRIES, + .maxval =3D MAX_LOG_ENTRIES, + .category =3D FIO_OPT_C_LOG, + .group =3D FIO_OPT_G_INVALID, + }, { .name =3D "log_avg_msec", .lname =3D "Log averaging (msec)", diff --git a/server.h b/server.h index 44b8da12..25b6bbdc 100644 --- a/server.h +++ b/server.h @@ -48,7 +48,7 @@ struct fio_net_cmd_reply { }; =20 enum { - FIO_SERVER_VER =3D 94, + FIO_SERVER_VER =3D 95, =20 FIO_SERVER_MAX_FRAGMENT_PDU =3D 1024, FIO_SERVER_MAX_CMD_MB =3D 2048, diff --git a/stat.c b/stat.c index cd35b114..e0dc99b6 100644 --- a/stat.c +++ b/stat.c @@ -2688,27 +2688,25 @@ static inline void add_stat_sample(struct io_stat= *is, unsigned long long data) */ static struct io_logs *get_new_log(struct io_log *iolog) { - size_t new_size, new_samples; + size_t new_samples; struct io_logs *cur_log; =20 /* * Cap the size at MAX_LOG_ENTRIES, so we don't keep doubling * forever */ - if (!iolog->cur_log_max) - new_samples =3D DEF_LOG_ENTRIES; - else { + if (!iolog->cur_log_max) { + new_samples =3D iolog->td->o.log_entries; + } else { new_samples =3D iolog->cur_log_max * 2; if (new_samples > MAX_LOG_ENTRIES) new_samples =3D MAX_LOG_ENTRIES; } =20 - new_size =3D new_samples * log_entry_sz(iolog); - cur_log =3D smalloc(sizeof(*cur_log)); if (cur_log) { INIT_FLIST_HEAD(&cur_log->list); - cur_log->log =3D malloc(new_size); + cur_log->log =3D calloc(new_samples, log_entry_sz(iolog)); if (cur_log->log) { cur_log->nr_samples =3D 0; cur_log->max_samples =3D new_samples; diff --git a/thread_options.h b/thread_options.h index 6e1a2cdd..8f4c8a59 100644 --- a/thread_options.h +++ b/thread_options.h @@ -377,6 +377,7 @@ struct thread_options { fio_fp64_t zrt; fio_fp64_t zrf; =20 + unsigned int log_entries; unsigned int log_prio; }; =20 @@ -683,6 +684,7 @@ struct thread_options_pack { int32_t max_open_zones; uint32_t ignore_zone_limits; =20 + uint32_t log_entries; uint32_t log_prio; } __attribute__((packed)); =20 --=20 2.31.1