{"thread":{"id":"20447","subject":"Re: [PATCH 0/7] block-sha1: improved SHA1 hashing","startedAt":"2009-08-07T07:36:01Z","lastAt":"2009-08-07T07:36:01Z","messageCount":1,"participants":["George Spelvin"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"119895","messageId":"20090807073601.7651.qmail@science.horizon.com","threadId":"20447","inReplyTo":null,"subject":"Re: [PATCH 0/7] block-sha1: improved SHA1 hashing","fromName":"George Spelvin","fromEmail":"linux@horizon.com","sentAt":"2009-08-07T07:36:01Z","receivedAt":"2009-08-07T07:36:01Z","isPatch":true,"sender":{"key":"linux@horizon.com","avatar":null},"body":"> Basically, older P4's will I think shift one bit at a time. So while even \n> Prescott is relatively weak in the shifter department, pre-prescott \n> (Willamette and Northwood) are _really_ weak. If your P4 is one of those, \n> you really shouldn't use it to decide on optimizations.\n\nThanks for the warning.  The only P4 I have a login on is a Willamette, so\nI guess it's a bad optimization target:\n\nprocessor       : 0\nvendor_id       : GenuineIntel\ncpu family      : 15\nmodel           : 1\nmodel name      : Intel(R) Pentium(R) 4 CPU 1.60GHz\nstepping        : 2\ncpu MHz         : 1593.888\ncache size      : 256 KB\nfdiv_bug        : no\nhlt_bug         : no\nf00f_bug        : no\ncoma_bug        : no\nfpu             : yes\nfpu_exception   : yes\ncpuid level     : 2\nwp              : yes\nflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pebs bts\nbogomips        : 3187.77\nclflush size    : 64\npower management:\n\n\n\nBTW, I'm having a bit of a problem with sha1bench.  Because the number\nof rounds is multiplied by 10 until it takes more than mintime, and\nthe watchdog timer is set to 12*mintime, if I just barely miss the\nthreshold, I can hit the watchdog on any code that's more than 20% slower\nthan the reference rfc3174 code:\n\n# /tmp/sha1bench \n#Initializing... Rounds: 10000000, size: 625000K, time: 6.904s, speed: 88.41MB/s\n#             TIME[s] SPEED[MB/s]\nrfc3174         6.912       88.31\n# New hash result: 0489b02aee9fbd82b0bb0cba96f8047e42f543b8\nrfc3174         6.911       88.31\nlinus           3.002       203.3\nlinusas         3.253       187.7\nlinusas2        3.059       199.6\nmozilla         10.86       56.22\nmozillaas       10.33       59.09\nopenssl         2.145       284.5\nspelvin         1.933       315.8\nspelvina        1.933       315.8\nnettle          2.161       282.4\n\nI had to bump it to 20 times to be able to get past the mozilla code.\n\nYou can still have nice round numbers with smaller incements of 2x or 2.5x:\n\n    do {\n-      rounds *= 10;\n+      rounds *= 2;\n+      if (rounds % 9 == 4)\n+        rounds += rounds/4;     /* Step 1, 2, 5, 10, 20, 50, 100... */\n       uWATCHDOG(mintime*20);\n       t1 = GETTIME();\n       for (i=0; i<rounds; i++) {\n          SHA1Input(sc, arr512b, sizeof(arr512b));\n          if (i<64) {\n             SHA1Result(sc, arr512b+\n                     (i+arr512b[i]+arr512b[arr512b[i]%64]+\n                      arr512b[63-i]+arr512b[arr512b[63-i]%64]) %\n                     (sizeof(arr512b)-20));\n             SHA1Reset(sc);\n             }\n          }\n       t2 = GETTIME(); td = t2-t1;\n       }\n    while (td<mintime);\n\nAnd yeah, my P4 is touchy:\nn# /var/tmp/sha1bench \n#Initializing... Rounds: 500000, size: 31250K, time: 0.9736s, speed: 31.35MB/s\n#             TIME[s] SPEED[MB/s]\nrfc3174        0.9931       30.73\n# New hash result: 2872616106e163ae9c7c8d12a38bef032323c844\nrfc3174        0.9491       32.16\nlinus          0.4906        62.2\nlinusas        0.5799       52.62\nlinusas2       0.4859       62.81\nmozilla         1.302       23.44\nmozillaas       1.234       24.74\nopenssl         0.226         135\nspelvin        0.2298       132.8\nspelvina       0.2494       122.4\nnettle         0.3687       82.78\n"}]}