Bug 178467 - [zfs] [request] Optimized Checksum Code for ZFS
Summary: [zfs] [request] Optimized Checksum Code for ZFS
Status: Closed Not Accepted
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-09 22:00 UTC by Jason Keller
Modified: 2018-05-29 09:55 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Keller 2013-05-09 22:00:00 UTC
This isn't so much a problem as it is an RFE.  Basically, the SHA256
checksum code within ZFS looks like it could use a little helping hand.
On my limited testing, it would appear that Solaris 11 has at least a
20-25% edge in efficiency when doing SHA256 checksumming for ZFS.

IANAP, but it would be extremely nice to be able to have the same (or
better) efficiency for ZFS on FreeBSD.  I have not done specific testing
with Fletcher4, but that also seemed to be slightly better tuned in
Solaris 11 as well.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-05-10 04:35:38 UTC
State Changed
From-To: open->suspended

assign, and note that someone will need to provide a patch. 


Comment 2 Mark Linimon freebsd_committer freebsd_triage 2013-05-10 04:35:38 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs
Comment 3 Xin LI freebsd_committer freebsd_triage 2013-05-10 07:16:03 UTC
Responsible Changed
From-To: freebsd-fs->zfs-devel

Assign to zfs-devel@
Comment 4 Steven Hartland freebsd_committer freebsd_triage 2013-05-10 09:47:59 UTC
We would need something more to go no than "looks like" I'm afraid.

Also Fletcher4 is the default checksum which achieves ~4GB/s
per core in hashing performance, where as SHA-256 even with
hand written assembly manages less than 1/10th that performance,
so if your looking for performance for checksums use the
default Fletcher4 instead of the SHA-256.

That said new processors do have HW support which could be
used to accelerate SHA-256 support, details of this can be
found here:-
http://download.intel.com/embedded/processor/whitepaper/327457.pdf

These sorts of core feature enhancements should be discussed
and implemented upstream at illumos.

    Regards
    Steve
Comment 5 Jason Keller 2013-05-10 14:21:26 UTC
Ok, thank you Steven - I'll gather up more detailed information when I have=
 my test environment fully fleshed out so I have absolute apples to apples =
numbers and can fully constrain my testing to one hardware platform (the pl=
atforms were slightly different, same processors and memory though).  I'll =
file that as an RFE with Illumos if that's what you think is best.  I just =
wanted to put that out there, since I certainly noticed the difference in m=
y many weeks of testing different platforms here (OmniOS, Solaris 11.0, Sol=
aris 11.1, FreeBSD 9.1, Nexenta 4 CE).  Didn't really know where I should f=
ile that particular RFE, so I figured I'd start with the kernel team.  I di=
dn't think that the SHA256 implementation in FreeBSD was taken exactly from=
 Illumos.
Comment 6 Steven Hartland freebsd_committer freebsd_triage 2013-05-10 15:29:11 UTC
Actually after double checking it looks like FreeBSD doesn't use the
same SHA-256 implementation in ZFS as illumos so there may well be
something to look at there.

Would be good to know the difference in performance between FreeBSD
and Openindiana (illumos distribution).

    Regards
    Steve
Comment 7 Jason Keller 2013-05-10 15:35:10 UTC
I'll gather some numbers together comparing OmniOS (Illumos) vs FreeBSD and=
 get back some numbers for you.  I can use my Xeon E3-1240 at home for the =
benchmarking, it'll just take me some time to gather everything together to=
 do it.  Are there any specific tools you'd like me to run, or just basic z=
pool iostat and mpstat / top -P ?
Comment 8 Jason Keller 2013-05-10 17:26:33 UTC
Steven,

It also looks as if kern/125738 is related to hardware acceleration of SHA2=
56 in ZFS where it's available - PJD took this one, but doesn't look like h=
e had time to work on it.  So they are similar, though this request is a bi=
t more broad.

Also, is there any way to scrub my mobile number off there in the ticket de=
tails?  Totally spaced out that it's in my default signature here at work.

--Jason
Comment 9 Alan Somers freebsd_committer freebsd_triage 2013-06-24 16:28:08 UTC
FWIW, I spent a full day trying to accelerate Fletcher-4 using SIMD
instructions (tested on Sandy Bridge and Nehalem).  I was unable to
improve on the current code; the Fletcher-4 hash is very fast and
doesn't vectorize well.  However, I believe that AVX-2 will probably
be able to beat the non-vectorized version.  I plan to try it out as
soon as I can get my hands on a Haswell CPU.  I've also spent several
weeks analyzing the strength of Fletcher-4, and concluded that it's
really quite good.  Good enough for every non-cryptographic
application, certainly.  My recommendation is that all ZFS users
should prefer Fletcher-4 over SHA-256.  I haven't tried vectorizing
SHA-256 and don't plan to.
Comment 10 Jason Keller 2013-06-24 17:20:35 UTC
Thank you very much for following up on this.  Any further optimization of =
checksums is gravy, for everyone that uses FreeBSD/ZFS.  Sure Fletcher4 is =
pretty light, but every little bit helps.  Fewer CPU cycles used =3D less l=
atency =3D more win.  I think for crypto/dedup applications, perhaps effort=
 should be focused on an optimized implementation of Keccak (SHA3 winner) i=
nstead of SHA256?
Comment 11 Mark Linimon freebsd_committer freebsd_triage 2013-08-15 04:43:25 UTC
Responsible Changed
From-To: zfs-devel->freebsd-fs

apparently there is no such alias.  reassign to freebsd-fs.
Comment 12 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:49:12 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
AND
- Untouched since 2018-01-01.
AND
- Affects Base System OR Documentation

DO:

Reset to open status.


Note:
I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.
Comment 13 Andriy Gapon freebsd_committer freebsd_triage 2018-05-29 09:55:36 UTC
Nobody came forward to do this, so no point in keeping the issue open.