Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72504 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99157 invoked from network); 12 Feb 2014 08:12:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Feb 2014 08:12:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-la0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:33988] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/94-07280-5DC2BF25 for ; Wed, 12 Feb 2014 03:12:06 -0500 Received: by mail-la0-f42.google.com with SMTP id hr13so6798520lab.15 for ; Wed, 12 Feb 2014 00:12:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=1HgUiNIgAW6h1bqSOooMk8OpxYaAwneNwX8R9m9TK0w=; b=xrthooH82Y5ltU7fMOLP0LnaAAEUTJ/HEyjAtSsDZZj7PYQ+FzKZgRMiKstw4Xxhfn 0TFsEp1kC7hmIi0D45wx/QSDRz9/+QwWDwjajXzEb70htZarQOrs0Lj2RdaLE/0FMTvj oOV74TMXak4WvrTUWeyhZldpUPuqhusizzZ4rQVPW081VbFZrxrTCv31hUfsUfuhqTRR eTEOixGPgyJ7lW4GrPfgaaMHcEtM01bgdCbPn9FcDKZrlXvW4vifZqh8qaMsW8p41K8r 5PBuPsNb2BgGJZaFD64Z3m08AbQLrckB1ykyaPwKO4MC7A7r1EfmnX6fxymbL+23xOqK GMPQ== X-Received: by 10.112.39.167 with SMTP id q7mr31023lbk.82.1392192721812; Wed, 12 Feb 2014 00:12:01 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Wed, 12 Feb 2014 00:11:21 -0800 (PST) In-Reply-To: <52FB21A0.7060204@lsces.co.uk> References: <9E3AA302-1EC1-4497-996F-716555CAAB64@rouvenwessling.de> <52F895CB.2020308@lsces.co.uk> <52FB21A0.7060204@lsces.co.uk> Date: Wed, 12 Feb 2014 17:11:21 +0900 X-Google-Sender-Auth: 8vEhED5pmYIhgqlmZK3fd27Lk8c Message-ID: To: Lester Caine Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1134d7aea4a23e04f23120bb Subject: Re: [PHP-DEV] [VOTE] Timing attack safe string comparison function From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1134d7aea4a23e04f23120bb Content-Type: text/plain; charset=UTF-8 Hi all, On Wed, Feb 12, 2014 at 4:24 PM, Lester Caine wrote: > Yasuo Ohgaki wrote: > >> We cannot assume word aligned data for strings. This is the reason why >> there is >> additional byte by byte comparison. It could be made to align memory to >> word size, >> but it requires memory allocation for comparison. I'm not sure which is >> better, though. >> > > Since PHP is controlling the memory management, there is no reason it > can't properly align data elements ... based on the target platform. When > you only had 640k of memory every byte counted, but these days the speed > gain provided by simply wasting a few bytes and always padding buffers to a > relevant word boundary is far greater than the space saving. Things have > changed somewhat since the original C compilers were written. But this is > better discussed on the 32/64bit optimization thread. Suffice to say that > Firebird recorded substantial speed improvement once the basic ground rules > were accepted and unnecessary 'byte related' processing dropped. Word aligned memory allocation can be done. It may be good for fragmentation also. I don't read current memory manager code, so I cannot answer this. Anyone? -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1134d7aea4a23e04f23120bb--