First Look at ZFS Deduplication

ZFS Deduplication was recently putback (Sun terminology for “commit”) to ON (Solaris’s primary codebase). That means it should go out at snv_128 (Build 128) due later this week.

Unable to wait for the BFU archives I resorted to actually building the code myself to play; something I’ve not felt the burning need to do for at least 2 years (I’ll blog about that shortly). Here’s the initial review…

In typical fashion putting ZFS Dedup to work is a trivial task. Zpools are created in the normal way, the dedup feature is enabled on a per-dataset basis and therefore is a simple matter of turning it on:

root@quadra ~$ zpool create stick c4t0d0
root@quadra ~$ zpool get all stick
NAME   PROPERTY       VALUE       SOURCE
stick  size           3.75G       -
stick  capacity       0%          -
stick  altroot        -           default
stick  health         ONLINE      -
stick  guid           12142487970365036186  default
stick  version        21          default
stick  bootfs         -           default
stick  delegation     on          default
stick  autoreplace    off         default
stick  cachefile      -           default
stick  failmode       wait        default
stick  listsnapshots  off         default
stick  autoexpand     off         default
stick  dedupratio     1.00x       -
stick  free           3.75G       -
stick  allocated      76.5K       -

Notice that there is no option to enable dedup for the pool, however there is a read-only “dedupratio” key. Because ZFS properties are inherited by child datasets we’ll enable dedup on the root dataset, in this case “stick”:

root@quadra ~$ zfs set dedup=on stick

Done! That’s it. Really, you’re done! Stop reading this now. :)

… ok, maybe I’ll go into it a bit more.

As with many ZFS Dataset Properties, there can be more than one setting. The default value of the “dedup” properties is “off”. It can also be set to “on”, “sha256″, “verify”, or “fletcher4,verify”. “on” is simply a pseudonym for “sha256″. “verify” is a pseudonym for “sha256,verify” and enables an ability to detect and correct hash collisions, however this is very system intensive and is not recommended for casual use, if you require absolute integrity at all costs, go for it, but test your workload first. Phrases like “hash collision” can cause a panic, but remember that the odds are astronomical. For details on this see Jeff Bonwick’s post on ZFS Dedup.

So, now for some testing. I’ve created my “stick” pool on a new 4GB micro-USB stick and enabled dedup. Lets copy in a bunch of JPEG’s to several directories and see what happens:

root@quadra ~$ zfs list stick
NAME    USED  AVAIL  REFER  MOUNTPOINT
stick  73.5K  3.69G    21K  /stick
root@quadra ~$ mkdir /stick/userA
root@quadra ~$ mkdir /stick/userB
root@quadra ~$ mkdir /stick/userC
root@quadra ~$ cd img
root@quadra img$ time cp * /stick/userA
real    0m15.395s
user    0m0.005s
sys     0m0.174s
root@quadra img$ time cp * /stick/userB
real    0m15.952s
user    0m0.004s
sys     0m0.112s
root@quadra img$ time cp * /stick/userC
real    0m2.347s
user    0m0.004s
sys     0m0.125s

root@quadra img$ zfs list stick
NAME    USED  AVAIL  REFER  MOUNTPOINT
stick   203M  3.62G   203M  /stick

root@quadra img$ cd /stick/userA/
root@quadra userA$ du -sh .
74M     .

OK, notice that I’m copying in 74MB of data, 3 times, each to a different directory. (Its slow because its a crappy USB stick.) If we run du it registers the proper size, if we look at zfs list it shows the full size of 203MB. In fact, if I look at the dataset properties I have no indication at all of its on-disk size:

root@quadra userA$ zfs get all stick
NAME   PROPERTY              VALUE                  SOURCE
stick  type                  filesystem             -
stick  creation              Tue Nov 10  0:07 2009  -
stick  used                  220M                   -
stick  available             3.62G                  -
stick  referenced            220M                   -
stick  compressratio         1.00x                  -
stick  mounted               yes                    -
stick  quota                 none                   default
stick  reservation           none                   default
...

So here’s the magic… look at the pool size:

root@quadra ~$ zpool list stick
NAME    SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
stick  3.75G  72.5M  3.68G     1%  3.06x  ONLINE  -

Beautiful. 72.5MB allocated and we correctly see the dedup ratio of 3 (less than the file sizes, leading me to believe there are some duplicate images, which I don’t doubt).

Yet again, ZFS makes it “just work”. And you don’t need a big huge expensive peice of gear, I’m deduping on this:

Suck it Data Domain. :)

For the elite ZFS Internals hackers out there, you can get a closer look at dedup using zdb -S (thanks to Jeff Victor for the tip):

root@quadra ~$ zdb -S stick
Simulated DDT histogram:

