[MERGE] Refactor diffing

Robert Collins robertc at robertcollins.net
Fri Nov 23 22:11:02 GMT 2007


On Fri, 2007-11-23 at 16:53 -0500, Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Robert Collins wrote:
> > On Fri, 2007-11-23 at 14:43 -0500, Aaron Bentley wrote:
> >> Okay, actually this is marked as a high-priority bug, so maybe it should
> >> go into 1.0:
> 
> > My thoughts are:
> >  - is it faster (that is, on (say) bzr.dev, what is the time to do a
> > diff with just a couple of text files changes, with and without the
> > patch. Thats the sort of scenario that that bug refers to.
> 
> The patch makes it slower;
> Without patch (best time):
> real    0m0.627s
> user    0m0.524s
> sys     0m0.088s
> 
> 
> With patch (best time):
> real    0m0.646sI'm getting some strange readings from the LSProf data.
>  AFAICT, it claims that WorkingTree4._get_inventory is being called by
> Tree.id2path.  Which makes no sense, given that id2path is implemented
> on WorkingTree4.
> 
> user    0m0.540s
> sys     0m0.100s
> 
> or 1.03x slower.
> 
> The inventory is still used, but it's an implementation detail of
> Tree.id2path (DirStateRevisionTree does not provide a customized
> implementation of id2path AFAICT).
> 
> According to lsprof: 41% of the time is spent retrieving revisions for
> get_file_mtime.
> 
> For the old version, that's 52%.
> 
> The old version spends 5.23% of its time retrieving the inventory for
> id2path.
> 
> The new version spends 4.05% of its time retrieving the inventory for
> id2path.
> 
> Anyone feel like implementing id2path on DirStateRevisionTree?

So, this patch goes a long way towards fixing the bug, but its not fixed
yet :).


    def id2path(self, file_id):
        "Convert a file-id to a path."
        entry = self._get_entry(file_id=file_id)
        if entry == (None, None):
            raise errors.NoSuchId(tree=self, file_id=file_id)
        path_utf8 = osutils.pathjoin(entry[0][0], entry[0][1])
        return path_utf8.decode('utf8')

That should do it and pass the interface tests.

-Rob

-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20071124/0512066f/attachment-0001.pgp 


More information about the bazaar mailing list