Re: Re: Fwd: little request :)

From: Date: Mon, 10 Feb 2014 20:09:42 +0000
Subject: Re: Re: Fwd: little request :)
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-72445@lists.php.net to get a copy of this message
On Tue, Feb 11, 2014 at 4:50 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote: > I think length leak does not matter much. > Therefore, I may ignore length leak as it could know it from other codes > using strlen(), etc. > > Our main concern would be performance. > > > https://github.com/yohgaki/php-src/compare/PHP-5.6-rfc-hash-compare > > and the bench mark result of > > https://gist.github.com/yohgaki/ede544f290c6cf9fa90d > > is > > [yohgaki@dev github-php-src]$ ./php-bin t.php > str_siphash_compare Elapsed: 9.450211 Iterations: 1000000 DataSize: 1024 > str_xxhash32_compare Elapsed: 3.849933 Iterations: 1000000 DataSize: 1024 > str_md5_compare Elapsed: 27.174614 Iterations: 1000000 DataSize: > 1024 > str_byte_compare Elapsed: 5.874092 Iterations: 1000000 DataSize: 1024 > str_byte_compare2 Elapsed: 8.761152 Iterations: 1000000 DataSize: 1024 > str_word_compare Elapsed: 1.867914 Iterations: 1000000 DataSize: 1024 > str_compare Elapsed: 1.178738 Iterations: 1000000 DataSize: 1024 > > I had the same idea, but I didn't try as it requires additional memory > allocation. > > str_byte_compare Elapsed: 5.874092 Iterations: 1000000 DataSize: 1024 > str_byte_compare2 Elapsed: 8.761152 Iterations: 1000000 DataSize: 1024 > > 1st one is simple byte by byte XOR, 2nd one is using modulo as original > patch > proposed. There is obvious difference even with additional modulo. > > str_compare Elapsed: 1.178738 Iterations: 1000000 DataSize: 1024 > > This is the result of simple strncmp() as a reference. > How well your version perform compare to simple strncmp? > This is --enable-debug build. Since we are talking about performance, I took the bench on the same machine w/o it. [yohgaki@dev github-php-src]$ ./php-bin t.php str_siphash_compare Elapsed: 2.324999 Iterations: 1000000 DataSize: 1024 str_xxhash32_compare Elapsed: 0.871854 Iterations: 1000000 DataSize: 1024 str_md5_compare Elapsed: 6.890052 Iterations: 1000000 DataSize: 1024 str_byte_compare Elapsed: 1.734985 Iterations: 1000000 DataSize: 1024 str_byte_compare2 Elapsed: 4.885057 Iterations: 1000000 DataSize: 1024 str_word_compare Elapsed: 0.512397 Iterations: 1000000 DataSize: 1024 str_compare Elapsed: 0.302799 Iterations: 1000000 DataSize: 1024 Modulo seems eating CPU time a lot. I'm interested in how emalloc affects performance. BTW, if we use SSE to compare data, it would be faster than str_word_compare(). Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#72445) next »