bucket              allocated                       referenced
______   ______________________________   ______________________________
refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE
------   ------   -----   -----   -----   ------   -----   -----   -----
     2      623   69.9M   69.9M   69.9M    1.83K    210M    210M    210M
     4       14   1.63M   1.63M   1.63M       84    9.8M    9.8M    9.8M
 Total      637   71.5M   71.5M   71.5M    1.91K    219M    219M    219M

dedup = 3.07, compress = 1.00, copies = 1.00, dedup * compress / copies = 3.07

So now its time to really beat on this thing and see if and where it breaks. Dedup for the masses is coming in the mail!!!

82 Responses to “First Look at ZFS Deduplication”

  1. Dmitry Sorokin says:

    Nice!
    Now, whet happens with zfs send | zfs receive? Does it send deduped blocks only or undeduped as usual? Would be very nice to know.

    Thanks for a great posts,
    Dmitry

  2. Derek Morr says:

    Ben, nice post.

    Dmitry, zfs send/receive dedup was recent integrated. See http://www.c0t0d0s0.org/archives/6096-ZFS-send-dedup-integrated-in-Opensolaris.html

  3. Alan Pae says:

    Do you have the ZFS version # for this?

  4. Thank you very much. I am wonderring if I can share your article in the bookmarks of society,Then more friends can talk about this problem.

  5. Dmitry Sorokin says:

    Derek, thanks for the reference.
    Interesting way of implementing ZFS dedupe in the send/receive streams. I’m not too sure how useful that is however, if I understand the concept correctly.
    Let’s take Ben’s example:
    1. copy set of files to ZFS data set with dedupe enabled, then take a snapshot A.
    2. zfs send -D | zfs receive the set based on snapshot A
    3. copy the same set of files to different subdirectory and take snapshot B
    4. zfs send -I -D | zfs receive the A to B delta
    5. copy the same set of files to yet another different subdirectory and take snapshot C
    6. zfs send -I -D | zfs receive the B to C delta

    If I understand the current implementation of ZFS dedupe for send/receive streams, every time the snapshot delta is sent, the full size will be sent, as oppose to really sending nothing, as the data was seeded originally in step 2. Doesn’t really help with replication over WAN. Why not keep metadata for every checksummed block and really send over only blocks that don’t exist at the remote end?
    This approach is much better and scalable, as oppose to deduplicating only blocks within one stream.
    Again, I might misinterpreted the info, but that’s the way I understood it.
    Anyone can confirm what’s really happening?

    Thanks,
    Dmitry

  6. zfscurious says:

    I’m curious as to why the cp in step 2 took as long as the cp in step 1? The data was already there, so I would have expected step 2 and 3 to take a similar amount of time.

  7. Nick Matyas says:

    So, nice your posting. It look’s so good in your posting. It is useful for all.

    http://www.webroyalty.com

  8. The sale of fake Gucci shoes is now a common event. But, the online shopping platform adds a fresh layer of deception. Individuals buying the fashionable shoes do not understand that the products they are buying are fake.

  9. ecco shoes says:

    competitive price ,high quality and beautiful designecco shoes

  10. Individuals buying the fashionable shoes do not understand that the products they are buying are fake.

  11. Just want to tell you that your blog is like having a whole banana split for dessert – fantastical.

  12. HaleyMartina says:

    Buildings are not cheap and not everybody can buy it. Nevertheless, credit loans are invented to support people in such situations.

  13. Plantar fasciitis or inflammation of the plantar fascia comes about when the plantar fascia suffers microscopic tears at the point where it joins to the heel bone, or along its length.

  14. johndiny says:

    Interesting post!!!!

  15. high quality http://www.sunglasses-mall.com/oakley-sunglasses-c-80.html” rel=”nofollow”>oakley sunglasses wholesale

  16. p90x says:

    P90x .It really is not expensive if you factor in the cost

    of a gym membership,P90x workout . The cost for P90X is

    about three months of a paid gym membership but you get to

    keep the program foreverP90x . You can try many of the

    online sites, but it will be the same as buying from the

    company or a Beachbody Coach. Make sure you are getting

    original DVD’s. People are selling copies all over. The

    problem is how long will they last, P90x workout ,and you

    truly need the exercise and nutrition guide to even follow

    the program. You can go to any site or you can go to

    http://www.p90xmall.com and click on products. P90x dvd You can

    order directly from the site,P90x dvd.

  17. Ed hardy says:

    Thanks for article. Everytime like to read you.http://www.edhardyau.com/

  18. If I understand the current implementation of ZFS dedupe for send/receive streams, every time the snapshot delta is sent, the full size will be sent, as oppose to really sending nothing, as the data was seeded originally in step 2

  19. Ugg Boots UK says:

    I really love your website, it’s so useful, i’m just sharing for my friends!welcome to my web http://www.uggretailers.org

  20. Please trust us. Choose us! spider man costume.We will bring you more exciting zentai unitard and better service.The site is http://zentaistore.co.uk

  21. Muska says:

    Please trust us. Choose us! spider man costume.We will bring you more exciting zentai unitard and better service.T

  22. Ugg Schoenen says:

    Thanks for the great post today! http://www.uggofficial.nl

  23. I really love your website, it’s so useful, i’m just baking a cake for my aunt! http://www.uggtall.com

  24. Classic uggs says:

    I enjoyed to be at here because one of my point has been cleared here. http://www.uggsonline.us

  25. Many thanks for sharing this, very useful! http://www.donedhardy.name

  26. I am glad to post my views and points in this blog. http://www.abercrombieofficial.org

  27. Ugg Boots UK says:

    I just found your site and wanted to say that I have really enjoyed browsing your posts. Welcome to our website: http://www.uggretailers.org

  28. The black blush ofUgg Classic Short (5825) favourite style ugg boot has been all year rotund.The UGG Boots’ sheepskin is one of some styles that while your wearing sheepskin, it’s automatically regulating your body temperature throughout The Ugg Classic Cardy delicate woolen sheepskin breathes, wicking section and creates a female devise silhouette. And it is an obviously thermostatic matter. This means that have been photographed on many celebrities and wetness away to keep your feet dry and at body temperature within, and out. Because of Merino hide greater which wicks damp away.

  29. bed bug bite says:

    I too enjoyed to be at here because one of my point has been cleared here. [ http://www.bedbugsbully.com/ bed bug bite ] [ http://www.plantar-fasciitistreatment.com/ plantar fasciitis cure ]

  30. Ideally before starting a half marathon program, you should have been training for about six months.

  31. I am glad I found it informative so Site has been added to my RSS feed for later browsing. bicycle shoes
    http://www.triathlonshoes.org

  32. I believe this blog post is one of the most informative thing not only for the technique learner but also for necessary for all stage people.

  33. UGG Schuhe says:

    Pretty good post. I just found your site and wanted to say that I have really enjoyed browsing your posts. http://www.uggofficial.de

  34. Nike Shoes, nike dunks, Nike air jordan ,Nike Shox Nike Air Rift, nike sneakers, Nike Air Force One, jordan shoes, Nike Air MaxShop authentic Nike Air Force One / 1 Shoes, including Nike Air Force 1 Premium, Nike Air Force 1 Supreme, Nike Air Force 1 Mid and ike Air Force 1 low. http://www.iofferitems.com

  35. Acai Berry says:

    This is one of the best posts that I’ve ever seen; you may include some more ideas in the same theme. I’m still waiting for some interesting thoughts from your side in your next post.

  36. MBT shoes says:

    MBT shoes is the original online trading platform of MBT shoes. From http://www.mbt-mbt-shoe.com you not only can find various

    different styles fashion MBT shoe makeup but also can get the products earlier and faster. We stock everything we sell. No one can make delivery to you quicker than us, much

    more than this, we offer you the most reasonable price. Also, our online support is the best. It is our aim to treat our customers with our best service!

  37. samyibiz says:

    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com
    Christian audiger:http://www.samyibiz.com

  38. This is one of the best posts that I’ve anytime seen; you may accommodate some added account in the aforementioned theme. I’m still cat-and-mouse for some absorbing thoughts from your ancillary in your abutting post.

  39. hgddgh says:

    http://www.ugg5498.com/
    welcome to ugg5498.com !

    You’ve found the world’s most comfortable ugg boots. The thicker merino sheepskin used in our ugg boots cools your toes in summer and warms in winter to produce a supremely comfortable 22 degree constant temperature. Unlike other footwear, ugg boots are made from a natural insulator. Constantly circulating air prevents heat exchange keeping you comfortable regardless of the temperature. With thicker sheepskin we offer greater insulation, comfort and strength.

    welcome to visit our website,you will have a wonderful business trip~~~!!!

  40. ghhf says:

    http://www.ugg4ok.com/
    As we all known, UGG Australia Boots are legendary. 100% pure Australia lambs wool used in all our foot wear products. But 2010 summer UGG Sandals more pop as well as ugg boots in winter. Our ugg sandals sale provides series of women & men UGG Sandals Collection:UGG Sandals 1759 Gypsy, UGG Sandals Halendi, UGG Tasmina Braid Sandals all you want to be found at our online store.

    “High quality, Best service” is our pursuit. Fashion design & High quality UGG Sandals 2010 Sale for customers. Top Services and Latest Fashion Information are from Ugg Sandals Sale Online Store. Buy Ugg Sandals from ugg4ok enjoy Fast shipping! The exclusive Ugg Sandal is worthy of own.

  41. hao123 says:

    http://www.ugg4womens.com/
    A series of fashion UGG boots items diversified latest designs here: UGG Bailey Button boots, UGG Classic Cardy Boot, UGG Classic Crochet Boots and so on. It’s perfect for your breathable comfort. And a great chance for you to buy your favorite UGG boots! The UGG will create curiosity and interest for your colourful life when you experience them yourself. Exquisite design and high quality are very perfect for any occasions. Take it if you like it. There are numerous listings of UGG boots for sale here. May you have a wonderful business trip!

  42. cool stuff says:

    very cool article ,thanks for sharing the article!like my cool stuff .very useful.
    uCoolStuff is the leading China wholesaler for http://www.ucoolstuff.com cool stuff http://www.ucoolstuff.com cool gifts , unusual gadgets and other unique gift ideas. We provide the very latest cool stuff and cool gifts for you

  43. Top Online Stores is a SEO Friendly http://www.toponlinestores.org free directory where you can find the best online shopping stores selected by hand and sorted by http://www.china-wholesale-directory.com china wholesale category.

  44. “First Look at ZFS Deduplication” is one of my favorite post. Its also informative information that helpful for newbie. :)

  45. Great blog posts here,I like so much.

  46. It is also one of my favorite post. Its also helpful for newbie. :)

  47. Excellent post. I like this post for its importance. So this site has been added to my RSS feed for later browsing.

  48. Nice! Now I know what to do, thank you! And as this information is educational so this site has been added to my RSS feed for later browsing. To know more about
    marathon training visit: http://www.marathontrainingschedule.net
    [ running training program ]

  49. This is one of the best blogs I’ve ever read. You’ve got some mad skill here. I just hope that you dont lose your style because youre definitely one of the coolest bloggers out there. Please keep it up because the internet needs someone like you spreading the word.

  50. It is really good,I must say!

  51. Really, it is trustworthy blog.. It have also informative information. Thanks for the post and assimilation in adequate others.

  52. Medical Debt says:

    Really trustworthy blog entry I have ever found.. Its also informative information. Thank you for the post and assimilation in adequate others…..

  53. Really trustworthy blog entry I have ever found.. Its also informative information. Thank you for the post and assimilation in adequate others…..

  54. Really trustworthy blog entry I have ever found.. Its also informative information. Thank you for the post and assimilation in adequate others…..http://www.accidentinjurylawyerblog.com/maryland” rel=”nofollow”>Serious injury lawyers

  55. tory burch says:

    Well, you mention here things that really made me think.

  56. Thank you, I have recently been searching for information about this topic for ages and yours is the best I have discovered so far.

  57. This was a really impressive Topics!I was fortunate to find your blog ,Also I got much in your subject, really thank you very much .

  58. so good to get more informed on this and again ,thanks !

  59. I agree with totally ,please write more .

  60. tory burch shoes sale says:

    best information ,i like.

  61. tory burch wholesale says:

    i appreciate your viewpoint.that is great!

  62. tory burch shoes says:

    thanks !! very helpful post!

  63. tory burch shoes sale says:

    This is a great story. Thanks!

  64. tory burch says:

    As a Newbie, I am always searching online for articles that can help me. Thank you.

  65. tory burch shoes sale says:

    Great articles & Nice a site….

  66. tory burch sale says:

    Great site,A lot of useful information here .GOOD!

  67. tory burch says:

    Keep working ,great job!

  68. tory burch flats says:

    the article is usefully,excellent!

  69. tory burch boots says:

    Thank you for wonderful blog post .

  70. tory burch wholesale says:

    ohhh nice info VRy interesting to read it .

  71. tory burch flats says:

    Such a usefule blog…wow !!!!

  72. ugg boots says:

    Every people work hard to earn money to live a good life.me too.As a guys of ugg australia.I want to tell people that more about info from inner of Ugg Australia marketing department.the profit of one pair of ugg boots is very high!if you cost 300 USD to buy a Ugg lady boots,in fact,the most of cost is only about 60-100 usd.So what is the best way to get a “ugly boots” in a lowest price? The right answer is get it from a http://www.ugg-official-website.com ,this is a only one online shop who get right of selling genuine ugg boots from Ugg Australia. But this site is not know by lots of people,becoz it is only face to inner worker of company.Now I come here and share it with every one who want to have a genuine ugg boots in a lower price than buy from shop.

    The most cold winter is coming this years.Go and own a Ugg boots to keep our foots warm.Let us have a wonderful time in this winter ! Go for 1 pair now -> http://www.ugg-official-website.com

  73. tory burch shoes says:

    thanks !! very helpful post! amazing stuff thanx.