diff tests/test-branches.t @ 51375:02e7d79edf62

branchmap: use mmap for faster revbranchcache loading A typical revbranchmap usage is: - load the entire revbranchmap file into memory - maybe do a few lookups - add a few bytes to it - write the addition to disk There's no reason to load the entire revbranchmap into memory. We can split it into a large immutable prefix and a mutable suffix, and then memorymap the prefix, thus saving all the useless loading. Benchmarking on some real-world pushes suggests that out of ~100s server-side push handling revbranchcache handling is responsible for: * ~7s with no change * ~1.3s with the change, without mmap * 0.04s with the change, with mmap
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Wed, 10 Jan 2024 18:58:42 +0000
parents 566f7dd563c1
children 40943970b7ae 2e8a88e5809f
line wrap: on
line diff
--- a/tests/test-branches.t	Fri Feb 02 04:46:54 2024 +0100
+++ b/tests/test-branches.t	Wed Jan 10 18:58:42 2024 +0000
@@ -1,3 +1,12 @@
+#testcases mmap nommap
+
+#if mmap
+  $ cat <<EOF >> $HGRCPATH
+  > [format]
+  > mmap-revbranchcache=true
+  > EOF
+#endif
+
   $ hg init a
   $ cd a
 
@@ -921,17 +930,10 @@
   $ f --size --hexdump .hg/cache/rbc-*
   .hg/cache/rbc-names-v1: size=1
   0000: 61                                              |a|
-  .hg/cache/rbc-revs-v1: size=152
+  .hg/cache/rbc-revs-v1: size=48
   0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
   0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
   0020: 00 00 00 00 00 00 00 00 d8 cb c6 1d 00 00 00 00 |................|
-  0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
-  0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
-  0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
-  0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
-  0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
-  0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
-  0090: 00 00 00 00 00 00 00 00                         |........|
 
   $ cd ..