Patchwork D11659: rhg: do not try to open a nodemap for an inline index

login
register
mail settings
Submitter phabricator
Date Oct. 14, 2021, 1:03 p.m.
Message ID <differential-rev-PHID-DREV-u6rtglnqkdyitlz4fidx-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49983/
State Superseded
Headers show

Comments

phabricator - Oct. 14, 2021, 1:03 p.m.
aalekseyev created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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).

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11659

AFFECTED FILES
  rust/hg-core/src/revlog/index.rs
  rust/hg-core/src/revlog/revlog.rs

CHANGE DETAILS




To: aalekseyev, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs
--- a/rust/hg-core/src/revlog/revlog.rs
+++ b/rust/hg-core/src/revlog/revlog.rs
@@ -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,
diff --git a/rust/hg-core/src/revlog/index.rs b/rust/hg-core/src/revlog/index.rs
--- a/rust/hg-core/src/revlog/index.rs
+++ b/rust/hg-core/src/revlog/index.rs
@@ -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.