diff options
| author | Alexander Motin <alexander.motin@TrueNAS.com> | 2025-12-18 18:22:11 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-18 18:22:11 +0000 |
| commit | 962e68865e4a569a8a51a07a45dcae7c33cdca78 (patch) | |
| tree | dc28261909f87994a2f96a538021956e4ce3bf8a | |
| parent | a83bb15fcd0c375a18efefcd11e356e1bb96c704 (diff) | |
Use reduced precision for scan timesvendor/openzfs/master
Scan time limits do not need precision beyond 1ms. Switching
scn_sync_start_time and spa_sync_starttime from gethrtime() to
getlrtime() saves ~3% of CPU time during resilver scan stage.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com>
Closes #18061
| -rw-r--r-- | module/zfs/dsl_scan.c | 26 | ||||
| -rw-r--r-- | module/zfs/spa.c | 2 | ||||
| -rw-r--r-- | module/zfs/spa_misc.c | 2 |
3 files changed, 15 insertions, 15 deletions
diff --git a/module/zfs/dsl_scan.c b/module/zfs/dsl_scan.c index 98bdf477162e..ae36161dd1b6 100644 --- a/module/zfs/dsl_scan.c +++ b/module/zfs/dsl_scan.c @@ -1669,7 +1669,7 @@ dsl_scan_check_suspend(dsl_scan_t *scn, const zbookmark_phys_t *zb) * or * - the scan queue has reached its memory use limit */ - uint64_t curr_time_ns = gethrtime(); + uint64_t curr_time_ns = getlrtime(); uint64_t scan_time_ns = curr_time_ns - scn->scn_sync_start_time; uint64_t sync_time_ns = curr_time_ns - scn->scn_dp->dp_spa->spa_sync_starttime; @@ -1731,7 +1731,7 @@ dsl_error_scrub_check_suspend(dsl_scan_t *scn, const zbookmark_phys_t *zb) * - the spa is shutting down because this pool is being exported * or the machine is rebooting. */ - uint64_t curr_time_ns = gethrtime(); + uint64_t curr_time_ns = getlrtime(); uint64_t error_scrub_time_ns = curr_time_ns - scn->scn_sync_start_time; uint64_t sync_time_ns = curr_time_ns - scn->scn_dp->dp_spa->spa_sync_starttime; @@ -3243,7 +3243,7 @@ static boolean_t scan_io_queue_check_suspend(dsl_scan_t *scn) { /* See comment in dsl_scan_check_suspend() */ - uint64_t curr_time_ns = gethrtime(); + uint64_t curr_time_ns = getlrtime(); uint64_t scan_time_ns = curr_time_ns - scn->scn_sync_start_time; uint64_t sync_time_ns = curr_time_ns - scn->scn_dp->dp_spa->spa_sync_starttime; @@ -3600,7 +3600,7 @@ dsl_scan_async_block_should_pause(dsl_scan_t *scn) return (B_TRUE); } - elapsed_nanosecs = gethrtime() - scn->scn_sync_start_time; + elapsed_nanosecs = getlrtime() - scn->scn_sync_start_time; return (elapsed_nanosecs / (NANOSEC / 2) > zfs_txg_timeout || (NSEC2MSEC(elapsed_nanosecs) > scn->scn_async_block_min_time_ms && txg_sync_waiting(scn->scn_dp)) || @@ -3887,7 +3887,7 @@ dsl_process_async_destroys(dsl_pool_t *dp, dmu_tx_t *tx) "free_bpobj/bptree on %s in txg %llu; err=%u", (longlong_t)scn->scn_visited_this_txg, (longlong_t) - NSEC2MSEC(gethrtime() - scn->scn_sync_start_time), + NSEC2MSEC(getlrtime() - scn->scn_sync_start_time), spa->spa_name, (longlong_t)tx->tx_txg, err); scn->scn_visited_this_txg = 0; scn->scn_async_frees_this_txg = 0; @@ -4218,14 +4218,14 @@ dsl_errorscrub_sync(dsl_pool_t *dp, dmu_tx_t *tx) } spa->spa_scrub_active = B_TRUE; - scn->scn_sync_start_time = gethrtime(); + scn->scn_sync_start_time = getlrtime(); /* * zfs_scan_suspend_progress can be set to disable scrub progress. * See more detailed comment in dsl_scan_sync(). */ if (zfs_scan_suspend_progress) { - uint64_t scan_time_ns = gethrtime() - scn->scn_sync_start_time; + uint64_t scan_time_ns = getlrtime() - scn->scn_sync_start_time; int mintime = zfs_scrub_min_time_ms; while (zfs_scan_suspend_progress && @@ -4233,7 +4233,7 @@ dsl_errorscrub_sync(dsl_pool_t *dp, dmu_tx_t *tx) !spa_shutting_down(scn->scn_dp->dp_spa) && NSEC2MSEC(scan_time_ns) < mintime) { delay(hz); - scan_time_ns = gethrtime() - scn->scn_sync_start_time; + scan_time_ns = getlrtime() - scn->scn_sync_start_time; } return; } @@ -4443,7 +4443,7 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx) scn->scn_avg_zio_size_this_txg = 0; scn->scn_zios_this_txg = 0; scn->scn_suspending = B_FALSE; - scn->scn_sync_start_time = gethrtime(); + scn->scn_sync_start_time = getlrtime(); spa->spa_scrub_active = B_TRUE; /* @@ -4467,7 +4467,7 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx) * useful for testing and debugging. */ if (zfs_scan_suspend_progress) { - uint64_t scan_time_ns = gethrtime() - scn->scn_sync_start_time; + uint64_t scan_time_ns = getlrtime() - scn->scn_sync_start_time; uint_t mintime = (scn->scn_phys.scn_func == POOL_SCAN_RESILVER) ? zfs_resilver_min_time_ms : zfs_scrub_min_time_ms; @@ -4477,7 +4477,7 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx) !spa_shutting_down(scn->scn_dp->dp_spa) && NSEC2MSEC(scan_time_ns) < mintime) { delay(hz); - scan_time_ns = gethrtime() - scn->scn_sync_start_time; + scan_time_ns = getlrtime() - scn->scn_sync_start_time; } return; } @@ -4607,7 +4607,7 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx) "%llu in ddt, %llu > maxtxg)", (longlong_t)scn->scn_visited_this_txg, spa->spa_name, - (longlong_t)NSEC2MSEC(gethrtime() - + (longlong_t)NSEC2MSEC(getlrtime() - scn->scn_sync_start_time), (longlong_t)scn->scn_objsets_visited_this_txg, (longlong_t)scn->scn_holes_this_txg, @@ -4648,7 +4648,7 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx) (longlong_t)scn->scn_zios_this_txg, spa->spa_name, (longlong_t)scn->scn_segs_this_txg, - (longlong_t)NSEC2MSEC(gethrtime() - + (longlong_t)NSEC2MSEC(getlrtime() - scn->scn_sync_start_time), (longlong_t)scn->scn_avg_zio_size_this_txg, (longlong_t)scn->scn_avg_seg_size_this_txg); diff --git a/module/zfs/spa.c b/module/zfs/spa.c index c481070e1f2d..b9924d33cd65 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -10449,7 +10449,7 @@ spa_sync(spa_t *spa, uint64_t txg) dsl_pool_t *dp = spa->spa_dsl_pool; dmu_tx_t *tx = dmu_tx_create_assigned(dp, txg); - spa->spa_sync_starttime = gethrtime(); + spa->spa_sync_starttime = getlrtime(); taskq_cancel_id(system_delay_taskq, spa->spa_deadman_tqid, B_TRUE); spa->spa_deadman_tqid = taskq_dispatch_delay(system_delay_taskq, diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index bf22d2eb68e7..aee170e9ea51 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -720,7 +720,7 @@ spa_deadman(void *arg) return; zfs_dbgmsg("slow spa_sync: started %llu seconds ago, calls %llu", - (gethrtime() - spa->spa_sync_starttime) / NANOSEC, + (getlrtime() - spa->spa_sync_starttime) / NANOSEC, (u_longlong_t)++spa->spa_deadman_calls); if (zfs_deadman_enabled) vdev_deadman(spa->spa_root_vdev, FTAG); |
