[pypy-issue] [issue900] Using cProfile on Windows generates negative tottime values

Garen Parham tracker at bugs.pypy.org
Wed Jan 11 10:37:29 CET 2012

Garen Parham <garen.p at gmail.com> added the comment:

The problem is still present as of 409a8b279f54 from the 1/10 nightly.  

I do see the affinity is set correctly (pypy.exe only shows CORE-0 active) but 
for whatever reason the negative tottime value still comes back in the results.  

Some side thoughts, based on:

* If the process affinity mask only has 1 bit set, no work needs to be done 
(means process can only run on at most 1 CPU)
* Return codes for GetProcessAffinityMask() and SetProcessAffinityMask() aren't 
inspected for error codes--there is a permission/privilege required (not 
relevant for my test though afaict).
* Won't work for systems with > 32 CPUs, need to use process groups. 
* IIRC I thought the "supported" way to do this is by first calling 
QueryPerformanceCounter() and QueryPerformanceFrequency() which presumably 
selects the best available hardware/instruction(s) for recording timestamps and 
accounts for frequency scaling issues (e.g. power management, turbo boost, speed 
step, ...)

This MS link seems to support using QueryPerformance*:


Hope that helps.

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list