[MERGE] lsprof branch

John Arbash Meinel john at arbash-meinel.com
Tue Jun 20 19:49:37 BST 2006


Robey Pointer wrote:
> 
> On 19 Jun 2006, at 21:15, John Arbash Meinel wrote:
> 
>> Robey Pointer wrote:
>>>

...

>> So how do you actually generate Calltree style output? I don't see any
>> options to bzr to actually generate it.
> 
> I don't either, and there doesn't seem to be any in ddaa's original
> patch.  Maybe ddaa can clarify how it works?
> 
> (I can't use kcachegrind because I didn't/won't install KDE libraries on
> my mac.)
> 

I think ddaa just updated lsprof for whatever he was using it, not
specifically for bzr. So he didn't do any updates to make bzr actually
generate the cachegrind output.

> 
>> So I figured I would use '--lsprof-file' to generate a pickle, and then
>> read that back in.
>>
>> But with the latest bzr.dev I have the problem that cPickle fails,
>> because it can't serialize a 'code'.
>>
>> bzr: ERROR: cPickle.PicklingError: Can't pickle <type 'code'>: attribute
>> lookup __builtin__.code failed
>>   at /home/jameinel/dev/bzr/bzr.dev/bzrlib/commands.py line 537
>>   in apply_lsprofiled
>>
>> Now, I can see in 'Stats' that the method 'freeze()' claims to convert
>> 'code' entries into string descriptions.
>>
>> This patch seems to fix it for me:
> 
> [snip] This code is from the original lsprof, but from scanning the code
> in your patch, I think the original indentation is correct.  It seems to
> be a really arcane way of doing string conversion on the fields.
> 
> What command did you lsprof?  I just tried it on "bzr info" and it
> worked here, so maybe a particular command is tickling it.
> 

The original indentation doesn't collapse code to strings for children
if e.code is already a string.

bzr --lsprof --lsprof-file ,,foo root

Caused it to happen every time. It also happens for 'bzr info' for me.
It might depend on the python version that you are using.
Why do you feel the original indenting is correct?

> 
>> So because everything was frozen so that you could pickle it, you can't
>> read it back in and create the call tree.
> 
> Here you are correct that once you freeze() the Stats object, it's no
> longer in the form that the calltree stuff is expecting.  I think ddaa
> intended calltree to be used inline (but I don't know how).
> 
> Maybe I should remove ddaa's patch since neither of us understands how
> to use it.  It seems like it's complicating things.
> 
> 
>> Also, why doesn't running './bzr --lsprof-file foo root' actually run
>> lsprof. It would seem like giving it an output file should be sufficient
>> for enabling the profiling.
> 
> That's a good idea; done.
> 
> robey

Looking at my svn branch of lsprof.py, it has the indenting that I
switched to. Where 'if e.calls'  is on the same level as 'if not
isinstance'. That was the major difference between the bzr one and the
lsprof.py one.

I think we can leave in ddaa's patch. The indentation bug existed before
his patch. We can have someone else try and get calltree output if you
don't feel like messing with it.

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060620/e143bcc9/attachment.pgp 


More information about the bazaar mailing list