Commit 403f9869 authored by dieter's avatar dieter

fsdump/fsstats improvements

parent 1fb097b4
...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
5.6.1 (unreleased) 5.6.1 (unreleased)
================== ==================
- Readd transaction size information to ``fsdump`` output;
adapt `fsstats` to ``fsdump``'s exchanged order for ``size`` and ``class``
information in data records;
(fixes `#354 <https://github.com/zopefoundation/ZODB/issues/354>_).
Make ``fsdump`` callable via Python's ``-m`` command line option.
- Fix UnboundLocalError when running fsoids.py script. - Fix UnboundLocalError when running fsoids.py script.
See `issue 285 <https://github.com/zopefoundation/ZODB/issues/285>`_. See `issue 285 <https://github.com/zopefoundation/ZODB/issues/285>`_.
......
...@@ -23,12 +23,14 @@ from ZODB.utils import u64, get_pickle_metadata ...@@ -23,12 +23,14 @@ from ZODB.utils import u64, get_pickle_metadata
def fsdump(path, file=None, with_offset=1): def fsdump(path, file=None, with_offset=1):
iter = FileIterator(path) iter = FileIterator(path)
for i, trans in enumerate(iter): for i, trans in enumerate(iter):
size = trans._tend - trans._tpos
if with_offset: if with_offset:
print(("Trans #%05d tid=%016x time=%s offset=%d" % print(("Trans #%05d tid=%016x size=%d time=%s offset=%d" %
(i, u64(trans.tid), TimeStamp(trans.tid), trans._pos)), file=file) (i, u64(trans.tid), size,
TimeStamp(trans.tid), trans._pos)), file=file)
else: else:
print(("Trans #%05d tid=%016x time=%s" % print(("Trans #%05d tid=%016x size=%d time=%s" %
(i, u64(trans.tid), TimeStamp(trans.tid))), file=file) (i, u64(trans.tid), size, TimeStamp(trans.tid))), file=file)
print((" status=%r user=%r description=%r" % print((" status=%r user=%r description=%r" %
(trans.status, trans.user, trans.description)), file=file) (trans.status, trans.user, trans.description)), file=file)
...@@ -122,3 +124,7 @@ class Dumper(object): ...@@ -122,3 +124,7 @@ class Dumper(object):
def main(): def main():
import sys import sys
fsdump(sys.argv[1]) fsdump(sys.argv[1])
if __name__ == "__main__":
main()
...@@ -7,7 +7,7 @@ import six ...@@ -7,7 +7,7 @@ import six
from six.moves import filter from six.moves import filter
rx_txn = re.compile("tid=([0-9a-f]+).*size=(\d+)") rx_txn = re.compile("tid=([0-9a-f]+).*size=(\d+)")
rx_data = re.compile("oid=([0-9a-f]+) class=(\S+) size=(\d+)") rx_data = re.compile("oid=([0-9a-f]+) size=(\d+) class=(\S+)")
def sort_byhsize(seq, reverse=False): def sort_byhsize(seq, reverse=False):
L = [(v.size(), k, v) for k, v in seq] L = [(v.size(), k, v) for k, v in seq]
...@@ -50,7 +50,10 @@ class Histogram(dict): ...@@ -50,7 +50,10 @@ class Histogram(dict):
return mode return mode
def make_bins(self, binsize): def make_bins(self, binsize):
maxkey = max(six.iterkeys(self)) try:
maxkey = max(six.iterkeys(self))
except ValueError:
maxkey = 0
self.binsize = binsize self.binsize = binsize
self.bins = [0] * (1 + maxkey / binsize) self.bins = [0] * (1 + maxkey / binsize)
for k, v in six.iteritems(self): for k, v in six.iteritems(self):
...@@ -104,7 +107,7 @@ def class_detail(class_size): ...@@ -104,7 +107,7 @@ def class_detail(class_size):
# per class details # per class details
for klass, h in sort_byhsize(six.iteritems(class_size), reverse=True): for klass, h in sort_byhsize(six.iteritems(class_size), reverse=True):
h.make_bins(50) h.make_bins(50)
if len(filter(None, h.bins)) == 1: if len(tuple(filter(None, h.bins))) == 1:
continue continue
h.report("Object size for %s" % klass, usebins=True) h.report("Object size for %s" % klass, usebins=True)
...@@ -146,7 +149,7 @@ def main(path=None): ...@@ -146,7 +149,7 @@ def main(path=None):
m = rx_data.search(line) m = rx_data.search(line)
if not m: if not m:
continue continue
oid, klass, size = m.groups() oid, size, klass = m.groups()
size = int(size) size = int(size)
obj_size.add(size) obj_size.add(size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment