mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work 1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync read, sync write, async read, async write, and scrub/resilver. The scheduler issues a number of concurrent i/os from each class to the device. Once a class has been selected, an i/o is selected from this class using either an elevator algorithem (async, scrub classes) or FIFO (sync classes). The number of concurrent async write i/os is tuned dynamically based on i/o load, to achieve good sync i/o latency when there is not a high load of writes, and good write throughput when there is. See the block comment in vdev_queue.c (reproduced below) for more details. 2. The write throttle (dsl_pool_tempreserve_space() and txg_constrain_throughput()) is rewritten to produce much more consistent delays when under constant load. The new write throttle is based on the amount of dirty data, rather than guesses about future performance of the system. When there is a lot of dirty data, each transaction (e.g. write() syscall) will be delayed by the same small amount. This eliminates the "brick wall of wait" that the old write throttle could hit, causing all transactions to wait several seconds until the next txg opens. One of the keys to the new write throttle is decrementing the amount of dirty data as i/o completes, rather than at the end of spa_sync(). Note that the write throttle is only applied once the i/o scheduler is issuing the maximum number of outstanding async writes. See the block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for more details. This diff has several other effects, including: * the commonly-tuned global variable zfs_vdev_max_pending has been removed; use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead. * the size of each txg (meaning the amount of dirty data written, and thus the time it takes to write out) is now controlled differently. There is no longer an explicit time goal; the primary determinant is amount of dirty data. Systems that are under light or medium load will now often see that a txg is always syncing, but the impact to performance (e.g. read latency) is minimal. Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this. * zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression, checksum, etc. This improves latency by not allowing these CPU-intensive tasks to consume all CPU (on machines with at least 4 CPU's; the percentage is rounded up). --matt APPENDIX: problems with the current i/o scheduler The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem with this is that if there are always i/os pending, then certain classes of i/os can see very long delays. For example, if there are always synchronous reads outstanding, then no async writes will be serviced until they become "past due". One symptom of this situation is that each pass of the txg sync takes at least several seconds (typically 3 seconds). If many i/os become "past due" (their deadline is in the past), then we must service all of these overdue i/os before any new i/os. This happens when we enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in the future. If we can't complete all the i/os in 2.5 seconds (e.g. because there were always reads pending), then these i/os will become past due. Now we must service all the "async" writes (which could be hundreds of megabytes) before we service any reads, introducing considerable latency to synchronous i/os (reads or ZIL writes). Notes on porting to ZFS on Linux: - zio_t gained new members io_physdone and io_phys_children. Because object caches in the Linux port call the constructor only once at allocation time, objects may contain residual data when retrieved from the cache. Therefore zio_create() was updated to zero out the two new fields. - vdev_mirror_pending() relied on the depth of the per-vdev pending queue (vq->vq_pending_tree) to select the least-busy leaf vdev to read from. This tree has been replaced by vq->vq_active_tree which is now used for the same purpose. - vdev_queue_init() used the value of zfs_vdev_max_pending to determine the number of vdev I/O buffers to pre-allocate. That global no longer exists, so we instead use the sum of the *_max_active values for each of the five I/O classes described above. - The Illumos implementation of dmu_tx_delay() delays a transaction by sleeping in condition variable embedded in the thread (curthread->t_delay_cv). We do not have an equivalent CV to use in Linux, so this change replaced the delay logic with a wrapper called zfs_sleep_until(). This wrapper could be adopted upstream and in other downstream ports to abstract away operating system-specific delay logic. - These tunables are added as module parameters, and descriptions added to the zfs-module-parameters.5 man page. spa_asize_inflation zfs_deadman_synctime_ms zfs_vdev_max_active zfs_vdev_async_write_active_min_dirty_percent zfs_vdev_async_write_active_max_dirty_percent zfs_vdev_async_read_max_active zfs_vdev_async_read_min_active zfs_vdev_async_write_max_active zfs_vdev_async_write_min_active zfs_vdev_scrub_max_active zfs_vdev_scrub_min_active zfs_vdev_sync_read_max_active zfs_vdev_sync_read_min_active zfs_vdev_sync_write_max_active zfs_vdev_sync_write_min_active zfs_dirty_data_max_percent zfs_delay_min_dirty_percent zfs_dirty_data_max_max_percent zfs_dirty_data_max zfs_dirty_data_max_max zfs_dirty_data_sync zfs_delay_scale The latter four have type unsigned long, whereas they are uint64_t in Illumos. This accommodates Linux's module_param() supported types, but means they may overflow on 32-bit architectures. The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most likely to overflow on 32-bit systems, since they express physical RAM sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to 2^32 which does overflow. To resolve that, this port instead initializes it in arc_init() to 25% of physical RAM, and adds the tunable zfs_dirty_data_max_max_percent to override that percentage. While this solution doesn't completely avoid the overflow issue, it should be a reasonable default for most systems, and the minority of affected systems can work around the issue by overriding the defaults. - Fixed reversed logic in comment above zfs_delay_scale declaration. - Clarified comments in vdev_queue.c regarding when per-queue minimums take effect. - Replaced dmu_tx_write_limit in the dmu_tx kstat file with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts how many times a transaction has been delayed because the pool dirty data has exceeded zfs_delay_min_dirty_percent. The latter counts how many times the pool dirty data has exceeded zfs_dirty_data_max (which we expect to never happen). - The original patch would have regressed the bug fixed in zfsonlinux/zfs@c418410, which prevented users from setting the zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE. A similar fix is added to vdev_queue_aggregate(). - In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the heap instead of the stack. In Linux we can't afford such large structures on the stack. Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Christopher Siden <christopher.siden@delphix.com> Reviewed by: Ned Bass <bass6@llnl.gov> Reviewed by: Brendan Gregg <brendan.gregg@joyent.com> Approved by: Robert Mustacchi <rm@joyent.com> References: http://www.illumos.org/issues/4045 illumos/illumos-gate@69962b5647 Ported-by: Ned Bass <bass6@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1913
This commit is contained in:
committed by
Brian Behlendorf
parent
384f8a09f8
commit
e8b96c6007
+473
-124
@@ -156,6 +156,22 @@ SPA config file
|
||||
Default value: \fB/etc/zfs/zpool.cache\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBspa_asize_inflation\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Multiplication factor used to estimate actual disk consumption from the
|
||||
size of data being written. The default value is a worst case estimate,
|
||||
but lower values may be valid for a given pool depending on its
|
||||
configuration. Pool administrators who understand the factors involved
|
||||
may wish to specify a more realistic inflation factor, particularly if
|
||||
they operate close to quota or capacity limits.
|
||||
.sp
|
||||
Default value: 24
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
@@ -335,12 +351,17 @@ Use \fB1\fR for yes (default) and \fB0\fR to disable.
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_deadman_synctime\fR (ulong)
|
||||
\fBzfs_deadman_synctime_ms\fR (ulong)
|
||||
.ad
|
||||
.RS 12n
|
||||
Expire in units of zfs_txg_synctime_ms
|
||||
Expiration time in milliseconds. This value has two meanings. First it is
|
||||
used to determine when the spa_deadman() logic should fire. By default the
|
||||
spa_deadman() will fire if spa_sync() has not completed in 1000 seconds.
|
||||
Secondly, the value determines if an I/O is considered "hung". Any I/O that
|
||||
has not completed in zfs_deadman_synctime_ms is considered "hung" resulting
|
||||
in a zevent being logged.
|
||||
.sp
|
||||
Default value: \fB1,000\fR.
|
||||
Default value: \fB1,000,000\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
@@ -354,6 +375,272 @@ Enable prefetching dedup-ed blks
|
||||
Use \fB1\fR for yes (default) and \fB0\fR to disable.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_delay_min_dirty_percent\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Start to delay each transaction once there is this amount of dirty data,
|
||||
expressed as a percentage of \fBzfs_dirty_data_max\fR.
|
||||
This value should be >= zfs_vdev_async_write_active_max_dirty_percent.
|
||||
See the section "ZFS TRANSACTION DELAY".
|
||||
.sp
|
||||
Default value: \fB60\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_delay_scale\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
This controls how quickly the transaction delay approaches infinity.
|
||||
Larger values cause longer delays for a given amount of dirty data.
|
||||
.sp
|
||||
For the smoothest delay, this value should be about 1 billion divided
|
||||
by the maximum number of operations per second. This will smoothly
|
||||
handle between 10x and 1/10th this number.
|
||||
.sp
|
||||
See the section "ZFS TRANSACTION DELAY".
|
||||
.sp
|
||||
Note: \fBzfs_delay_scale\fR * \fBzfs_dirty_data_max\fR must be < 2^64.
|
||||
.sp
|
||||
Default value: \fB500,000\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_dirty_data_max\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Determines the dirty space limit in bytes. Once this limit is exceeded, new
|
||||
writes are halted until space frees up. This parameter takes precedence
|
||||
over \fBzfs_dirty_data_max_percent\fR.
|
||||
See the section "ZFS TRANSACTION DELAY".
|
||||
.sp
|
||||
Default value: 10 percent of all memory, capped at \fBzfs_dirty_data_max_max\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_dirty_data_max_max\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Maximum allowable value of \fBzfs_dirty_data_max\fR, expressed in bytes.
|
||||
This limit is only enforced at module load time, and will be ignored if
|
||||
\fBzfs_dirty_data_max\fR is later changed. This parameter takes
|
||||
precedence over \fBzfs_dirty_data_max_max_percent\fR. See the section
|
||||
"ZFS TRANSACTION DELAY".
|
||||
.sp
|
||||
Default value: 25% of physical RAM.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_dirty_data_max_max_percent\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Maximum allowable value of \fBzfs_dirty_data_max\fR, expressed as a
|
||||
percentage of physical RAM. This limit is only enforced at module load
|
||||
time, and will be ignored if \fBzfs_dirty_data_max\fR is later changed.
|
||||
The parameter \fBzfs_dirty_data_max_max\fR takes precedence over this
|
||||
one. See the section "ZFS TRANSACTION DELAY".
|
||||
.sp
|
||||
Default value: 25
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_dirty_data_max_percent\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Determines the dirty space limit, expressed as a percentage of all
|
||||
memory. Once this limit is exceeded, new writes are halted until space frees
|
||||
up. The parameter \fBzfs_dirty_data_max\fR takes precedence over this
|
||||
one. See the section "ZFS TRANSACTION DELAY".
|
||||
.sp
|
||||
Default value: 10%, subject to \fBzfs_dirty_data_max_max\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_dirty_data_sync\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Start syncing out a transaction group if there is at least this much dirty data.
|
||||
.sp
|
||||
Default value: \fB67,108,864\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_async_read_max_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Maxium asynchronous read I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB3\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_async_read_min_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Minimum asynchronous read I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB1\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_async_write_active_max_dirty_percent\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
When the pool has more than
|
||||
\fBzfs_vdev_async_write_active_max_dirty_percent\fR dirty data, use
|
||||
\fBzfs_vdev_async_write_max_active\fR to limit active async writes. If
|
||||
the dirty data is between min and max, the active I/O limit is linearly
|
||||
interpolated. See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB60\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_async_write_active_min_dirty_percent\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
When the pool has less than
|
||||
\fBzfs_vdev_async_write_active_min_dirty_percent\fR dirty data, use
|
||||
\fBzfs_vdev_async_write_min_active\fR to limit active async writes. If
|
||||
the dirty data is between min and max, the active I/O limit is linearly
|
||||
interpolated. See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB30\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_async_write_max_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Maxium asynchronous write I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB10\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_async_write_min_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Minimum asynchronous write I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB1\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_max_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
The maximum number of I/Os active to each device. Ideally, this will be >=
|
||||
the sum of each queue's max_active. It must be at least the sum of each
|
||||
queue's min_active. See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB1,000\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_scrub_max_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Maxium scrub I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB2\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_scrub_min_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Minimum scrub I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB1\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_sync_read_max_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Maxium synchronous read I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB10\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_sync_read_min_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Minimum synchronous read I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB10\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_sync_write_max_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Maxium synchronous write I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB10\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_sync_write_min_active\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Minimum synchronous write I/Os active to each device.
|
||||
See the section "ZFS I/O SCHEDULER".
|
||||
.sp
|
||||
Default value: \fB10\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
@@ -442,17 +729,6 @@ Set for no scrub prefetching
|
||||
Use \fB1\fR for yes and \fB0\fR for no (default).
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_no_write_throttle\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Disable write throttling
|
||||
.sp
|
||||
Use \fB1\fR for yes and \fB0\fR for no (default).
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
@@ -652,17 +928,6 @@ Historic statistics for the last N txgs
|
||||
Default value: \fB0\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_txg_synctime_ms\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Target milliseconds between txg sync
|
||||
.sp
|
||||
Default value: \fB1,000\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
@@ -716,28 +981,6 @@ Total size of the per-disk cache
|
||||
Default value: \fB0\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_max_pending\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Max pending per-vdev I/Os
|
||||
.sp
|
||||
Default value: \fB10\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_min_pending\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Min pending per-vdev I/Os
|
||||
.sp
|
||||
Default value: \fB4\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
@@ -749,17 +992,6 @@ Switch mirrors every N usecs
|
||||
Default value: \fB10,000\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_ramp_rate\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Exponential I/O issue ramp-up rate
|
||||
.sp
|
||||
Default value: \fB2\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
@@ -782,17 +1014,6 @@ I/O scheduler
|
||||
Default value: \fBnoop\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_vdev_time_shift\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
Deadline time shift for vdev I/O
|
||||
.sp
|
||||
Default value: \fB29\fR (each bucket is 0.537 seconds).
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
@@ -804,61 +1025,6 @@ Aggregate write I/O over gap
|
||||
Default value: \fB4,096\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_write_limit_inflated\fR (ulong)
|
||||
.ad
|
||||
.RS 12n
|
||||
Inflated txg write limit
|
||||
.sp
|
||||
Default value: \fB0\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_write_limit_max\fR (ulong)
|
||||
.ad
|
||||
.RS 12n
|
||||
Max txg write limit
|
||||
.sp
|
||||
Default value: \fB0\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_write_limit_min\fR (ulong)
|
||||
.ad
|
||||
.RS 12n
|
||||
Min txg write limit
|
||||
.sp
|
||||
Default value: \fB33,554,432\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_write_limit_override\fR (ulong)
|
||||
.ad
|
||||
.RS 12n
|
||||
Override txg write limit
|
||||
.sp
|
||||
Default value: \fB0\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
\fBzfs_write_limit_shift\fR (int)
|
||||
.ad
|
||||
.RS 12n
|
||||
log2(fraction of memory) per txg
|
||||
.sp
|
||||
Default value: \fB3\fR.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.na
|
||||
@@ -1002,3 +1168,186 @@ Number of threads for zvol device
|
||||
Default value: \fB32\fR.
|
||||
.RE
|
||||
|
||||
.SH ZFS I/O SCHEDULER
|
||||
ZFS issues I/O operations to leaf vdevs to satisfy and complete I/Os.
|
||||
The I/O scheduler determines when and in what order those operations are
|
||||
issued. The I/O scheduler divides operations into five I/O classes
|
||||
prioritized in the following order: sync read, sync write, async read,
|
||||
async write, and scrub/resilver. Each queue defines the minimum and
|
||||
maximum number of concurrent operations that may be issued to the
|
||||
device. In addition, the device has an aggregate maximum,
|
||||
\fBzfs_vdev_max_active\fR. Note that the sum of the per-queue minimums
|
||||
must not exceed the aggregate maximum. If the sum of the per-queue
|
||||
maximums exceeds the aggregate maximum, then the number of active I/Os
|
||||
may reach \fBzfs_vdev_max_active\fR, in which case no further I/Os will
|
||||
be issued regardless of whether all per-queue minimums have been met.
|
||||
.sp
|
||||
For many physical devices, throughput increases with the number of
|
||||
concurrent operations, but latency typically suffers. Further, physical
|
||||
devices typically have a limit at which more concurrent operations have no
|
||||
effect on throughput or can actually cause it to decrease.
|
||||
.sp
|
||||
The scheduler selects the next operation to issue by first looking for an
|
||||
I/O class whose minimum has not been satisfied. Once all are satisfied and
|
||||
the aggregate maximum has not been hit, the scheduler looks for classes
|
||||
whose maximum has not been satisfied. Iteration through the I/O classes is
|
||||
done in the order specified above. No further operations are issued if the
|
||||
aggregate maximum number of concurrent operations has been hit or if there
|
||||
are no operations queued for an I/O class that has not hit its maximum.
|
||||
Every time an I/O is queued or an operation completes, the I/O scheduler
|
||||
looks for new operations to issue.
|
||||
.sp
|
||||
In general, smaller max_active's will lead to lower latency of synchronous
|
||||
operations. Larger max_active's may lead to higher overall throughput,
|
||||
depending on underlying storage.
|
||||
.sp
|
||||
The ratio of the queues' max_actives determines the balance of performance
|
||||
between reads, writes, and scrubs. E.g., increasing
|
||||
\fBzfs_vdev_scrub_max_active\fR will cause the scrub or resilver to complete
|
||||
more quickly, but reads and writes to have higher latency and lower throughput.
|
||||
.sp
|
||||
All I/O classes have a fixed maximum number of outstanding operations
|
||||
except for the async write class. Asynchronous writes represent the data
|
||||
that is committed to stable storage during the syncing stage for
|
||||
transaction groups. Transaction groups enter the syncing state
|
||||
periodically so the number of queued async writes will quickly burst up
|
||||
and then bleed down to zero. Rather than servicing them as quickly as
|
||||
possible, the I/O scheduler changes the maximum number of active async
|
||||
write I/Os according to the amount of dirty data in the pool. Since
|
||||
both throughput and latency typically increase with the number of
|
||||
concurrent operations issued to physical devices, reducing the
|
||||
burstiness in the number of concurrent operations also stabilizes the
|
||||
response time of operations from other -- and in particular synchronous
|
||||
-- queues. In broad strokes, the I/O scheduler will issue more
|
||||
concurrent operations from the async write queue as there's more dirty
|
||||
data in the pool.
|
||||
.sp
|
||||
Async Writes
|
||||
.sp
|
||||
The number of concurrent operations issued for the async write I/O class
|
||||
follows a piece-wise linear function defined by a few adjustable points.
|
||||
.nf
|
||||
|
||||
| o---------| <-- zfs_vdev_async_write_max_active
|
||||
^ | /^ |
|
||||
| | / | |
|
||||
active | / | |
|
||||
I/O | / | |
|
||||
count | / | |
|
||||
| / | |
|
||||
|-------o | | <-- zfs_vdev_async_write_min_active
|
||||
0|_______^______|_________|
|
||||
0% | | 100% of zfs_dirty_data_max
|
||||
| |
|
||||
| `-- zfs_vdev_async_write_active_max_dirty_percent
|
||||
`--------- zfs_vdev_async_write_active_min_dirty_percent
|
||||
|
||||
.fi
|
||||
Until the amount of dirty data exceeds a minimum percentage of the dirty
|
||||
data allowed in the pool, the I/O scheduler will limit the number of
|
||||
concurrent operations to the minimum. As that threshold is crossed, the
|
||||
number of concurrent operations issued increases linearly to the maximum at
|
||||
the specified maximum percentage of the dirty data allowed in the pool.
|
||||
.sp
|
||||
Ideally, the amount of dirty data on a busy pool will stay in the sloped
|
||||
part of the function between \fBzfs_vdev_async_write_active_min_dirty_percent\fR
|
||||
and \fBzfs_vdev_async_write_active_max_dirty_percent\fR. If it exceeds the
|
||||
maximum percentage, this indicates that the rate of incoming data is
|
||||
greater than the rate that the backend storage can handle. In this case, we
|
||||
must further throttle incoming writes, as described in the next section.
|
||||
|
||||
.SH ZFS TRANSACTION DELAY
|
||||
We delay transactions when we've determined that the backend storage
|
||||
isn't able to accommodate the rate of incoming writes.
|
||||
.sp
|
||||
If there is already a transaction waiting, we delay relative to when
|
||||
that transaction will finish waiting. This way the calculated delay time
|
||||
is independent of the number of threads concurrently executing
|
||||
transactions.
|
||||
.sp
|
||||
If we are the only waiter, wait relative to when the transaction
|
||||
started, rather than the current time. This credits the transaction for
|
||||
"time already served", e.g. reading indirect blocks.
|
||||
.sp
|
||||
The minimum time for a transaction to take is calculated as:
|
||||
.nf
|
||||
min_time = zfs_delay_scale * (dirty - min) / (max - dirty)
|
||||
min_time is then capped at 100 milliseconds.
|
||||
.fi
|
||||
.sp
|
||||
The delay has two degrees of freedom that can be adjusted via tunables. The
|
||||
percentage of dirty data at which we start to delay is defined by
|
||||
\fBzfs_delay_min_dirty_percent\fR. This should typically be at or above
|
||||
\fBzfs_vdev_async_write_active_max_dirty_percent\fR so that we only start to
|
||||
delay after writing at full speed has failed to keep up with the incoming write
|
||||
rate. The scale of the curve is defined by \fBzfs_delay_scale\fR. Roughly speaking,
|
||||
this variable determines the amount of delay at the midpoint of the curve.
|
||||
.sp
|
||||
.nf
|
||||
delay
|
||||
10ms +-------------------------------------------------------------*+
|
||||
| *|
|
||||
9ms + *+
|
||||
| *|
|
||||
8ms + *+
|
||||
| * |
|
||||
7ms + * +
|
||||
| * |
|
||||
6ms + * +
|
||||
| * |
|
||||
5ms + * +
|
||||
| * |
|
||||
4ms + * +
|
||||
| * |
|
||||
3ms + * +
|
||||
| * |
|
||||
2ms + (midpoint) * +
|
||||
| | ** |
|
||||
1ms + v *** +
|
||||
| zfs_delay_scale ----------> ******** |
|
||||
0 +-------------------------------------*********----------------+
|
||||
0% <- zfs_dirty_data_max -> 100%
|
||||
.fi
|
||||
.sp
|
||||
Note that since the delay is added to the outstanding time remaining on the
|
||||
most recent transaction, the delay is effectively the inverse of IOPS.
|
||||
Here the midpoint of 500us translates to 2000 IOPS. The shape of the curve
|
||||
was chosen such that small changes in the amount of accumulated dirty data
|
||||
in the first 3/4 of the curve yield relatively small differences in the
|
||||
amount of delay.
|
||||
.sp
|
||||
The effects can be easier to understand when the amount of delay is
|
||||
represented on a log scale:
|
||||
.sp
|
||||
.nf
|
||||
delay
|
||||
100ms +-------------------------------------------------------------++
|
||||
+ +
|
||||
| |
|
||||
+ *+
|
||||
10ms + *+
|
||||
+ ** +
|
||||
| (midpoint) ** |
|
||||
+ | ** +
|
||||
1ms + v **** +
|
||||
+ zfs_delay_scale ----------> ***** +
|
||||
| **** |
|
||||
+ **** +
|
||||
100us + ** +
|
||||
+ * +
|
||||
| * |
|
||||
+ * +
|
||||
10us + * +
|
||||
+ +
|
||||
| |
|
||||
+ +
|
||||
+--------------------------------------------------------------+
|
||||
0% <- zfs_dirty_data_max -> 100%
|
||||
.fi
|
||||
.sp
|
||||
Note here that only as the amount of dirty data approaches its limit does
|
||||
the delay start to increase rapidly. The goal of a properly tuned system
|
||||
should be to keep the amount of dirty data out of that range by first
|
||||
ensuring that the appropriate limits are set for the I/O scheduler to reach
|
||||
optimal throughput on the backend storage, and then by changing the value
|
||||
of \fBzfs_delay_scale\fR to increase the steepness of the curve.
|
||||
|
||||
Reference in New Issue
Block a user