mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #877] OMP scaling #481
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#481
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jfoug on GitHub (Dec 11, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/877
Here is an example (cygwin64, OMP build)
I have fixed one of these
github.com/magnumripper/JohnTheRipper@38aa13b3d9But we need to identify them, and at least work around them (like this). It would be nice to know WHY, and if why, then try some way to auto-detect.It likely (for the tc_* hashes on cygwin), that the PKCS5_PBKDF2_HMAC() oSSL function was made thread safe by simply putting a mutex around the call, OR worse, they put a mutex around some interal part of the call (such as the HMAC). The 2nd is more likely. So what happens is 8 threads start into PKCS5_PBKDF2_HMAC() call, then they all but one block and that one does an HMAC. That thread then is stopped, and the next thead gets it's chance to go. HORRIBLE performance!!
That is just a theory, but from dealing with poorly coded MT code before, it is what it looks like it is doing.
I will add some rel-bench runs where I cut out things that did not look quite right, and put them into a follow up post.
@jfoug commented on GitHub (Dec 11, 2014):
This may not fit here 100%, but it is where i am putting it now. Here are benchmark tests run, against 3 runs, on cygwin64 and Ubuntu-64 (virtualbox VM), on my AMD xop dual laptop. There are some MAX_KEYS and OMP_SCALE things we should address here. I want to get the same data from my core-i7 quad HT at work, since it will likely scale differently. Then we can smooth some of these issues out, even before starting on auto-scaling for OMP.
@jfoug commented on GitHub (Dec 11, 2014):
Original timings using PKCS5_PBKDF2_HMAC() if truecrypt:
New timings using pbkdf2_sha512 (not even to mention we CAN do this with SIMD)
This is really a NO BRAINER!!!
I was also able to get ripemd160 working instantly in pass_gen.pl by passing &ripemd160 paramter to pp_pbkdf2 (and 2000 iterations). It works like a champ. I have to build a pbkdf2_hmac_ripemd160 for this.
However, whirlpool did NOT give me the same results for the pbkdf2 in pass_gen.pl. I do not know why but it did not.
@jfoug commented on GitHub (Dec 11, 2014):
Now:
I have it ready to go. ONLY sha512 is overridden (for now). I do not have a pbkdf2 done for ripemd160 (yet). It should not be hard however, and THAT hash is very slow on my machine, so there may be a LOT to gain.
5c36dfb@magnumripper commented on GitHub (Dec 11, 2014):
Good stuff!
@jfoug commented on GitHub (Dec 12, 2014):
i now have pbkdf2-hmac-whirlpool.h, and pbkdf2-hmac-ripemd160.h into JtR code, and included and used in trueccrypt_fmt_plug.c whirlpool only got about 60% speedup, but ripemd got about 3x or so improvement.
@jfoug commented on GitHub (Dec 13, 2014):
oSSL also contains RIPEMD160. I added code to configure to autodetect. There is now HAVE_RIPEMD160 added into autoconfig.h I also put code in to use this within pbkdf2_hmac_ripemd160.h (used by truecrypt_fmt). Found out on my 64 byte cygwin system, it is about 10% slower than the sph code. It is almost certain that oSSL is using the same reference-level RipeMD that we are doing, but 'properly' based on the build being 64 bits (such as bit count accumulation in a single var). oSSL may be doing it using 2 vars or something (which is slower). Well whatever it is, I have commented it out for now (with an
#if HAVE_RIPEMD160 && 0) I might have a look on other systems. I bet that oSSL on 32 bit will be faster than sph, but I could be wrong in that assumption also.@jfoug commented on GitHub (Dec 14, 2014):
Here is a breakdown of oSSL and sph_* for ripemd160 and whirlpool for 32 bit and 64 bit systems I have. I think this shows that running oSSL for whirlpool (if supported) is best, or almost even, and that running sph_ripemd160 is best or almost even, for all systems.
@frank-dittrich commented on GitHub (Dec 14, 2014):
Are you running ubuntu inside a VM, on different hardware, or why are the numbers so poor (compared to cygwin)?
Can you post the patches needed to reproduce this? I#d like to try it on 32bit and 64bit Fedora.
@jfoug commented on GitHub (Dec 14, 2014):
In a VM. That 32 bit VM only have 2 cores. All other tests had 4 (real CPU is DUAL-HT)
@jfoug commented on GitHub (Dec 14, 2014):
Btw, here are the new speeds after the latest commit of this format, cygwin64 speeds only, but on same hardware as the above table
$ ../run/john -test=5 -format=tc_*
Will run 4 OpenMP threads
Benchmarking: tc_aes_xts, TrueCrypt (RIPEMD160/SHA512/WHIRLPOOL) AES256_XTS [128/128 XOP 2x]... (4xOMP) DONE
Raw: 2361 c/s real, 1223 c/s virtual
Benchmarking: tc_ripemd160, TrueCrypt RIPEMD160 AES256_XTS [32/64]... (4xOMP) DONE
Raw: 469 c/s real, 124 c/s virtual
Benchmarking: tc_sha512, TrueCrypt SHA512 AES256_XTS [128/128 XOP 2x]... (4xOMP) DONE
Raw: 3718 c/s real, 994 c/s virtual
Benchmarking: tc_whirlpool, TrueCrypt WHIRLPOOL AES256_XTS [64/64]... (4xOMP) DONE
Raw: 709 c/s real, 189 c/s virtual
All 4 formats passed self-tests!
@magnumripper commented on GitHub (Dec 14, 2014):
That's beautiful for the relbench figures :) TC did exist in J7, didn't it? Heck it was so long ago I do not really know.
@jfoug commented on GitHub (Dec 15, 2014):
I am pretty sure TC has been there a bit. It is 10 to 20x faster now. (or on my cygwin omp build, about 4000x faster for sha512, LOL).
Now I gotta get krb5-18 done. That one should also get a huge improvement if we can get past the libkrb5 stuff.
That actually is not a bad idea. Identifying the hashes that use slow high level libs, but where the hash was present in J7, 'fixing' them to be faster native, or even SIMD, and fudging the relbench numbers :)
@jfoug commented on GitHub (Dec 15, 2014):
Btw, I have the TC_* hashes in pass_gen.pl now, so I can also add them to jtrts.pl I have added them to the 'add missing hashes ' issue on jtrts.
@jfoug commented on GitHub (Dec 17, 2014):
krb5-18 is now done. This was the last super bad one on cygwin (where OMP was SLOWER by far, than OMP=1)
@magnumripper commented on GitHub (Dec 19, 2014):
Benchmark:
First I thought the below said phpass should run larger batches in non-omp builds:
Then I saw this
Why is a non-omp build using MD5_body!? It's the same for dynamic_17.
@magnumripper commented on GitHub (Dec 19, 2014):
Very poor figures below. Ideally it should be 4.0
The list is a lot longer and doesn't reach 2.0 (50% efficiency) until line 90 out of 511.
@jfoug commented on GitHub (Dec 19, 2014):
Phpass should be fixed. Yes, this was a bug, with #define's mixed up. The #define block was a little complex (like 4 different things going on, between OMP, SIMD, BE and MD5_X2. Thank god for syntax highlighting and smart #ifdef highlighting.
@magnumripper commented on GitHub (Dec 20, 2014):
Fixed the few worst. cq got some awsome speedup even without OMP:
50337K -> 90725K and OMPx4 60633K -> 258998K.
@magnumripper commented on GitHub (Dec 20, 2014):
I bet we have 30 or so formats that could benefit a lot from OMP_SCALE tuning, among at least the double number to test.
@jfoug commented on GitHub (Dec 29, 2014):
Made good progress today: Still some to go (since my auto code only works for formats if they do a
max *= (scale*omp_t)and many formats do not do that I do have a list of other formats that 'look' like we could do some better work.Some of these may not benefit. Some may not have OMP at all. These are just ones that mostly appear like they may have benefits we can give them, OR when trying to kick up OMP_SCALE, it kept a fixed size. I just did IPB2 to get an idea of how best to attack some of these formats that do not allow the external upward adjustment of OMP_SCALE env var.
made into a thin format, dyna_2004 2-3x improvement + OMPnot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matternot enough gain to matter@magnumripper commented on GitHub (Dec 29, 2014):
To make that a checklist you need to start each line with dash
@magnumripper commented on GitHub (Dec 29, 2014):
md4gen is an old thing made by Solar (but not in core iirc). I use to ignore it because Dynamic obsoletes it. Actually we could drop it IMHO.
@magnumripper commented on GitHub (Dec 29, 2014):
mssql and mssql05 does not support OMP. They probably should.
Your script could detect that we did not get the
(4xOMP)so no need to bother@magnumripper commented on GitHub (Dec 29, 2014):
NT does not and can not support OMP.
@jfoug commented on GitHub (Dec 29, 2014):
I have pulled md4-gen and NT. I probably should also pull sha1-gen It is also somewhat redundant.
@jfoug commented on GitHub (Dec 30, 2014):
Dyna formats may need to have scale looked at. BUT they should ALL get updated with a single change. right now, they are 6144 (I think) in scale (OMP-4). It may be 6144 fixed no matter what the OMP level. But I think it should be increased (some), or possibly recomputed for each type.
@magnumripper commented on GitHub (Dec 30, 2014):
578fe51fixed a whole lot of formats with this one-liner[tm]@jfoug commented on GitHub (Dec 31, 2014):
So we can use OMP_SCALE environment car now ?
@magnumripper commented on GitHub (Dec 31, 2014):
I would guess so but haven't bothered. Go ahead if you like.
Note to self: md5crypt is odd - I tried unifying it but reverted. And scrypt does not benefit at all from scaling - it's just too slow.
@jfoug commented on GitHub (Dec 31, 2014):
I doubt scrypt or bcrypt for that matter will have any benefit. Super slow ones just don't matter, and are better with scale 1
@jfoug commented on GitHub (Mar 12, 2015):
I did some work on dyna. I was able to get things to have more or less values in OMP. Now comes the tough part. There are some formats that get slower (some much slower), when you increase count, and some that get faster. So, I may have to make some changes. For these changes I will need to:
But all in all, I think I can get 150% for many formats (the faster ones), might get 200% for some that are over scaled today, and get 110-120% for most others. Some may have no change at all.
For example, here were some timings I saw
So you can see for this format, we got about half of the loss back. There is no way we can get it all, there simply is WAY too much overhead in dyna that I simply can not eliminate.
But I do think I can get dyna working quite a bit quicker for many of the formats. It may not be a trivial undertaking, but I really think it needs done. At the same time, I really would love to simplify this somewhat, but I may not be able to do that. Being able to handle SIMD (of multiple flavors), oSSL, md5_go, md5_body and md5_body-x2 is NOT trivial, especially allowing switching in and out of SIMD/flat. The code prior to md5_body-x2 was quite a bit more simplistic, BUT that md5_body_x2 does provide a significant improvement in performance, so I think coding for it, even though it adds 100's of extra lines of #ifdef code, does make the format faster.
@magnumripper commented on GitHub (Mar 13, 2015):
Is Dynamic all-or-nothing OMP? I usually build with --disable-openmp-for-fast-formats. I use --fork for the fast ones.
@jfoug commented on GitHub (Mar 13, 2015):
I believe it is all or nothing. I may have to address the disable-omp-for-fast-formats switch.
@jfoug commented on GitHub (Mar 13, 2015):
Ok, here is a 'checking' program (to test BE and LE GETPOS macros).
Here are some results. @magnum, can you please validate that the results for 8 and 16 coef are correct. I 'think' they are, but I am not 100% sure.
@jfoug commented on GitHub (Mar 13, 2015):
Here were the 'originals'
Here are my modifications
The only thing that was changed was the
(SIMD_COEF_32>>1)`` becomingSIMD_SHIFT``` and SIMD_SHIFT will probably have to be SIMD32_SHIFT since we may have the same thing for SIMD64@magnumripper commented on GitHub (Mar 13, 2015):
I think they are OK, but I have been confused before :-)
This should be correct.
@jfoug commented on GitHub (Mar 13, 2015):
I am pretty sure dyna will be a real bitch when it comes to COEF > 4
I think for GSOC, we should probably just have them first create the SIMD code, and then simply create as small an update as possible for the raw format. So they should update:
rawMD4_fmt_plug.c
rawMD5_fmt_plug.c
rawSHA1_fmt_plug.c
rawSHA256_fmt_plug.c
rawSHA512_fmt_plug.c
at first. Get them solid, and with as 'minimal' as possible change so that COEF==4|8|16 all work. Once we get to that point, we can start to move out. I think the pbkdf2_*.h would probably be the 2nd thing(s) to do, as they are somewhat simple to change, and impact a bunch of formats. Then start doing one off's on the other 70 or so SIMD formats, and also start on dyna.
Yes, getting some of these things like we are in this thread done up front is good. I really think we could get the raw formats 'ready', just waiting for the code. But on a lot of it, we simply will have to put out fires.