[DragonFlyBSD - Submit #2783] (New) [PATCH 0/2] sbin/hammer: add get_ondisk() and cleanups

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Wed Feb 4 11:06:07 PST 2015


Issue #2783 has been reported by tkusumi.

----------------------------------------
Submit #2783: [PATCH 0/2] sbin/hammer: add get_ondisk() and cleanups
http://bugs.dragonflybsd.org/issues/2783

* Author: tkusumi
* Status: New
* Priority: Normal
* Assignee: 
* Category: Userland
* Target version: 
----------------------------------------
These patches do followings.

---
>From 91164be29025acef50289e3b3ee26544a95e91c4 Mon Sep 17 00:00:00 2001
Date: Wed, 4 Feb 2015 05:31:46 +0900
Subject: [PATCH 1/2] sbin/hammer: add get_ondisk()

- Cleanup get_buffer_data() and get_node() using a new inline function
  get_ondisk(). These two look different but actually do the same thing
  except for the way they release an existing buffer (--ref and
  eventually free it). Using get_ondisk() makes the code clear.

- get_ondisk_data() frees an existing non-NULL buffer when isnew or
  the offset is out of 16KB range of the cached data. get_node() frees
  an existing buffer for btree node whenever the buffer is non-NULL.
  They both do the same thing after this.
---
 sbin/hammer/ondisk.c | 47 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 33 insertions(+), 14 deletions(-)

---
>From 7ce4695ffdc02bbd13e9070f06d06c6f026e9c58 Mon Sep 17 00:00:00 2001
Date: Wed, 4 Feb 2015 05:35:56 +0900
Subject: [PATCH 2/2] sbin/hammer: cleanups

- Minor cleanups to make get_buffer_data() and get_node() look the same.
  As explained in the previous patch these two are very similar and it's
  better if the code look similar as well.

- hunk1 - no need to dereference indirect pointer **bufferp via direct
  pointer *buffer in here anymore.

- hunk2 - all the rest of the code use **bufferp instead of **bufp.
---
 sbin/hammer/ondisk.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)



---
Quick check using gprof to see # of allocation/free against the same
hammer storage haven't changed, which indicates possible logical change
if the # were different.

--------
1. hammer blockmap (read the whole blockmap)

- master compiled with -pg
# ./hammer -f /dev/ad1:/dev/ad2:/dev/ad3 blockmap > out1
# gprof ./hammer ./hammer.gmon > hammer.gprof
# grep get_buffer hammer.gprof | grep "^\[[0-9]\+"
[4]     96.0    0.00  601.53 1835008         get_buffer_data [4]
[5]     90.9    0.00  569.08    2048+4099    get_buffer [5]
# grep rel_buffer hammer.gprof | grep "^\[[0-9]\+"
[10]    19.5    0.00  121.87    7686         rel_buffer [10]
# grep malloc hammer.gprof | grep "^\[[0-9]\+"
[26]     0.0    0.00    0.16    4191         malloc [26]
# grep free hammer.gprof | grep "^\[[0-9]\+"
[8]     19.5    0.00  121.91    3079         free [8]
[9]     19.5    0.00  121.91    3079+1540    _slabfree [9]
[655]    0.0    0.00    0.00    1540         _vmem_free [655]

- this patch compiled with -pg
# ./hammer -f /dev/ad1:/dev/ad2:/dev/ad3 blockmap > out2
# gprof ./hammer ./hammer.gmon > hammer.gprof
# grep get_buffer hammer.gprof | grep "^\[[0-9]\+"
[5]     51.9    0.00  293.67 1835008         get_buffer_data [5]
[6]     51.9    0.00  293.67    2048+4099    get_buffer [6]
# grep rel_buffer hammer.gprof | grep "^\[[0-9]\+"
[30]     0.0    0.00    0.00    7686         rel_buffer [30]
# grep malloc hammer.gprof | grep "^\[[0-9]\+"
[33]     0.0    0.00    0.00    4191         malloc [33]
# grep free hammer.gprof | grep "^\[[0-9]\+"
[34]     0.0    0.00    0.00    3079         free [34]
[647]    0.0    0.00    0.00    3079+1540    _slabfree [647]
[651]    0.0    0.00    0.00    1540         _vmem_free [651]

- compare output
# diff ./out1 ./out2
#

--------
2. hammer show (read the whole filesystem btree nodes)

- master compiled with -pg
# ./hammer -f /dev/ad1:/dev/ad2:/dev/ad3 show > out1
# gprof ./hammer ./hammer.gmon > hammer.gprof
# grep get_buffer hammer.gprof | grep "^\[[0-9]\+"
[7]     61.9    0.00  584.42 1470091+111572  get_buffer <cycle 1> [7]
[28]     1.5    0.00   14.64 1462516         get_buffer_data <cycle 1> [28]
# grep rel_buffer hammer.gprof | grep "^\[[0-9]\+"
[24]     4.2    0.01   40.00 1646814         rel_buffer [24]
# grep malloc hammer.gprof | grep "^\[[0-9]\+"
[22]    19.5    0.00  183.76  132125         malloc [22]
# grep free hammer.gprof | grep "^\[[0-9]\+"
[25]     4.2    0.00   39.99  130303         free [25]
[26]     4.2    0.02   39.98  130303+65152   _slabfree [26]
[655]    0.0    0.00    0.00   65152         _vmem_free [655]

- this patch compiled with -pg
# ./hammer -f /dev/ad1:/dev/ad2:/dev/ad3 show > out2
# gprof ./hammer ./hammer.gmon > hammer.gprof
# grep get_buffer hammer.gprof | grep "^\[[0-9]\+"
[7]     48.1    0.02  526.25 1470091+111572  get_buffer <cycle 1> [7]
[24]    13.3    0.01  145.37 1462516         get_buffer_data <cycle 1> [24]
# grep rel_buffer hammer.gprof | grep "^\[[0-9]\+"
[12]    36.3    0.00  397.27 1646814         rel_buffer [12]
# grep malloc hammer.gprof | grep "^\[[0-9]\+"
[38]     0.0    0.00    0.01  132125         malloc [38]
# grep free hammer.gprof | grep "^\[[0-9]\+"
[10]    36.3    0.00  397.27  130303         free [10]
[11]    36.3    0.01  397.26  130303+65152   _slabfree [11]
[655]    0.0    0.00    0.00   65152         _vmem_free [655]

- compare output
# diff ./out1 ./out2
#


---Files--------------------------------
0001-sbin-hammer-add-get_ondisk.patch (3.25 KB)
0002-sbin-hammer-cleanups.patch (2.02 KB)


-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account



More information about the Submit mailing list