Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26648 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56787 invoked by uid 1010); 16 Nov 2006 18:00:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 56772 invoked from network); 16 Nov 2006 18:00:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Nov 2006 18:00:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=andrei@gravitonic.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andrei@gravitonic.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gravitonic.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: andrei@gravitonic.com X-Host-Fingerprint: 204.11.219.139 lerdorf.com Linux 2.5 (sometimes 2.4) (4) Received: from [204.11.219.139] ([204.11.219.139:48077] helo=lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/D4-01084-627AC554 for ; Thu, 16 Nov 2006 13:00:12 -0500 Received: from [66.228.175.145] (borndress-lm.corp.yahoo.com [66.228.175.145]) (authenticated bits=0) by lerdorf.com (8.13.8/8.13.8/Debian-2) with ESMTP id kAGI00UD024102; Thu, 16 Nov 2006 10:00:00 -0800 In-Reply-To: <011b01c70721$ca0ec7f0$0201a8c0@pc1> References: <455455D1.3020706@zend.com> <017f01c704b9$5e07f870$0201a8c0@pc1> <45546EDB.2020400@zend.com> <011b01c70721$ca0ec7f0$0201a8c0@pc1> Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-ID: <0e7bb4f7f12e57e899a6c4b26068b93e@gravitonic.com> Content-Transfer-Encoding: 7bit Cc: "Antony Dovgal" , "php-dev" Date: Thu, 16 Nov 2006 09:59:45 -0800 To: "Matt Wilmas" X-Mailer: Apple Mail (2.624) Subject: Re: [PHP-DEV] zend_u_strtod() 400% speed up From: andrei@gravitonic.com (Andrei Zmievski) Matt and Antony, I this we should go with Matt's patch, since we care only about ASCII characters in strings. -Andrei On Nov 13, 2006, at 4:46 AM, Matt Wilmas wrote: > Hi Antony, > > ----- Original Message ----- > From: "Antony Dovgal" > Sent: Friday, November 10, 2006 > >> On 11/10/2006 02:14 PM, Matt Wilmas wrote: >>> Hi Antony, >>> >>> ----- Original Message ----- >>> From: "Antony Dovgal" >>> Sent: Friday, November 10, 2006 >>> >>>> Hello all. >>>> >>>> I would like to propose a replacement for current zend_u_strtod() >>> implementation. >>>> The patch: http://tony2001.phpclub.net/dev/tmp/u_strtod.diff >>>> >>>> According to my tests, new implementation is faster in about 40 >>>> (forty) >>> times. >>>> The simple script below takes ~1 sec to run with the patch and ~40 > seconds >>> without. >>> >>> Cool. :-) I'd just been thinking about zend_u_strtod() again -- if >>> you > see >>> my thread asking Andrei about the Unicode characters allowed as > numbers... >>> I changed the function back in the summer to be about 8x faster by >>> converting FROM Unicode and using the regular zend_strtod(), but it >>> was > just >>> a quick hack, so maybe better that it wasn't applied! >>> http://realplain.com/php/zend_u_strtod.diff >> >> Hmm.. Actually, your version seems to be slightly faster (~15%) than >> mine >> and there are several advantages, like no formatter is required, >> avoiding >> parsing non-numeric strings and less TSRMLS_FETCH() calls, which >> leads to >> even better results on non-numeric strings. >> >> Also, it looks like a good idea to use zend_strtod() in both native >> and >> unicode modes. > > Hmm, I don't understand how mine was faster if yours was 40x faster > than the > current version, as when I tested mine, it was only ~8x. :-/ > > Well anyway, as I mentioned in my first reply, I had another idea > since I > learned (from README.UNICODE and Andrei) that only ASCII digits are > allowed > in Unicode. I just put this together: > http://realplain.com/php/zend_u_strtod.c I didn't test it (or even > try to > compile), but you get the idea -- "manually" copying the relevant > Unicode > chars to a char * (am I doing that right?). I've got the "char > buf[64]" > there, assuming it's more efficient than using emalloc() (?), when the > number will fit. I didn't know what size to make it, just whatever > catches > the vast majority of cases... > > I'd really like to see a faster version implemented soon. :-) > > > Matt