~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-11 05:25:40 UTC
  • mfrom: (4326.2.4 report-vfs-calls)
  • Revision ID: pqm@pqm.ubuntu.com-20090511052540-r3l0iwm1uo716iv0
(jml) Show number of VFS calls when using -Dhpss.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    ui,
44
44
    urlutils,
45
45
    )
46
 
from bzrlib.smart import client, protocol
 
46
from bzrlib.smart import client, protocol, request, vfs
47
47
from bzrlib.transport import ssh
48
48
""")
49
49
 
509
509
        """
510
510
        medium_repr = repr(medium)
511
511
        # Add this medium to the WeakKeyDictionary
512
 
        self.counts[medium] = [0, medium_repr]
 
512
        self.counts[medium] = dict(count=0, vfs_count=0,
 
513
                                   medium_repr=medium_repr)
513
514
        # Weakref callbacks are fired in reverse order of their association
514
515
        # with the referenced object.  So we add a weakref *after* adding to
515
516
        # the WeakKeyDict so that we can report the value from it before the
519
520
    def increment_call_count(self, params):
520
521
        # Increment the count in the WeakKeyDictionary
521
522
        value = self.counts[params.medium]
522
 
        value[0] += 1
 
523
        value['count'] += 1
 
524
        request_method = request.request_handlers.get(params.method)
 
525
        if issubclass(request_method, vfs.VfsRequest):
 
526
            value['vfs_count'] += 1
523
527
 
524
528
    def done(self, ref):
525
529
        value = self.counts[ref]
526
 
        count, medium_repr = value
 
530
        count, vfs_count, medium_repr = (
 
531
            value['count'], value['vfs_count'], value['medium_repr'])
527
532
        # In case this callback is invoked for the same ref twice (by the
528
533
        # weakref callback and by the atexit function), set the call count back
529
534
        # to 0 so this item won't be reported twice.
530
 
        value[0] = 0
 
535
        value['count'] = 0
 
536
        value['vfs_count'] = 0
531
537
        if count != 0:
532
 
            trace.note('HPSS calls: %d %s', count, medium_repr)
 
538
            trace.note('HPSS calls: %d (%d vfs) %s',
 
539
                       count, vfs_count, medium_repr)
533
540
 
534
541
    def flush_all(self):
535
542
        for ref in list(self.counts.keys()):