First Look at ZFS Deduplication

10 Nov '09 - 09:57 by benr

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!!!


- - C O M M E N T S - -

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

Dmitry Sorokin (Email) - 10 November '09 - 14:27

Ben, nice post.

Dmitry, zfs send/receive dedup was recent integrated. See [[http://www.c0t0d0s0.org/archives/6096-..]]

Derek Morr (Email) (URL) - 10 November '09 - 14:40

Do you have the ZFS version # for this?

Alan Pae (Email) (URL) - 10 November '09 - 20:52

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.

true religion jeans (Email) (URL) - 11 November '09 - 09:10

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

Dmitry Sorokin (Email) - 11 November '09 - 18:09

Great post! Hope to be better. Better means more features.
good post,I think so!
Thanks for your information, i have read it, very good!
Bing is a really overlord!! support Bing~~
This is great news. Best of luck for the future and keep up the good work.

links of london (Email) (URL) - 17 November '09 - 03:18

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.

zfscurious - 14 December '09 - 23:34

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

christian louboutin shoes (Email) (URL) - 18 December '09 - 07:47

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

[[http://www.webroyalty.com]]

Nick Matyas (Email) (URL) - 03 January '10 - 12:31

top quality ecco shoes

ecco shoes (Email) (URL) - 17 January '10 - 10:19

[[http://www.buykamagra.com]] buy kamagra
[[http://www.viagracialis.com]] viagra cialis

M65 Jacket (Email) (URL) - 21 January '10 - 02:38

good post

abercrombie clothing (Email) (URL) - 22 January '10 - 08:33

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.

gucci women shoes (Email) (URL) - 23 January '10 - 03:52

Your article is very useful!Thank you for sharing.Nice post.

Tiffany Accessories (Email) (URL) - 08 February '10 - 08:45

competitive price ,high quality and beautiful designecco shoes

ecco shoes (Email) (URL) - 09 February '10 - 13:05

Ed Hardy Hats were later launched with much fanfare.

ed hardy (Email) (URL) - 25 February '10 - 03:40

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

links of london (Email) (URL) - 11 March '10 - 01:42

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

abercrombie milano (Email) (URL) - 18 March '10 - 02:52

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

HaleyMartina (Email) (URL) - 27 March '10 - 03:41

I just wanted to say thank you for the laughs and keep up the great work!

manolo blahnik store (Email) (URL) - 31 March '10 - 11:11

[[http://www.mobilershop.com]]
[[http://www.beautycasa.com]]

cell phone (Email) (URL) - 12 April '10 - 05:57

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.

best plantar fasciitis treatment (Email) (URL) - 22 April '10 - 05:15

I very intersted in the article

cheap mbt shoes (Email) (URL) - 23 April '10 - 03:25

Interesting post!!!!

johndiny (Email) (URL) - 25 April '10 - 17:18

sale christian louboutin shoes [[http://www.salelouboutins.com]]

louboutin shoe (Email) (URL) - 30 April '10 - 01:09

shop louboutin shoes from [[http://www.salelouboutins.com]]

louboutins shoes (Email) (URL) - 30 April '10 - 01:19

high quality oakley sunglasses wholesale

oakley sunglasses wholesale (Email) (URL) - 04 May '10 - 09:32

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.

p90x (Email) (URL) - 05 May '10 - 05:46

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

Ed hardy (Email) (URL) - 08 May '10 - 08:15

high quality oakley sunglasses wholesale

oakley sunglasses wholesale (Email) (URL) - 08 May '10 - 12:28

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

ed hardy women shoes (Email) (URL) - 12 May '10 - 06:49

hi there, thanks for your great post, it help me so much! now i wonder if you linke the mbt shoes from my site: the url is [[http://www.thesuitshoes.com]]

mbt shoes (Email) (URL) - 12 May '10 - 07:03

A good idea! [[http://www.offerreplicawatches.com.The..]] sell Chanel Watches, Replica BRM Watches,offer Cartier Watches, Copy Ebel Watches, Replica Hublot Watches, Fake Tag Heuer Watches, wholesale Richard Mille Watches.

They also sell some very fashion watches, such as Montblanc Watches for sale,Chopard Watches, Dior Watches and Gucci Watches. Rolex watches are hot sell. If u are Armani Watches and Breitling Watches fan. You can still look at Omega Watches and Longines Watches, many new arrivals watches just come here.You can have a try on 58338312391273913. :[url=[[http://www.offerreplicawatches.com]www..]]].

Replica Chanel Watches,Dvd Boxes (Email) (URL) - 12 May '10 - 07:41

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

Ugg Boots UK (URL) - 13 May '10 - 01:33

Toshiba pa3421u-1brs Battery [[http://www.adapterlist.com/toshiba/pa3..]]

laptop battery (Email) (URL) - 14 May '10 - 09:34

Apple a1185 Battery [[http://www.globallaptopbattery.co.uk/a..]]

laptop batteries (Email) (URL) - 14 May '10 - 09:48

MBT Masai Barefoot Technology, MBT Shoes No tax. No shipping. No hassles,MBT Fumba hot sale in europe. perfect shoes for you. [[http://www.mbts-mbtshoes.com/]]

wotanuo (Email) (URL) - 22 May '10 - 08:10

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]]

spider man costume (Email) (URL) - 24 May '10 - 11:57

[[http://www.airjordanshoescheap.com]]

susan (Email) - 25 May '10 - 01:53

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

Muska (Email) (URL) - 31 May '10 - 11:43

So nice to hear from you! [[http://www.fivefingersrunning.com]]

vibram five fingers (Email) (URL) - 02 June '10 - 01:30

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

Ugg Schoenen (Email) (URL) - 02 June '10 - 01:31

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

Ugg Boots Shop (Email) (URL) - 02 June '10 - 01:32

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

Classic uggs (Email) (URL) - 02 June '10 - 01:33

Thanks for sharing.great article! [[http://www.uggbaileybutton.org]]

Ugg Boots Cheap (Email) (URL) - 02 June '10 - 01:34

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

Cheap EdHardy (Email) (URL) - 02 June '10 - 01:35

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

Womens Abercrombie Fitch (Email) (URL) - 02 June '10 - 01:35

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]]

Ugg Boots UK (Email) (URL) - 02 June '10 - 01:36

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.

Ugg Classic Short (Email) (URL) - 03 June '10 - 10:00

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...]] plantar fasciitis cure ]

bed bug bite (Email) (URL) - 05 June '10 - 22:34

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

half marathon training schedule (Email) (URL) - 11 June '10 - 10:11

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]]

bicycle shoes (Email) (URL) - 14 June '10 - 05:42

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.

AAdvantage Partners (Email) (URL) - 15 June '10 - 06:21

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

UGG Schuhe (Email) (URL) - 15 June '10 - 07:07

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]]

nike air shoes (Email) (URL) - 17 June '10 - 02:04

[[http://www.sxhgz.com]] : nike shoes

puma shoes (Email) (URL) - 21 June '10 - 01:55

[[http://www.mbtshoeslatest.com]]
[[http://www.nikeairmaxshoe.com]]

Nike air max shoe (Email) (URL) - 24 June '10 - 07:46

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.

Acai Berry (Email) (URL) - 02 July '10 - 09:35

Do you like the ugg ? Ugg Classic Short Boots are UGG Australia’s original heritage styles. Ugg Classic Tall will keep your feet dry and the ultimate comfortable.
[[http://www.ugg-boots-london.com/ugg-cl..]]

Ugg Classic Short (Email) (URL) - 07 July '10 - 01:15

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!

MBT shoes (Email) (URL) - 02 August '10 - 06:25

discount nfl jerseys from china
cheap nfl jerseys

tanglnog (Email) (URL) - 04 August '10 - 02:45

[url=[[http://www.cheapjerseyschina.com]disco..]] nfl jerseys from china[/url]
[url=[[http://www.cheapjerseyschina.com]disco..]] nfl jerseys wholesale[/url]

tanglnog (Email) (URL) - 04 August '10 - 02:55

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

samyibiz (Email) (URL) - 13 August '10 - 04:15

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.

triathlon wetsuit (Email) (URL) - 19 August '10 - 05:53

[[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~~~!!!

hgddgh (Email) (URL) - 22 August '10 - 02:10

[[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.

ghhf (Email) (URL) - 22 August '10 - 02:11

[[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!

hao123 (Email) (URL) - 22 August '10 - 02:12

excellent article , I added you to my [[http://www.china-wholesale-directory.c..]] Top China Wholesalers category.. thanks for sharing the article!

China Wholesale Directory (Email) (URL) - 25 August '10 - 07:45

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

cool stuff (Email) (URL) - 25 August '10 - 08:05

Personal information





Remember your information?
Comment

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.


^M