Add tunable to allow changing micro ZAP's max size

This change turns `MZAP_MAX_BLKSZ` into a `ZFS_MODULE_PARAM()` called
`zap_micro_max_size`. As a result, we can experiment with different
micro ZAP sizes to improve directory size scaling.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Mateusz Piotrowski <mateuszpiotrowski@klarasystems.com>
Co-authored-by: Toomas Soome <toomas.soome@klarasystems.com>
Signed-off-by: Mateusz Piotrowski <mateuszpiotrowski@klarasystems.com>
Sponsored-by: Wasabi Technology, Inc.
Closes #14292
This commit is contained in:
Mateusz Piotrowski 2023-01-10 22:41:54 +01:00 committed by GitHub
parent 1f19826c9a
commit a4b21eadec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -15,7 +15,7 @@
.\" own identifying information: .\" own identifying information:
.\" Portions Copyright [yyyy] [name of copyright owner] .\" Portions Copyright [yyyy] [name of copyright owner]
.\" .\"
.Dd November 9, 2022 .Dd December 21, 2022
.Dt ZFS 4 .Dt ZFS 4
.Os .Os
. .
@ -496,6 +496,10 @@ prefetch the entire object (all leaf blocks).
However, this is limited by However, this is limited by
.Sy dmu_prefetch_max . .Sy dmu_prefetch_max .
. .
.It Sy zap_micro_max_size Ns = Ns Sy 131072 Ns B Po 128 KiB Pc Pq int
Maximum micro ZAP size.
A micro ZAP is upgraded to a fat ZAP, once it grows beyond the specified size.
.
.It Sy zfetch_array_rd_sz Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq u64 .It Sy zfetch_array_rd_sz Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq u64
If prefetching is enabled, disable prefetching for reads larger than this size. If prefetching is enabled, disable prefetching for reads larger than this size.
. .

View File

@ -465,6 +465,7 @@ dmu_tx_hold_zap_impl(dmu_tx_hold_t *txh, const char *name)
dmu_tx_t *tx = txh->txh_tx; dmu_tx_t *tx = txh->txh_tx;
dnode_t *dn = txh->txh_dnode; dnode_t *dn = txh->txh_dnode;
int err; int err;
extern int zap_micro_max_size;
ASSERT(tx->tx_txg == 0); ASSERT(tx->tx_txg == 0);
@ -480,7 +481,7 @@ dmu_tx_hold_zap_impl(dmu_tx_hold_t *txh, const char *name)
* - 2 grown ptrtbl blocks * - 2 grown ptrtbl blocks
*/ */
(void) zfs_refcount_add_many(&txh->txh_space_towrite, (void) zfs_refcount_add_many(&txh->txh_space_towrite,
MZAP_MAX_BLKSZ, FTAG); zap_micro_max_size, FTAG);
if (dn == NULL) if (dn == NULL)
return; return;

View File

@ -41,6 +41,8 @@
#include <sys/sunddi.h> #include <sys/sunddi.h>
#endif #endif
int zap_micro_max_size = MZAP_MAX_BLKSZ;
static int mzap_upgrade(zap_t **zapp, static int mzap_upgrade(zap_t **zapp,
const void *tag, dmu_tx_t *tx, zap_flags_t flags); const void *tag, dmu_tx_t *tx, zap_flags_t flags);
@ -568,7 +570,7 @@ zap_lockdir_impl(dmu_buf_t *db, const void *tag, dmu_tx_t *tx,
if (zap->zap_ismicro && tx && adding && if (zap->zap_ismicro && tx && adding &&
zap->zap_m.zap_num_entries == zap->zap_m.zap_num_chunks) { zap->zap_m.zap_num_entries == zap->zap_m.zap_num_chunks) {
uint64_t newsz = db->db_size + SPA_MINBLOCKSIZE; uint64_t newsz = db->db_size + SPA_MINBLOCKSIZE;
if (newsz > MZAP_MAX_BLKSZ) { if (newsz > zap_micro_max_size) {
dprintf("upgrading obj %llu: num_entries=%u\n", dprintf("upgrading obj %llu: num_entries=%u\n",
(u_longlong_t)obj, zap->zap_m.zap_num_entries); (u_longlong_t)obj, zap->zap_m.zap_num_entries);
*zapp = zap; *zapp = zap;
@ -1724,4 +1726,8 @@ EXPORT_SYMBOL(zap_cursor_advance);
EXPORT_SYMBOL(zap_cursor_serialize); EXPORT_SYMBOL(zap_cursor_serialize);
EXPORT_SYMBOL(zap_cursor_init_serialized); EXPORT_SYMBOL(zap_cursor_init_serialized);
EXPORT_SYMBOL(zap_get_stats); EXPORT_SYMBOL(zap_get_stats);
/* CSTYLED */
ZFS_MODULE_PARAM(zfs, , zap_micro_max_size, INT, ZMOD_RW,
"Maximum micro ZAP size, before converting to a fat ZAP, in bytes");
#endif #endif