Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72419 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36202 invoked from network); 9 Feb 2014 06:32:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2014 06:32:20 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.204 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.204 mail4.serversure.net Linux 2.6 Received: from [217.147.176.204] ([217.147.176.204:53736] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/01-22225-1F027F25 for ; Sun, 09 Feb 2014 01:32:18 -0500 Received: (qmail 25408 invoked by uid 89); 9 Feb 2014 06:32:15 -0000 Received: by simscan 1.3.1 ppid: 25401, pid: 25404, t: 0.0783s scanners: attach: 1.3.1 clamav: 0.96/m:52 Received: from unknown (HELO linux-dev4.lsces.org.uk) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 9 Feb 2014 06:32:15 -0000 Message-ID: <52F721AF.7060706@lsces.co.uk> Date: Sun, 09 Feb 2014 06:35:27 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24 MIME-Version: 1.0 To: PHP Internals Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: 64 bit runs slower than 32 bit? From: lester@lsces.co.uk (Lester Caine) When using Google one rarely gets the right answer until you already know the right questions to ask ... That 64bit runs slower than 32bit has always niggled me since when moving up from 8/16 bit platforms to 32 bits one always saw a substantial speed improvement. I've been asking the wrong questions about 'timing attach' used to decode passwords simply because I've been looking at the wrong questions, and the detailed analysis being supplied was convincing. But it's based on a lower level mistake. The 'timing attach' only works if one is doing 'byte by byte' compares and I'd not twigged that this was the mistake being made. We tend to ignore just how something is achieved, so using memcmp() seems a sensible low level function, but it has a time penalty when all one wants is '='. It was not until I started to look at how it works that I found all the explanations on how having found a missmatch it then works out which character and produces the problem and the '<>' results. All the effort to produce a 'safe' comparison on other c software aims to hide that timing difference? But why are we wasting time doing all that work? What is needed initially is to simply drop memcmp() and switch to a memequ() macro which bales as soon as a missmatch is found. It could have a flag which scans the whole buffer before baling if you want that extra 'safety'. How often in the PHP code is memcmp() used when a simple memequ() would be faster ... and faster still on 64bit machines? There is a side question here as to why with all the instructions available on processors there is not a 'byte compare' which produces the right set of flags in a single process cycle, but I suspect that fails as soon as you introduce unicode characters? memcmp() fails to produce the correct answer once one switches to a unicode base, while a memequ() would not have that problem? -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk