[MERGE] Extend -Dhpss to emit a count of HPSS calls to stderr

Andrew Bennetts andrew at canonical.com
Fri Sep 26 00:17:14 BST 2008


John Arbash Meinel wrote:
[...]
> 
> I'll mention that "-Dmemory" writes out using "trace.note()" which both
> writes to sys.stderr *and* to .bzr.log, which I think is a good way to
> do it. It means you can capture the value for long term, and see it
> right away.

It probably is a good idea to write to do the trace.note as well.  I'll add
that.

[...]
> > I have an alternative version of this patch (also attached, as a diff
> > relative to this change, I hope it doesn't confuse BB), that installs a
> > single hook function (rather than one per medium).  The hook function
> > then had to find the matching weakref for the medium being used, which
> > didn't seem as straightforward to me.  Also that approach conflicts more
> > with the test suite, which resets hooks after each test, but this hook
> > is only installed once per process.
> 
> I probably prefer the latter one. Instead of searching, you could use
> the repr(ref) to index into a dict, or id(medium). You could even get
> rid of the weakref code entirely by doing:
> 
> def __init__
>   self.counts = {}
> 
> def track(self, medium):
> 
>   medium_info = (0, repr(medium))
>   self.counts[id(medium)] = medium_info
> 
> That doesn't give you a 'done' callback, but we could just live with atexit.

I considered using repr(medium) as the dict key, but it isn't robust.  It's
possible (if unlikely) for two media to have the same repr: memory addresses get
re-used, and also someone might one day decide to change SmartClientMedium's
repr to omit the id.

It is harder, but not *that* much harder, to do it robustly with weakrefs, so I
did.

-Andrew.




More information about the bazaar mailing list