##// END OF EJS Templates
perf: change the way we approach revlog reading...
marmoute -
r51901:2f1967ff default
parent child Browse files
Show More
@@ -3744,16 +3744,20 b' def perfrevlogchunks(ui, repo, file_=Non'
3744 3744
3745 3745 revs = list(rl.revs(startrev, len(rl) - 1))
3746 3746
3747 def rlfh(rl):
3748 if rl._inline:
3747 @contextlib.contextmanager
3748 def reading(rl):
3749 if getattr(rl, 'reading', None) is not None:
3750 with rl.reading():
3751 yield None
3752 elif rl._inline:
3749 3753 indexfile = getattr(rl, '_indexfile', None)
3750 3754 if indexfile is None:
3751 3755 # compatibility with <= hg-5.8
3752 3756 indexfile = getattr(rl, 'indexfile')
3753 return getsvfs(repo)(indexfile)
3757 yield getsvfs(repo)(indexfile)
3754 3758 else:
3755 3759 datafile = getattr(rl, 'datafile', getattr(rl, 'datafile'))
3756 return getsvfs(repo)(datafile)
3760 yield getsvfs(repo)(datafile)
3757 3761
3758 3762 def doread():
3759 3763 rl.clearcaches()
@@ -3762,9 +3766,13 b' def perfrevlogchunks(ui, repo, file_=Non'
3762 3766
3763 3767 def doreadcachedfh():
3764 3768 rl.clearcaches()
3765 fh = rlfh(rl)
3766 for rev in revs:
3767 segmentforrevs(rev, rev, df=fh)
3769 with reading(rl) as fh:
3770 if fh is not None:
3771 for rev in revs:
3772 segmentforrevs(rev, rev, df=fh)
3773 else:
3774 for rev in revs:
3775 segmentforrevs(rev, rev)
3768 3776
3769 3777 def doreadbatch():
3770 3778 rl.clearcaches()
@@ -3772,22 +3780,33 b' def perfrevlogchunks(ui, repo, file_=Non'
3772 3780
3773 3781 def doreadbatchcachedfh():
3774 3782 rl.clearcaches()
3775 fh = rlfh(rl)
3776 segmentforrevs(revs[0], revs[-1], df=fh)
3783 with reading(rl) as fh:
3784 if fh is not None:
3785 segmentforrevs(revs[0], revs[-1], df=fh)
3786 else:
3787 segmentforrevs(revs[0], revs[-1])
3777 3788
3778 3789 def dochunk():
3779 3790 rl.clearcaches()
3780 fh = rlfh(rl)
3781 for rev in revs:
3782 rl._chunk(rev, df=fh)
3791 with reading(rl) as fh:
3792 if fh is not None:
3793 for rev in revs:
3794 rl._chunk(rev, df=fh)
3795 else:
3796 for rev in revs:
3797 rl._chunk(rev)
3783 3798
3784 3799 chunks = [None]
3785 3800
3786 3801 def dochunkbatch():
3787 3802 rl.clearcaches()
3788 fh = rlfh(rl)
3789 # Save chunks as a side-effect.
3790 chunks[0] = rl._chunks(revs, df=fh)
3803 with reading(rl) as fh:
3804 if fh is not None:
3805 # Save chunks as a side-effect.
3806 chunks[0] = rl._chunks(revs, df=fh)
3807 else:
3808 # Save chunks as a side-effect.
3809 chunks[0] = rl._chunks(revs)
3791 3810
3792 3811 def docompress(compressor):
3793 3812 rl.clearcaches()
General Comments 0
You need to be logged in to leave comments. Login now