php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58718 Allow use of CPU cycles instead of time
Submitted: 2009-06-11 08:17 UTC Modified: 2009-06-14 12:14 UTC
From: karsten at typo3 dot org Assigned:
Status: Wont fix Package: xhprof (PECL)
PHP Version: 5.3.0RC2 OS: OS X (Leopard)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-06-11 08:17 UTC] karsten at typo3 dot org
Description:
------------
The use of time when profiling is always error-prone 
(SpeedStep, comparability across systems). It would be cool to 
use CPU cycles instead of microseconds, at least that could be 
an option.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-11 18:48 UTC] kannan@php.net
I don't think it fixes the issue. A program which does say a sleep(1) would still report different number of cycles when SpeedStep is on.

[Note: We are using CPU cycles (RDTSC counter) as a way to do "elapsed" time (or wall clock time) profiling. If what you are interested in is CPU time, then xhprof_enable() already takes an option flag for CPU time profiling-- namely, XHPROF_FLAGS_CPU. When XHPROF_FLAGS_CPU flag is used, CPU times are measured using getrusage().]

Let me know if I misunderstood your suggestion.
 [2009-06-14 07:38 UTC] karsten at typo3 dot org
Well, sleep() calls are hardly something one wants to 
profile... :)

I saw that you use the RDTSC counter, but calculate time using 
the CPU frequency inside the xhprof extension. If you just 
left that out, it would no longer be required to disable 
speedstep and numbers would be comparable even across 
different machines.
 [2009-06-14 10:21 UTC] changhao dot jiang at gmail dot com
I am not convinced that RDTSC counter comparison is useful either. Based on our own experience that a significant portion of a PHP request processing time is spent on external IO (database queries, memcache accesses, etc.). Suppose we compare RDTSC counter values directly, and the CPU frequency is downclocked with SpeedStep by half, even if nothing has changed in the execution time, direct RDTSC counter comparison would lead to the wrong conclusion that external IO operations were sped up by two times.
 [2009-06-14 11:17 UTC] kannan@php.net
@karsten: sleep() was just an example. The idea is that any time the process is blocked waiting on something, the same issue will kick in. If a call to the DB takes say 0.1 seconds, the cycles (RDTSC) delta reported for the DB call will vary when SpeedStep is turned on. So the proposed solution doesn't help.
 [2009-06-14 11:22 UTC] kannan@php.net
closing the issue
 [2009-06-14 12:14 UTC] karsten at typo3 dot org
Ok, that's a valid point. For my use case that would (at least 
partly) not be a problem, but that depends on what you are 
profiling, of course... Thanks for considering this issue!

PS: Too bad there seems to be only one tool (CoolBook) to 
switch off SpeedStep on a Mac...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 21:01:29 2024 UTC