diff options
author | alc <alc@FreeBSD.org> | 2003-05-13 04:36:02 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2003-05-13 04:36:02 +0000 |
commit | 0422418ef409d77459414f521175563ac8f3100f (patch) | |
tree | 64fabc395742fda6135861081668f303c073ca2e /sys/kern/vfs_subr.c | |
parent | 0d14921801d80ac047a0aed411cd3bb3916a3436 (diff) | |
download | FreeBSD-src-0422418ef409d77459414f521175563ac8f3100f.zip FreeBSD-src-0422418ef409d77459414f521175563ac8f3100f.tar.gz |
Optimize the use of splay in gbincore(). During a "make buildworld" the
desired buffer is found at one of the roots more than 60% of the time.
Thus, checking both roots before performing either splay eliminates
unnecessary splays on the first tree splayed.
Approved by: re (jhb)
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 66f7271..ae9ef7f 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1565,6 +1565,11 @@ buf_vlist_add(struct buf *bp, struct vnode *vp, b_xflags_t xflags) * * This code isn't quite efficient as it could be because we are maintaining * two sorted lists and do not know which list the block resides in. + * + * During a "make buildworld" the desired buffer is found at one of + * the roots more than 60% of the time. Thus, checking both roots + * before performing either splay eliminates unnecessary splays on the + * first tree splayed. */ struct buf * gbincore(struct vnode *vp, daddr_t lblkno) @@ -1574,13 +1579,23 @@ gbincore(struct vnode *vp, daddr_t lblkno) GIANT_REQUIRED; ASSERT_VI_LOCKED(vp, "gbincore"); - bp = vp->v_cleanblkroot = buf_splay(lblkno, 0, vp->v_cleanblkroot); - if (bp && bp->b_lblkno == lblkno && !(bp->b_xflags & BX_BKGRDMARKER)) - return(bp); - bp = vp->v_dirtyblkroot = buf_splay(lblkno, 0, vp->v_dirtyblkroot); - if (bp && bp->b_lblkno == lblkno && !(bp->b_xflags & BX_BKGRDMARKER)) - return(bp); - return(NULL); + if ((bp = vp->v_cleanblkroot) != NULL && + bp->b_lblkno == lblkno && !(bp->b_xflags & BX_BKGRDMARKER)) + return (bp); + if ((bp = vp->v_dirtyblkroot) != NULL && + bp->b_lblkno == lblkno && !(bp->b_xflags & BX_BKGRDMARKER)) + return (bp); + if ((bp = vp->v_cleanblkroot) != NULL) { + vp->v_cleanblkroot = bp = buf_splay(lblkno, 0, bp); + if (bp->b_lblkno == lblkno && !(bp->b_xflags & BX_BKGRDMARKER)) + return (bp); + } + if ((bp = vp->v_dirtyblkroot) != NULL) { + vp->v_dirtyblkroot = bp = buf_splay(lblkno, 0, bp); + if (bp->b_lblkno == lblkno && !(bp->b_xflags & BX_BKGRDMARKER)) + return (bp); + } + return (NULL); } /* |