|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-08-07 15:54 UTC] dmitry dot koterov at gmail dot com
Description:
------------
Sometimes on i386 machines (not x86_64) xhprof displays wrong values in "Excl. Wall Time" column - extremely high (near 2 billions). Seems we have int32 overflow here while calculating.
The patch is attached. It simply converts all microseconds to double. It forces PHP to automatically cast to double all expression which use these values. It avoids overflows while displaying and calculating the statistics. I'll be pleased if you apply this patch in a next version.
Index: xhprof_lib/utils/xhprof_runs.php
===================================================================
--- xhprof_lib/utils/xhprof_runs.php (revision 14556)
+++ xhprof_lib/utils/xhprof_runs.php (working copy)
@@ -118,7 +118,15 @@
$contents = file_get_contents($file_name);
$run_desc = "XHProf Run (Namespace=$type)";
- return unserialize($contents);
+
+ $dump = unserialize($contents);
+
+ // Convert all numbers to float to avoid int32 overflow.
+ foreach ($dump as $k => $v) {
+ $dump[$k]['ct'] = floatval($dump[$k]['ct']);
+ $dump[$k]['wt'] = floatval($dump[$k]['wt']);
+ }
+ return $dump;
}
public function save_run($xhprof_data, $type, $run_id = null) {
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
Oh! Seems the problem is not only an integer overflow. Sometimes profiling dump looks like: [a==>b] => Array ( [ct] => 1 [wt] => -2147483648 ) Note the negative [wt] value above! Reproducing is not stable: sometimes it works OK, sometimes not. And seems this effect is reproduced more often if xdebug is also active together xhprod. If xdebug is turned off, no negative values are present, but sometimes wt=0 for all rows. So, possibly this is an xdebug side-effect in most cases...