php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50486 [PATCH] optimization for safe_address on exotic platforms
Submitted: 2009-12-16 01:30 UTC Modified: 2016-08-06 02:37 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: basant dot kukreja at gmail dot com Assigned: dmitry (profile)
Status: Assigned Package: Performance problem
PHP Version: 5.3SVN-2009-12-16 (SVN) OS: Solaris 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: basant dot kukreja at gmail dot com
New email:
PHP Version: OS:

 

 [2009-12-16 01:30 UTC] basant dot kukreja at gmail dot com
Description:
------------
safe_address function calculates nmemb * size + offset and it want to make
sure that it output doesn't overflow.
It uses doubles for finding overflow which is very inefficent for platforms
like sparc.


Reproduce code:
---------------
Any Php script causes _ecalloc function.

Expected result:
----------------
Good performance on platform other than gcc + x86_64 combo.

Actual result:
--------------
Poor _ecalloc performance on plaforms like Solaris.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-16 01:33 UTC] basantk@php.net
Here is the link to the proposed patch :
http://bitbucket.org/basantk/php53perfpatches/raw/ca263ffd272b/safe_address_64bitopt_php53.txt

Richard Smith did the original work and I refined the patch.
In this proposed optimization we can check if the inputs are
sufficiently large enough so that overflow is possible. If overflow is
possible, regular double logic will follow.


Link the the mail sent to internals mailing list :
http://marc.info/?l=php-internals&m=126084384813237&w=2

 [2009-12-16 01:34 UTC] basantk@php.net
Microbenchmark testing on Linux x86_64 :
=======================================
Based on the above suggested implementation, I benchmarked 3 implementation of
safe_address on Linux x86_64 (fedora 11) using a micro benchmark. Here are the
results :

--------------------------------------
For a regular nmemb * size + offset when no overflow possible :
nmemb = 23456 size = 67890 offset = 12345
assembly version of safe_address time diff = 26 ticks 
doubles imlementation of safe_address time diff = 72 ticks 
proposed safe_address time diff = 30 ticks 
--------------------------------------

For bigger integer multiplication :

nmemb = 2589934591 size = 4294967295 offset = 5

assembly version of safe_address time diff = 26 ticks 
doubles imlementation of safe_address time diff = 75 ticks 
proposed safe_address time diff = 76 ticks 

--------------------------------------
Here is the micro benchmark link :
http://bitbucket.org/basantk/php53perfpatches/src/tip/safe_address_bench.c

 [2009-12-16 01:35 UTC] basantk@php.net
On a ecommerce benchmark on Solaris sparc, new implementation reduced the time spent in _ecalloc to 50%.

 [2010-11-24 09:56 UTC] jani@php.net
-Summary: [PATCH]optimization for safe_address on exotic platforms +Summary: [PATCH] optimization for safe_address on exotic platforms -Package: Feature/Change Request +Package: *General Issues
 [2010-11-24 09:57 UTC] jani@php.net
-Package: *General Issues +Package: Performance problem
 [2016-08-06 02:37 UTC] kalle@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: dmitry
 [2016-08-06 02:37 UTC] kalle@php.net
Dmitry, any input on this?
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC