Browse Source

Switch SlotList to smallvec (#8003)

* Switch SlotList in AccountsIndex to smallvec

* Enable union feature of smallvec
Kamil Skalski 2 months ago
parent
commit
1757dff6e4
3 changed files with 5 additions and 3 deletions
  1. 1 1
      Cargo.toml
  2. 2 1
      accounts-db/src/accounts_db.rs
  3. 2 1
      accounts-db/src/accounts_index.rs

+ 1 - 1
Cargo.toml

@@ -366,7 +366,7 @@ shuttle = "0.7.1"
 signal-hook = "0.3.18"
 siphasher = "1.0.1"
 slab = "0.4.11"
-smallvec = "1.15.1"
+smallvec = { version = "1.15.1", default-features = false, features = ["union"] }
 smpl_jwt = "0.7.1"
 socket2 = "0.6.0"
 soketto = "0.7"

+ 2 - 1
accounts-db/src/accounts_db.rs

@@ -5498,7 +5498,7 @@ impl AccountsDb {
                     );
                 });
             });
-            reclaims
+            reclaims.to_vec()
         };
 
         let threshold = 1;
@@ -5523,6 +5523,7 @@ impl AccountsDb {
         } else {
             update(0, len)
         }
+        .into()
     }
 
     fn should_not_shrink(alive_bytes: u64, total_bytes: u64) -> bool {

+ 2 - 1
accounts-db/src/accounts_index.rs

@@ -24,6 +24,7 @@ use {
     rayon::iter::{IntoParallelIterator, ParallelIterator},
     roots_tracker::RootsTracker,
     secondary::{RwLockSecondaryIndexEntry, SecondaryIndex, SecondaryIndexEntry},
+    smallvec::SmallVec,
     solana_account::ReadableAccount,
     solana_clock::{BankId, Slot},
     solana_measure::measure::Measure,
@@ -70,7 +71,7 @@ pub const ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS: AccountsIndexConfig = AccountsIn
     scan_results_limit_bytes: None,
 };
 pub type ScanResult<T> = Result<T, ScanError>;
-pub type SlotList<T> = Vec<(Slot, T)>;
+pub type SlotList<T> = SmallVec<[(Slot, T); 1]>;
 
 // The ref count cannot be higher than the total number of storages, and we should never have more
 // than 1 million storages. A 32-bit ref count should be *significantly* more than enough.