More configurable rocksdb compaction (#15213) (#15325)

rocksdb compaction can cause long stalls, so
make it more configurable to try and reduce those stalls
and also to coordinate between multiple nodes to not induce
stall at the same time.

(cherry picked from commit 5b8f046c67)

Co-authored-by: sakridge <sakridge@gmail.com>
This commit is contained in:
mergify[bot]
2021-02-16 01:46:36 +00:00
committed by GitHub
parent 543f7e7ec1
commit 59beb8e548
5 changed files with 150 additions and 45 deletions

View File

@@ -8,7 +8,7 @@ mod tests {
use solana_ledger::shred::Shred;
use std::collections::VecDeque;
use std::str::FromStr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock};
use std::thread::{self, Builder, JoinHandle};
@@ -223,8 +223,14 @@ mod tests {
let (sender, receiver) = channel();
let exit = Arc::new(AtomicBool::new(false));
let cleaner =
LedgerCleanupService::new(receiver, blockstore.clone(), max_ledger_shreds, &exit);
let cleaner = LedgerCleanupService::new(
receiver,
blockstore.clone(),
max_ledger_shreds,
&exit,
None,
None,
);
let exit_cpu = Arc::new(AtomicBool::new(false));
let sys = CpuStatsUpdater::new(&exit_cpu);
@@ -375,18 +381,28 @@ mod tests {
let (sender, receiver) = channel();
sender.send(n).unwrap();
let mut last_purge_slot = 0;
let mut last_compaction_slot = 0;
let highest_compact_slot = Arc::new(AtomicU64::new(0));
LedgerCleanupService::cleanup_ledger(
&receiver,
&blockstore,
max_ledger_shreds,
&mut last_purge_slot,
10,
&mut last_compaction_slot,
10,
&highest_compact_slot,
)
.unwrap();
let mut compaction_jitter = 0;
let mut last_compaction_slot = 0;
LedgerCleanupService::compact_ledger(
&blockstore,
&mut last_compaction_slot,
10,
&highest_compact_slot,
&mut compaction_jitter,
None,
);
thread::sleep(Duration::from_secs(2));
let u2 = blockstore.storage_size().unwrap() as f64;