Skip to content

Commit

Permalink
Maximize txg size to improve throughput
Browse files Browse the repository at this point in the history
Only quiesce new transaction group when previous syncing is
getting close to completion, so that quiescing completed just
in time for it. That's the time when previous txg's dirty size
shrinks to about 5% of dp_dirty_total. (current txg takes 95%
of dp_dirty_total)

Some other style fixes regarding code review.

Signed-off-by: jxdking <[email protected]>
  • Loading branch information
jxdking committed May 13, 2021
1 parent 184f4cd commit e474b3a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
3 changes: 1 addition & 2 deletions module/zfs/dmu_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1056,9 +1056,8 @@ dmu_tx_assign(dmu_tx_t *tx, uint64_t txg_how)

txg_rele_to_quiesce(&tx->tx_txgh);

if (dsl_pool_need_dirty_sync(tx->tx_pool, tx->tx_txg)) {
if (dsl_pool_need_dirty_sync(tx->tx_pool, tx->tx_txg))
txg_kick(tx->tx_pool, tx->tx_txg);
}
return (0);
}

Expand Down
17 changes: 12 additions & 5 deletions module/zfs/dsl_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,9 @@ dsl_pool_need_dirty_delay(dsl_pool_t *dp)
{
uint64_t delay_min_bytes =
zfs_dirty_data_max * zfs_delay_min_dirty_percent / 100;
uint64_t dirty;

mutex_enter(&dp->dp_lock);
dirty = dp->dp_dirty_total;
uint64_t dirty = dp->dp_dirty_total;
mutex_exit(&dp->dp_lock);

return (dirty > delay_min_bytes);
Expand All @@ -911,15 +910,23 @@ dsl_pool_need_dirty_delay(dsl_pool_t *dp)
boolean_t
dsl_pool_need_dirty_sync(dsl_pool_t *dp, uint64_t txg)
{
uint64_t dirty;
uint64_t dirty_min_bytes =
zfs_dirty_data_max * zfs_dirty_data_sync_percent / 100;

mutex_enter(&dp->dp_lock);
dirty = dp->dp_dirty_pertxg[txg & TXG_MASK];
uint64_t dirty = dp->dp_dirty_pertxg[txg & TXG_MASK];
uint64_t total = dp->dp_dirty_total;
mutex_exit(&dp->dp_lock);

return (dirty > dirty_min_bytes);
/*
* Only quiesce new transaction group when previous syncing is
* getting close to completion, so that quiescing completed just
* in time for it. That's the time when previous txg's dirty size
* shrinks to about 5% of dp_dirty_total (current txg takes 95%
* of dp_dirty_total)
*/
return (dirty > dirty_min_bytes &&
dirty * 100 > total * 95);
}

void
Expand Down
3 changes: 2 additions & 1 deletion module/zfs/txg.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ txg_wait_open(dsl_pool_t *dp, uint64_t txg, boolean_t should_quiesce)
* If there isn't a txg quiescing in the pipeline, push the txg
* through the pipeline by quiescing the open txg.
* It is fine there is a txg still syncing.
* Pass in the txg number of the transaction that should be closed and synced.
*/
void
txg_kick(dsl_pool_t *dp, uint64_t txg)
Expand All @@ -788,7 +789,7 @@ txg_kick(dsl_pool_t *dp, uint64_t txg)
ASSERT(!dsl_pool_config_held(dp));

mutex_enter(&tx->tx_sync_lock);
txg = txg == 0 ? tx->tx_open_txg : txg;
txg = (txg == 0 ? tx->tx_open_txg : txg);
if (txg == tx->tx_open_txg &&
!txg_is_quiescing(dp) &&
tx->tx_quiesce_txg_waiting <= tx->tx_open_txg &&
Expand Down

0 comments on commit e474b3a

Please sign in to comment.