##// END OF EJS Templates
revlog: use file read caching for sidedata...
Simon Sapin -
r48219:cac0e062 default
parent child Browse files
Show More
@@ -455,6 +455,7 b' class changelog(revlog.revlog):'
455 self._realopener, self._indexfile, self._delaybuf
455 self._realopener, self._indexfile, self._delaybuf
456 )
456 )
457 self._segmentfile.opener = self.opener
457 self._segmentfile.opener = self.opener
458 self._segmentfile_sidedata.opener = self.opener
458 self._delayed = True
459 self._delayed = True
459 tr.addpending(b'cl-%i' % id(self), self._writepending)
460 tr.addpending(b'cl-%i' % id(self), self._writepending)
460 tr.addfinalize(b'cl-%i' % id(self), self._finalize)
461 tr.addfinalize(b'cl-%i' % id(self), self._finalize)
@@ -464,6 +465,7 b' class changelog(revlog.revlog):'
464 self._delayed = False
465 self._delayed = False
465 self.opener = self._realopener
466 self.opener = self._realopener
466 self._segmentfile.opener = self.opener
467 self._segmentfile.opener = self.opener
468 self._segmentfile_sidedata.opener = self.opener
467 # move redirected index data back into place
469 # move redirected index data back into place
468 if self._docket is not None:
470 if self._docket is not None:
469 self._write_docket(tr)
471 self._write_docket(tr)
@@ -504,6 +506,7 b' class changelog(revlog.revlog):'
504 self._divert = True
506 self._divert = True
505 self.opener = _divertopener(self._realopener, self._indexfile)
507 self.opener = _divertopener(self._realopener, self._indexfile)
506 self._segmentfile.opener = self.opener
508 self._segmentfile.opener = self.opener
509 self._segmentfile_sidedata.opener = self.opener
507
510
508 if self._divert:
511 if self._divert:
509 return True
512 return True
@@ -629,6 +629,11 b' class revlog(object):'
629 self._chunkcachesize,
629 self._chunkcachesize,
630 chunkcache,
630 chunkcache,
631 )
631 )
632 self._segmentfile_sidedata = randomaccessfile.randomaccessfile(
633 self.opener,
634 self._sidedatafile,
635 self._chunkcachesize,
636 )
632 # revnum -> (chain-length, sum-delta-length)
637 # revnum -> (chain-length, sum-delta-length)
633 self._chaininfocache = util.lrucachedict(500)
638 self._chaininfocache = util.lrucachedict(500)
634 # revlog header -> revlog compressor
639 # revlog header -> revlog compressor
@@ -782,6 +787,7 b' class revlog(object):'
782 self._revisioncache = None
787 self._revisioncache = None
783 self._chainbasecache.clear()
788 self._chainbasecache.clear()
784 self._segmentfile.clear_cache()
789 self._segmentfile.clear_cache()
790 self._segmentfile_sidedata.clear_cache()
785 self._pcache = {}
791 self._pcache = {}
786 self._nodemap_docket = None
792 self._nodemap_docket = None
787 self.index.clearcaches()
793 self.index.clearcaches()
@@ -1916,8 +1922,6 b' class revlog(object):'
1916 if sidedata_size == 0:
1922 if sidedata_size == 0:
1917 return {}
1923 return {}
1918
1924
1919 # XXX this need caching, as we do for data
1920 with self._sidedatareadfp() as sdf:
1921 if self._docket.sidedata_end < sidedata_offset + sidedata_size:
1925 if self._docket.sidedata_end < sidedata_offset + sidedata_size:
1922 filename = self._sidedatafile
1926 filename = self._sidedatafile
1923 end = self._docket.sidedata_end
1927 end = self._docket.sidedata_end
@@ -1926,21 +1930,9 b' class revlog(object):'
1926 m = FILE_TOO_SHORT_MSG % (filename, length, offset, end)
1930 m = FILE_TOO_SHORT_MSG % (filename, length, offset, end)
1927 raise error.RevlogError(m)
1931 raise error.RevlogError(m)
1928
1932
1929 sdf.seek(sidedata_offset, os.SEEK_SET)
1933 comp_segment = self._segmentfile_sidedata.read_chunk(
1930 comp_segment = sdf.read(sidedata_size)
1934 sidedata_offset, sidedata_size
1931
1932 if len(comp_segment) < sidedata_size:
1933 filename = self._sidedatafile
1934 length = sidedata_size
1935 offset = sidedata_offset
1936 got = len(comp_segment)
1937 m = randomaccessfile.PARTIAL_READ_MSG % (
1938 filename,
1939 length,
1940 offset,
1941 got,
1942 )
1935 )
1943 raise error.RevlogError(m)
1944
1936
1945 comp = self.index[rev][11]
1937 comp = self.index[rev][11]
1946 if comp == COMP_MODE_PLAIN:
1938 if comp == COMP_MODE_PLAIN:
@@ -2033,6 +2025,9 b' class revlog(object):'
2033 # its usage.
2025 # its usage.
2034 self._writinghandles = None
2026 self._writinghandles = None
2035 self._segmentfile.writing_handle = None
2027 self._segmentfile.writing_handle = None
2028 # No need to deal with sidedata writing handle as it is only
2029 # relevant with revlog-v2 which is never inline, not reaching
2030 # this code
2036
2031
2037 new_dfh = self._datafp(b'w+')
2032 new_dfh = self._datafp(b'w+')
2038 new_dfh.truncate(0) # drop any potentially existing data
2033 new_dfh.truncate(0) # drop any potentially existing data
@@ -2080,6 +2075,9 b' class revlog(object):'
2080 self._writinghandles = (ifh, new_dfh, None)
2075 self._writinghandles = (ifh, new_dfh, None)
2081 self._segmentfile.writing_handle = new_dfh
2076 self._segmentfile.writing_handle = new_dfh
2082 new_dfh = None
2077 new_dfh = None
2078 # No need to deal with sidedata writing handle as it is only
2079 # relevant with revlog-v2 which is never inline, not reaching
2080 # this code
2083 finally:
2081 finally:
2084 if new_dfh is not None:
2082 if new_dfh is not None:
2085 new_dfh.close()
2083 new_dfh.close()
@@ -2138,12 +2136,14 b' class revlog(object):'
2138 # exposing all file handle for writing.
2136 # exposing all file handle for writing.
2139 self._writinghandles = (ifh, dfh, sdfh)
2137 self._writinghandles = (ifh, dfh, sdfh)
2140 self._segmentfile.writing_handle = ifh if self._inline else dfh
2138 self._segmentfile.writing_handle = ifh if self._inline else dfh
2139 self._segmentfile_sidedata.writing_handle = sdfh
2141 yield
2140 yield
2142 if self._docket is not None:
2141 if self._docket is not None:
2143 self._write_docket(transaction)
2142 self._write_docket(transaction)
2144 finally:
2143 finally:
2145 self._writinghandles = None
2144 self._writinghandles = None
2146 self._segmentfile.writing_handle = None
2145 self._segmentfile.writing_handle = None
2146 self._segmentfile_sidedata.writing_handle = None
2147 if dfh is not None:
2147 if dfh is not None:
2148 dfh.close()
2148 dfh.close()
2149 if sdfh is not None:
2149 if sdfh is not None:
@@ -2778,6 +2778,7 b' class revlog(object):'
2778 self._revisioncache = None
2778 self._revisioncache = None
2779 self._chaininfocache = util.lrucachedict(500)
2779 self._chaininfocache = util.lrucachedict(500)
2780 self._segmentfile.clear_cache()
2780 self._segmentfile.clear_cache()
2781 self._segmentfile_sidedata.clear_cache()
2781
2782
2782 del self.index[rev:-1]
2783 del self.index[rev:-1]
2783
2784
General Comments 0
You need to be logged in to leave comments. Login now