changeset 48238:5e77bdc29d56

rhg: do not try to open a nodemap for an inline index This saves an [open] system call per file, which is a small saving, but it showed up in the profile at large file counts (it accounted for 30ms out of 400ms needed for catting 10000 files, on a ZFS filesystem on Linux, so ~3us per syscall). Differential Revision: https://phab.mercurial-scm.org/D11659
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Thu, 14 Oct 2021 13:34:37 +0100
parents 0cc69017d47f
children 4518d91f02d8
files rust/hg-core/src/revlog/index.rs rust/hg-core/src/revlog/revlog.rs
diffstat 2 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/index.rs	Tue Oct 05 15:10:42 2021 +0100
+++ b/rust/hg-core/src/revlog/index.rs	Thu Oct 14 13:34:37 2021 +0100
@@ -57,7 +57,7 @@
 
     /// Value of the inline flag.
     pub fn is_inline(&self) -> bool {
-        is_inline(&self.bytes)
+        self.offsets.is_some()
     }
 
     /// Return a slice of bytes if `revlog` is inline. Panic if not.
--- a/rust/hg-core/src/revlog/revlog.rs	Tue Oct 05 15:10:42 2021 +0100
+++ b/rust/hg-core/src/revlog/revlog.rs	Thu Oct 14 13:34:37 2021 +0100
@@ -99,14 +99,18 @@
                 Some(Box::new(data_mmap))
             };
 
-        let nodemap = NodeMapDocket::read_from_file(repo, index_path)?.map(
-            |(docket, data)| {
-                nodemap::NodeTree::load_bytes(
-                    Box::new(data),
-                    docket.data_length,
-                )
-            },
-        );
+        let nodemap = if index.is_inline() {
+            None
+        } else {
+            NodeMapDocket::read_from_file(repo, index_path)?.map(
+                |(docket, data)| {
+                    nodemap::NodeTree::load_bytes(
+                        Box::new(data),
+                        docket.data_length,
+                    )
+                },
+            )
+        };
 
         Ok(Revlog {
             index,