Rev 3755: Extend -Dhpss flag to report HPSS call count on stderr. (Andrew in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Oct 1 07:49:13 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3755
revision-id: pqm at pqm.ubuntu.com-20081001064910-typ6d7diwd53z6iv
parent: pqm at pqm.ubuntu.com-20081001013215-ouj6gl6fwotdoj7n
parent: andrew.bennetts at canonical.com-20081001061017-z97p3m0n9qqjzklf
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-10-01 07:49:10 +0100
message:
Extend -Dhpss flag to report HPSS call count on stderr. (Andrew
Bennetts)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/smart/client.py client.py-20061116014825-2k6ada6xgulslami-1
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
------------------------------------------------------------
revno: 3731.2.7
revision-id: andrew.bennetts at canonical.com-20081001061017-z97p3m0n9qqjzklf
parent: andrew.bennetts at canonical.com-20081001060919-bfgpvsmpq9bvpgnr
parent: pqm at pqm.ubuntu.com-20080930002605-dfe533l96sx35va8
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-call-count
timestamp: Wed 2008-10-01 16:10:17 +1000
message:
Merge from bzr.dev
removed:
bzrlib/_walkdirs_win32.h _walkdirs_win32.h-20080716220454-kweh3tgxez5dvw2l-1
added:
bzrlib/python-compat.h pythoncompat.h-20080924041409-9kvi0fgtuuqp743j-1
bzrlib/tests/workingtree_implementations/test_get_file_with_stat.py test_get_file_with_s-20080922035909-lhdovrr36jpxmu0v-1
doc/developers/lca_tree_merging.txt lca_merge_resolution-20080731173903-8ku77uz7o6smd3jj-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/_btree_serializer_c.pyx _parse_btree_c.pyx-20080703034413-3q25bklkenti3p8p-2
bzrlib/_dirstate_helpers_c.pyx dirstate_helpers.pyx-20070503201057-u425eni465q4idwn-3
bzrlib/_dirstate_helpers_py.py _dirstate_helpers_py-20070710145033-90nz6cqglsk150jy-1
bzrlib/_patiencediff_c.c _patiencediff_c.c-20070721205602-q3imkipwlgagp3cy-1
bzrlib/_readdir_pyx.pyx readdir.pyx-20060609152855-rm6v321vuaqyh9tu-1
bzrlib/_walkdirs_win32.pyx _walkdirs_win32.pyx-20080716220454-kweh3tgxez5dvw2l-2
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/branchbuilder.py branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
bzrlib/btree_index.py index.py-20080624222253-p0x5f92uyh5hw734-7
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/delta.py delta.py-20050729221636-54cf14ef94783d0a
bzrlib/diff.py diff.py-20050309040759-26944fbbf2ebbf36
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/hashcache.py hashcache.py-20050706091756-fe3a8cc1143ff24f
bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/memorytree.py memorytree.py-20060906023413-4wlkalbdpsxi2r4y-1
bzrlib/merge.py merge.py-20050513021216-953b65a438527106
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/revisionspec.py revisionspec.py-20050907152633-17567659fd5c0ddb
bzrlib/status.py status.py-20050505062338-431bfa63ec9b19e6
bzrlib/testament.py testament.py-20051011100429-6d319a18183b13c8
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_annotate.py testannotate.py-20051013044000-457f44801bfa9d39
bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
bzrlib/tests/http_server.py httpserver.py-20061012142527-m1yxdj1xazsf8d7s-1
bzrlib/tests/http_utils.py HTTPTestUtil.py-20050914180604-247d3aafb7a43343
bzrlib/tests/intertree_implementations/__init__.py __init__.py-20060724101752-09ysswo1a92uqyoz-3
bzrlib/tests/per_repository/test_check_reconcile.py test_broken.py-20070928125406-62236394w0jpbpd6-2
bzrlib/tests/per_repository/test_commit_builder.py test_commit_builder.py-20060606110838-76e3ra5slucqus81-1
bzrlib/tests/test__dirstate_helpers.py test_dirstate_helper-20070504035751-jsbn00xodv0y1eve-2
bzrlib/tests/test_branchbuilder.py test_branchbuilder.p-20070427022007-zlxpqz2lannhk6y8-2
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
bzrlib/tests/test_hashcache.py testhashcache.py-20050706091800-0288ab2659338981
bzrlib/tests/test_http.py testhttp.py-20051018020158-b2eef6e867c514d9
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
bzrlib/tests/test_log.py testlog.py-20050728115707-1a514809d7d49309
bzrlib/tests/test_memorytree.py test_memorytree.py-20060906023413-4wlkalbdpsxi2r4y-3
bzrlib/tests/test_merge.py testmerge.py-20050905070950-c1b5aa49ff911024
bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
bzrlib/tests/test_revisionspec.py testrevisionnamespaces.py-20050711050225-8b4af89e6b1efe84
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
bzrlib/tests/test_sftp_transport.py testsftp.py-20051027032739-247570325fec7e7e
bzrlib/tests/test_testament.py testtestament.py-20051011100429-5df1657310caa929
bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
bzrlib/tests/test_workingtree_4.py test_workingtree_4.p-20070223025758-531n3tznl3zacv2o-1
bzrlib/tests/tree_implementations/test_tree.py test_tree.py-20061215160206-usu7lwcj8aq2n3br-1
bzrlib/tests/workingtree_implementations/__init__.py __init__.py-20060203003124-b2aa5aca21a8bfad
bzrlib/trace.py trace.py-20050309040759-c8ed824bdcd4748a
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/http/__init__.py http_transport.py-20050711212304-506c5fd1059ace96
bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
bzrlib/transport/http/wsgi.py wsgi.py-20061005091552-rz8pva0olkxv0sd8-2
bzrlib/transport/remote.py ssh.py-20060608202016-c25gvf1ob7ypbus6-1
bzrlib/tree.py tree.py-20050309040759-9d5f2496be663e77
bzrlib/tuned_gzip.py tuned_gzip.py-20060407014720-5aadc518e928e8d2
bzrlib/util/configobj/configobj.py configobj.py-20051018184548-06992a2246425e3e
bzrlib/weave.py knit.py-20050627021749-759c29984154256b
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
doc/developers/development-repo.txt developmentrepo.txt-20080102200205-raj42k61dch8pjmj-1
doc/developers/inventory.txt inventory.txt-20080103013957-opkrhxy6lmywmx4i-1
doc/en/user-guide/http_smart_server.txt fastcgi.txt-20061005091552-rz8pva0olkxv0sd8-3
setup.py setup.py-20050314065409-02f8a0a6e3f9bc70
------------------------------------------------------------
revno: 3731.2.6
revision-id: andrew.bennetts at canonical.com-20081001060919-bfgpvsmpq9bvpgnr
parent: andrew.bennetts at canonical.com-20081001012020-6pqq6p6xuu4orjr6
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-call-count
timestamp: Wed 2008-10-01 16:09:19 +1000
message:
Add NEWS entry.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 3731.2.5
revision-id: andrew.bennetts at canonical.com-20081001012020-6pqq6p6xuu4orjr6
parent: andrew.bennetts at canonical.com-20080925060210-h6gv3xs9s91lewl9
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-call-count
timestamp: Wed 2008-10-01 11:20:20 +1000
message:
Rework hpss call counter.
modified:
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
------------------------------------------------------------
revno: 3731.2.4
revision-id: andrew.bennetts at canonical.com-20080925060210-h6gv3xs9s91lewl9
parent: andrew.bennetts at canonical.com-20080925045055-32udmv9r80b4v130
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-call-count
timestamp: Thu 2008-09-25 16:02:10 +1000
message:
Minor tweaks.
modified:
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
------------------------------------------------------------
revno: 3731.2.3
revision-id: andrew.bennetts at canonical.com-20080925045055-32udmv9r80b4v130
parent: andrew.bennetts at canonical.com-20080925040625-84addwyxwwcnl2hg
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-call-count
timestamp: Thu 2008-09-25 14:50:55 +1000
message:
Remove unnecessary change to disconnect methods.
modified:
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
------------------------------------------------------------
revno: 3731.2.2
revision-id: andrew.bennetts at canonical.com-20080925040625-84addwyxwwcnl2hg
parent: andrew.bennetts at canonical.com-20080924134644-wu29mrcljknmpdpz
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-call-count
timestamp: Thu 2008-09-25 14:06:25 +1000
message:
Iterate over a copy of _atexit_counters, because it is mutated during iteration.
modified:
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
------------------------------------------------------------
revno: 3731.2.1
revision-id: andrew.bennetts at canonical.com-20080924134644-wu29mrcljknmpdpz
parent: pqm at pqm.ubuntu.com-20080924014325-ucivgbdmsbuthnqw
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss-call-count
timestamp: Wed 2008-09-24 23:46:44 +1000
message:
Show total HPSS calls (if any) on stderr when -Dhpss is active.
modified:
bzrlib/smart/client.py client.py-20061116014825-2k6ada6xgulslami-1
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
=== modified file 'NEWS'
--- a/NEWS 2008-09-29 07:12:37 +0000
+++ b/NEWS 2008-10-01 06:10:17 +0000
@@ -63,6 +63,10 @@
* The C extensions now build on python 2.4 (Robert Collins, #271939)
+ * The ``-Dhpss`` debug flag now reports the number of smart server
+ calls per medium to stderr. This is in addition to the existing
+ detailed logging to the .bzr.log trace file. (Andrew Bennetts)
+
BUG FIXES:
* Branching from a shared repository on a smart server into a new
=== modified file 'bzrlib/smart/client.py'
--- a/bzrlib/smart/client.py 2008-09-16 05:41:24 +0000
+++ b/bzrlib/smart/client.py 2008-09-24 13:46:44 +0000
@@ -56,7 +56,7 @@
def _run_call_hooks(self, method, args, body, readv_body):
if not _SmartClient.hooks['call']:
return
- params = CallHookParams(method, args, body, readv_body)
+ params = CallHookParams(method, args, body, readv_body, self._medium)
for hook in _SmartClient.hooks['call']:
hook(params)
@@ -187,11 +187,12 @@
class CallHookParams(object):
- def __init__(self, method, args, body, readv_body):
+ def __init__(self, method, args, body, readv_body, medium):
self.method = method
self.args = args
self.body = body
self.readv_body = readv_body
+ self.medium = medium
def __repr__(self):
attrs = dict((k, v) for (k, v) in self.__dict__.iteritems()
=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py 2008-09-19 10:12:18 +0000
+++ b/bzrlib/smart/medium.py 2008-10-01 01:20:20 +0000
@@ -31,13 +31,17 @@
from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
+import atexit
+import weakref
from bzrlib import (
+ debug,
errors,
osutils,
symbol_versioning,
+ trace,
urlutils,
)
-from bzrlib.smart import protocol
+from bzrlib.smart import client, protocol
from bzrlib.transport import ssh
""")
@@ -468,6 +472,57 @@
return self._medium._get_line()
+class _DebugCounter(object):
+ """An object that counts the HPSS calls made to each client medium.
+
+ When a medium is garbage-collected, or failing that when atexit functions
+ are run, the total number of calls made on that medium are reported via
+ trace.note.
+ """
+
+ def __init__(self):
+ self.counts = weakref.WeakKeyDictionary()
+ client._SmartClient.hooks.install_named_hook(
+ 'call', self.increment_call_count, 'hpss call counter')
+ atexit.register(self.flush_all)
+
+ def track(self, medium):
+ """Start tracking calls made to a medium.
+
+ This only keeps a weakref to the medium, so shouldn't affect the
+ medium's lifetime.
+ """
+ medium_repr = repr(medium)
+ # Add this medium to the WeakKeyDictionary
+ self.counts[medium] = [0, medium_repr]
+ # Weakref callbacks are fired in reverse order of their association
+ # with the referenced object. So we add a weakref *after* adding to
+ # the WeakKeyDict so that we can report the value from it before the
+ # entry is removed by the WeakKeyDict's own callback.
+ ref = weakref.ref(medium, self.done)
+
+ def increment_call_count(self, params):
+ # Increment the count in the WeakKeyDictionary
+ value = self.counts[params.medium]
+ value[0] += 1
+
+ def done(self, ref):
+ value = self.counts[ref]
+ count, medium_repr = value
+ # In case this callback is invoked for the same ref twice (by the
+ # weakref callback and by the atexit function), set the call count back
+ # to 0 so this item won't be reported twice.
+ value[0] = 0
+ if count != 0:
+ trace.note('HPSS calls: %d %s', count, medium_repr)
+
+ def flush_all(self):
+ for ref in list(self.counts.keys()):
+ self.done(ref)
+
+_debug_counter = None
+
+
class SmartClientMedium(SmartMedium):
"""Smart client is a medium for sending smart protocol requests over."""
@@ -482,6 +537,12 @@
# _remote_version_is_before tracks the bzr version the remote side
# can be based on what we've seen so far.
self._remote_version_is_before = None
+ # Install debug hook function if debug flag is set.
+ if 'hpss' in debug.debug_flags:
+ global _debug_counter
+ if _debug_counter is None:
+ _debug_counter = _DebugCounter()
+ _debug_counter.track(self)
def _is_remote_before(self, version_tuple):
"""Is it possible the remote side supports RPCs for a given version?
More information about the bazaar-commits
mailing list