721 // Holds a reference to the mmap'ed persistent index data |
721 // Holds a reference to the mmap'ed persistent index data |
722 data index_mmap: RefCell<PyBuffer>; |
722 data index_mmap: RefCell<PyBuffer>; |
723 data head_revs_py_list: RefCell<Option<PyList>>; |
723 data head_revs_py_list: RefCell<Option<PyList>>; |
724 data head_node_ids_py_list: RefCell<Option<PyList>>; |
724 data head_node_ids_py_list: RefCell<Option<PyList>>; |
725 data revision_cache: RefCell<Option<PyObject>>; |
725 data revision_cache: RefCell<Option<PyObject>>; |
|
726 data use_persistent_nodemap: bool; |
726 |
727 |
727 def __new__( |
728 def __new__( |
728 _cls, |
729 _cls, |
729 vfs_base: PyObject, |
730 vfs_base: PyObject, |
730 fncache: PyObject, |
731 fncache: PyObject, |
738 delta_config: PyObject, |
739 delta_config: PyObject, |
739 feature_config: PyObject, |
740 feature_config: PyObject, |
740 chunk_cache: PyObject, |
741 chunk_cache: PyObject, |
741 default_compression_header: PyObject, |
742 default_compression_header: PyObject, |
742 revlog_type: usize, |
743 revlog_type: usize, |
|
744 use_persistent_nodemap: bool, |
743 ) -> PyResult<Self> { |
745 ) -> PyResult<Self> { |
744 Self::inner_new( |
746 Self::inner_new( |
745 py, |
747 py, |
746 vfs_base, |
748 vfs_base, |
747 fncache, |
749 fncache, |
1106 } |
1109 } |
1107 |
1110 |
1108 // -- forwarded index methods -- |
1111 // -- forwarded index methods -- |
1109 |
1112 |
1110 def _index_get_rev(&self, node: PyBytes) -> PyResult<Option<PyRevision>> { |
1113 def _index_get_rev(&self, node: PyBytes) -> PyResult<Option<PyRevision>> { |
|
1114 let node = node_from_py_bytes(py, &node)?; |
|
1115 // Filelogs have no persistent nodemaps and are often small, use a |
|
1116 // brute force lookup from the end backwards. If there is a very large |
|
1117 // filelog (automation file that changes every commit etc.), it also |
|
1118 // seems to work quite well for all measured purposes so far. |
|
1119 // |
|
1120 // TODO build an in-memory nodemap if more than 4 queries to the same |
|
1121 // revlog are made? |
|
1122 if !*self.use_persistent_nodemap(py) { |
|
1123 let idx = &self.inner(py).borrow().index; |
|
1124 let res = |
|
1125 idx.rev_from_node_no_persistent_nodemap(node.into()).ok(); |
|
1126 return Ok(res.map(Into::into)) |
|
1127 } |
1111 let opt = self.get_nodetree(py)?.borrow(); |
1128 let opt = self.get_nodetree(py)?.borrow(); |
1112 let nt = opt.as_ref().expect("nodetree should be set"); |
1129 let nt = opt.as_ref().expect("nodetree should be set"); |
1113 let ridx = &self.inner(py).borrow().index; |
1130 let ridx = &self.inner(py).borrow().index; |
1114 let node = node_from_py_bytes(py, &node)?; |
|
1115 let rust_rev = |
1131 let rust_rev = |
1116 nt.find_bin(ridx, node.into()).map_err(|e| nodemap_error(py, e))?; |
1132 nt.find_bin(ridx, node.into()).map_err(|e| nodemap_error(py, e))?; |
1117 Ok(rust_rev.map(Into::into)) |
1133 Ok(rust_rev.map(Into::into)) |
1118 } |
1134 } |
1119 |
1135 |
1955 delta_config: PyObject, |
1971 delta_config: PyObject, |
1956 feature_config: PyObject, |
1972 feature_config: PyObject, |
1957 _chunk_cache: PyObject, |
1973 _chunk_cache: PyObject, |
1958 _default_compression_header: PyObject, |
1974 _default_compression_header: PyObject, |
1959 revlog_type: usize, |
1975 revlog_type: usize, |
|
1976 use_persistent_nodemap: bool, |
1960 ) -> PyResult<Self> { |
1977 ) -> PyResult<Self> { |
1961 let index_file = |
1978 let index_file = |
1962 get_path_from_bytes(index_file.extract::<PyBytes>(py)?.data(py)) |
1979 get_path_from_bytes(index_file.extract::<PyBytes>(py)?.data(py)) |
1963 .to_owned(); |
1980 .to_owned(); |
1964 let data_file = |
1981 let data_file = |