From 465e4e795ee3cbdc5de862b26d81b2f1116733df Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Thu, 13 Feb 2020 14:20:42 -0500 Subject: Remove duplicate dbufs accounting Since AVL already has embedded element counter, use dn_dbufs_count only for dbufs not counted there (bonus buffers) and just add them. This removes two atomics per dbuf life cycle. According to profiler it reduces time spent by dbuf_destroy() inside bottlenecked dbuf_evict_thread() from 13.36% to 9.20% of the core. Reviewed-by: Brian Behlendorf Reviewed-by: Matt Ahrens Signed-off-by: Alexander Motin Sponsored-By: iXsystems, Inc. Closes #9949 --- include/sys/dnode.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/sys') diff --git a/include/sys/dnode.h b/include/sys/dnode.h index 5e9d070e2..708e5fc44 100644 --- a/include/sys/dnode.h +++ b/include/sys/dnode.h @@ -372,6 +372,13 @@ struct dnode { struct zfetch dn_zfetch; }; +/* + * Since AVL already has embedded element counter, use dn_dbufs_count + * only for dbufs not counted there (bonus buffers) and just add them. + */ +#define DN_DBUFS_COUNT(dn) ((dn)->dn_dbufs_count + \ + avl_numnodes(&(dn)->dn_dbufs)) + /* * We use this (otherwise unused) bit to indicate if the value of * dn_next_maxblkid[txgoff] is valid to use in dnode_sync(). -- cgit v1.2.3