Rev 28: Relax the constraint on latency format, 1 minute was too restrictive in http://code.launchpad.net/%7Ev-ladeuil/bzr/transportstats

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Dec 5 09:19:46 GMT 2007


At http://code.launchpad.net/%7Ev-ladeuil/bzr/transportstats

------------------------------------------------------------
revno: 28
revision-id:v.ladeuil+lp at free.fr-20071205091943-bmh501x3vngt5pxa
parent: v.ladeuil+lp at free.fr-20071204105555-5fj1gsy124mnjxov
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: transportstats
timestamp: Wed 2007-12-05 10:19:43 +0100
message:
  Relax the constraint on latency format, 1 minute was too restrictive
  given that the actual measure is imprecise (to say the least) and that
  known cases exist where it may be well above (when the latency measured
  includes the download of several MB).
  
  * statsfile.py:
  (StatsFile): Bump format, latency is now a long.
  
  * stats.py:
  (StatsRegistry): latency is a long.
  
  * decorator.py:
  (StatsCollector): Limiting latency to 1 minute to be able to store
  in on a short is uselss, get rid of that and use a long.
modified:
  __init__.py                    __init__.py-20070926152400-0tt23m760160wbva-1
  decorator.py                   decorator.py-20070926152401-52kuiex1mu755ajk-1
  stats.py                       stats.py-20070928061304-7i3r2h4gg6rbi03e-1
  statsfile.py                   structuredfile.py-20070927123433-krruwbx4mkalu3xs-1
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2007-10-07 14:15:30 +0000
+++ b/__init__.py	2007-12-05 09:19:43 +0000
@@ -24,13 +24,11 @@
 
 from bzrlib.plugins.transportstats import commands
 
-transport.register_transport_proto('stats+',
-                                   help="This modifier collect stats"
-                                   " while using the transport."
-                                   )
-transport.register_lazy_transport('stats+',
-                                  'bzrlib.plugins.transportstats.decorator',
-                                  'StatsCollector')
+transport.register_transport_proto(
+    'stats+', help='This modifier collect stats while using the transport.'
+    )
+transport.register_lazy_transport(
+    'stats+', 'bzrlib.plugins.transportstats.decorator', 'StatsCollector')
 
 bzrlib.commands.register_command(commands.cmd_ts_reset)
 bzrlib.commands.register_command(commands.cmd_ts_display)

=== modified file 'decorator.py'
--- a/decorator.py	2007-10-09 07:11:09 +0000
+++ b/decorator.py	2007-12-05 09:19:43 +0000
@@ -34,16 +34,18 @@
 from bzrlib.transport import decorator
 """)
 
+MAX_LATENCY = 2**32 - 1
 
 class StatsCollector(decorator.TransportDecorator):
     """A decorator that collect statistics.
 
     This is requested via the 'stats+' prefix to get_transport().
 
-    Latency is represented with an unsigned short number of miliseconds. Above
-    the minute latencies are considered pathological enough to be ignored.  The
+    Latency is represented with an unsigned long number of miliseconds.The
     latency measured here represents an estimate of the time between request
-    sending and response receiving.
+    sending and response receiving. It can be largely overestimated if the
+    transport doesn't allow a measure point before transferring large chunks of
+    data.
     """
 
     def __init__(self, *args):
@@ -60,8 +62,9 @@
         self.__start_time = time.time()
 
     def __latency(self):
+        # Convert to int and cap
         latency = int((time.time() - self.__start_time) * 1000)
-        return max(0, min(65535, latency))
+        return max(0, min(MAX_LATENCY, latency))
 
     def __pump_to_tmp(self, f):
         """Copy the file-like object content to a temp file.

=== modified file 'stats.py'
--- a/stats.py	2007-11-26 09:53:37 +0000
+++ b/stats.py	2007-12-05 09:19:43 +0000
@@ -107,39 +107,39 @@
 # Shortcut
 register_stat = stats_registry.register
 register_stat('Transport.append_file', TransportStat,
-              '%(base)us%(relpath)us%(bytes_written)L%(latency)H')
+              '%(base)us%(relpath)us%(bytes_written)L%(latency)L')
 register_stat('Transport.append_bytes', TransportStat,
-              '%(base)us%(relpath)us%(bytes_written)L%(latency)H')
+              '%(base)us%(relpath)us%(bytes_written)L%(latency)L')
 register_stat('Transport.delete', TransportStat,
-              '%(base)us%(relpath)us%(latency)H')
+              '%(base)us%(relpath)us%(latency)L')
 register_stat('Transport.delete_tree', TransportStat,
-              '%(base)us%(relpath)us%(latency)H')
+              '%(base)us%(relpath)us%(latency)L')
 register_stat('Transport.get', TransportStat,
-              '%(base)us%(relpath)us%(bytes_read)L%(latency)H')
+              '%(base)us%(relpath)us%(bytes_read)L%(latency)L')
 register_stat('Transport.get_bytes', TransportStat,
-              '%(base)us%(relpath)us%(bytes_read)L%(latency)H')
+              '%(base)us%(relpath)us%(bytes_read)L%(latency)L')
 register_stat('Transport.has', TransportStat,
-              '%(base)us%(relpath)us%(latency)H')
+              '%(base)us%(relpath)us%(latency)L')
 register_stat('Transport.mkdir', TransportStat,
-              '%(base)us%(relpath)us%(latency)H')
+              '%(base)us%(relpath)us%(latency)L')
 register_stat('Transport.put_file', TransportStat,
-              '%(base)us%(relpath)us%(bytes_written)L%(latency)H')
+              '%(base)us%(relpath)us%(bytes_written)L%(latency)L')
 register_stat('Transport.put_bytes', TransportStat,
-              '%(base)us%(relpath)us%(bytes_written)L%(latency)H')
+              '%(base)us%(relpath)us%(bytes_written)L%(latency)L')
 register_stat('Transport.readv', TransportStat,
-              '%(base)us%(relpath)us%(latency)H')
+              '%(base)us%(relpath)us%(latency)L')
 register_stat('Transport.readv/offset', TransportReadvOffset,
               '%(base)us%(relpath)us%(offset)L%(bytes_read)L')
 register_stat('Transport.rename', TransportStat,
-              '%(base)us%(relpath)us%(target)us%(latency)H')
+              '%(base)us%(relpath)us%(target)us%(latency)L')
 register_stat('Transport.rmdir', TransportStat,
-              '%(base)us%(relpath)us%(latency)H')
+              '%(base)us%(relpath)us%(latency)L')
 register_stat('Transport.stat', TransportStat,
-              '%(base)us%(relpath)us%(latency)H')
+              '%(base)us%(relpath)us%(latency)L')
 register_stat('Transport.lock_read', TransportStat,
-              '%(base)us%(relpath)us%(latency)H')
+              '%(base)us%(relpath)us%(latency)L')
 register_stat('Transport.lock_write', TransportStat,
-              '%(base)us%(relpath)us%(latency)H')
+              '%(base)us%(relpath)us%(latency)L')
 
 
 class Stats(object):

=== modified file 'statsfile.py'
--- a/statsfile.py	2007-11-26 09:53:37 +0000
+++ b/statsfile.py	2007-12-05 09:19:43 +0000
@@ -239,7 +239,7 @@
 
 class StatsFile(_file_wrapper):
 
-    _current_format = 'Transport stats Bzr plugin 2'
+    _current_format = 'Transport stats Bzr plugin 3'
     _default_buf_size = 65535
     _header_of = {'file': Header(_current_format),
                   'marker': Header('\xde\xad\xbe\xef'),



More information about the bazaar-commits mailing list