Skip to content

Commit

Permalink
Decouple arc_read_done callback from arc buf instantiation
Browse files Browse the repository at this point in the history
Add ARC_FLAG_NO_BUF to indicate that a buffer need not be
instantiated.  This fixes a ~20% performance regression on
cached reads due to zfetch changes.

Reviewed-by: Tony Nguyen <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Matthew Ahrens <[email protected]>
Signed-off-by: Matt Macy <[email protected]>
Closes #11220 
Closes #11232
  • Loading branch information
mattmacy authored Dec 9, 2020
1 parent edb20ff commit 1e4732c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions include/sys/arc.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ typedef enum arc_flags
*/
ARC_FLAG_CACHED_ONLY = 1 << 22,

/*
* Don't instantiate an arc_buf_t for arc_read_done.
*/
ARC_FLAG_NO_BUF = 1 << 23,

/*
* The arc buffer's compression mode is stored in the top 7 bits of the
* flags field, so these dummy flags are included so that MDB can
Expand Down
5 changes: 3 additions & 2 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5924,6 +5924,7 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
boolean_t noauth_read = BP_IS_AUTHENTICATED(bp) &&
(zio_flags & ZIO_FLAG_RAW_ENCRYPT) != 0;
boolean_t embedded_bp = !!BP_IS_EMBEDDED(bp);
boolean_t no_buf = *arc_flags & ARC_FLAG_NO_BUF;
int rc = 0;

ASSERT(!embedded_bp ||
Expand Down Expand Up @@ -5998,7 +5999,7 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
}
ASSERT(*arc_flags & ARC_FLAG_NOWAIT);

if (done) {
if (done && !no_buf) {
arc_callback_t *acb = NULL;

acb = kmem_zalloc(sizeof (arc_callback_t),
Expand Down Expand Up @@ -6027,7 +6028,7 @@ arc_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
ASSERT(hdr->b_l1hdr.b_state == arc_mru ||
hdr->b_l1hdr.b_state == arc_mfu);

if (done) {
if (done && !no_buf) {
if (hdr->b_flags & ARC_FLAG_PREDICTIVE_PREFETCH) {
/*
* This is a demand read which does not have to
Expand Down
3 changes: 2 additions & 1 deletion module/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3040,7 +3040,8 @@ dbuf_issue_final_prefetch(dbuf_prefetch_arg_t *dpa, blkptr_t *bp)

int zio_flags = ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE;
arc_flags_t aflags =
dpa->dpa_aflags | ARC_FLAG_NOWAIT | ARC_FLAG_PREFETCH;
dpa->dpa_aflags | ARC_FLAG_NOWAIT | ARC_FLAG_PREFETCH |
ARC_FLAG_NO_BUF;

/* dnodes are always read as raw and then converted later */
if (BP_GET_TYPE(bp) == DMU_OT_DNODE && BP_IS_PROTECTED(bp) &&
Expand Down

0 comments on commit 1e4732c

Please sign in to comment.