diff rust/hg-core/src/revlog/index.rs @ 51260:c4f1a790bda8

rust-index: use a `BitVec` instead of plain `Vec` for heads computation The `Vec` method uses one byte per revision, this uses 1 per 8 revisions, which improves our memory footprint. For large graphs (10+ millions), this can make a measurable difference server-side. I have seen no measurable impact on execution speed.
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 29 Nov 2023 15:58:24 -0500
parents ed6683d4cb29
children 9088c6d65ef6
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/index.rs	Wed Nov 29 10:04:41 2023 -0500
+++ b/rust/hg-core/src/revlog/index.rs	Wed Nov 29 15:58:24 2023 -0500
@@ -3,6 +3,7 @@
 use std::ops::Deref;
 use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
 
+use bitvec::prelude::*;
 use byteorder::{BigEndian, ByteOrder};
 use bytes_cast::{unaligned, BytesCast};
 
@@ -568,8 +569,12 @@
         let as_vec = if self.is_empty() {
             vec![NULL_REVISION]
         } else {
-            let mut not_heads = vec![false; self.len()];
-            dagops::retain_heads_fast(self, &mut not_heads, filtered_revs)?;
+            let mut not_heads = bitvec![0; self.len()];
+            dagops::retain_heads_fast(
+                self,
+                not_heads.as_mut_bitslice(),
+                filtered_revs,
+            )?;
             not_heads
                 .into_iter()
                 .enumerate()