##// END OF EJS Templates
perf: add command for measuring revlog chunk operations...
Gregory Szorc -
r30451:94ca0e13 default
parent child Browse files
Show More
@@ -859,6 +859,84 b' def perfrevlog(ui, repo, file_=None, sta'
859 859 timer(d)
860 860 fm.end()
861 861
862 @command('perfrevlogchunks', revlogopts + formatteropts +
863 [('s', 'startrev', 0, 'revision to start at')],
864 '-c|-m|FILE')
865 def perfrevlogchunks(ui, repo, file_=None, startrev=0, **opts):
866 """Benchmark operations on revlog chunks.
867
868 Logically, each revlog is a collection of fulltext revisions. However,
869 stored within each revlog are "chunks" of possibly compressed data. This
870 data needs to be read and decompressed or compressed and written.
871
872 This command measures the time it takes to read+decompress and recompress
873 chunks in a revlog. It effectively isolates I/O and compression performance.
874 For measurements of higher-level operations like resolving revisions,
875 see ``perfrevlog`` and ``perfrevlogrevision``.
876 """
877 rl = cmdutil.openrevlog(repo, 'perfrevlogchunks', file_, opts)
878 revs = list(rl.revs(startrev, len(rl) - 1))
879
880 def rlfh(rl):
881 if rl._inline:
882 return getsvfs(repo)(rl.indexfile)
883 else:
884 return getsvfs(repo)(rl.datafile)
885
886 def doread():
887 rl.clearcaches()
888 for rev in revs:
889 rl._chunkraw(rev, rev)
890
891 def doreadcachedfh():
892 rl.clearcaches()
893 fh = rlfh(rl)
894 for rev in revs:
895 rl._chunkraw(rev, rev, df=fh)
896
897 def doreadbatch():
898 rl.clearcaches()
899 rl._chunkraw(revs[0], revs[-1])
900
901 def doreadbatchcachedfh():
902 rl.clearcaches()
903 fh = rlfh(rl)
904 rl._chunkraw(revs[0], revs[-1], df=fh)
905
906 def dochunk():
907 rl.clearcaches()
908 fh = rlfh(rl)
909 for rev in revs:
910 rl._chunk(rev, df=fh)
911
912 chunks = [None]
913
914 def dochunkbatch():
915 rl.clearcaches()
916 fh = rlfh(rl)
917 # Save chunks as a side-effect.
918 chunks[0] = rl._chunks(revs, df=fh)
919
920 def docompress():
921 rl.clearcaches()
922 for chunk in chunks[0]:
923 rl.compress(chunk)
924
925 benches = [
926 (lambda: doread(), 'read'),
927 (lambda: doreadcachedfh(), 'read w/ reused fd'),
928 (lambda: doreadbatch(), 'read batch'),
929 (lambda: doreadbatchcachedfh(), 'read batch w/ reused fd'),
930 (lambda: dochunk(), 'chunk'),
931 (lambda: dochunkbatch(), 'chunk batch'),
932 (lambda: docompress(), 'compress'),
933 ]
934
935 for fn, title in benches:
936 timer, fm = gettimer(ui, opts)
937 timer(fn, title=title)
938 fm.end()
939
862 940 @command('perfrevlogrevision', revlogopts + formatteropts +
863 941 [('', 'cache', False, 'use caches instead of clearing')],
864 942 '-c|-m|FILE REV')
@@ -95,6 +95,8 b' perfstatus'
95 95 (no help text available)
96 96 perfrawfiles (no help text available)
97 97 perfrevlog Benchmark reading a series of revisions from a revlog.
98 perfrevlogchunks
99 Benchmark operations on revlog chunks.
98 100 perfrevlogrevision
99 101 Benchmark obtaining a revlog revision.
100 102 perfrevrange (no help text available)
@@ -144,6 +146,7 b' perfstatus'
144 146 $ hg perfrawfiles 2
145 147 $ hg perfrevlog .hg/store/data/a.i
146 148 $ hg perfrevlogrevision -m 0
149 $ hg perfrevlogchunks -c
147 150 $ hg perfrevrange
148 151 $ hg perfrevset 'all()'
149 152 $ hg perfstartup
General Comments 0
You need to be logged in to leave comments. Login now