Move status cache serialization to the Snapshot Packager service (#6081) (#6101)

automerge
This commit is contained in:
mergify[bot]
2019-09-25 14:40:18 -07:00
committed by Grimes
parent 2293ad20d5
commit 0245e4cf94
8 changed files with 159 additions and 129 deletions

View File

@@ -38,6 +38,7 @@ solana-vote-program = { path = "../programs/vote_program", version = "0.19.1" }
sys-info = "0.5.8"
tempfile = "3.1.0"
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "0.19.1" }
itertools = "0.8.0"
[lib]
crate-type = ["lib"]

View File

@@ -23,6 +23,7 @@ use crate::{
};
use bincode::{deserialize_from, serialize_into};
use byteorder::{ByteOrder, LittleEndian};
use itertools::Itertools;
use log::*;
use serde::{Deserialize, Serialize};
use solana_measure::measure::Measure;
@@ -48,7 +49,7 @@ use solana_sdk::{
timing::duration_as_ns,
transaction::{Result, Transaction, TransactionError},
};
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::io::{BufReader, Cursor, Error as IOError, Read};
use std::path::Path;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
@@ -136,8 +137,15 @@ impl StatusCacheRc {
sc.slot_deltas(slots)
}
pub fn roots(&self) -> HashSet<u64> {
self.status_cache.read().unwrap().roots().clone()
pub fn roots(&self) -> Vec<u64> {
self.status_cache
.read()
.unwrap()
.roots()
.iter()
.cloned()
.sorted()
.collect()
}
pub fn append(&self, slot_deltas: &[SlotDelta<Result<()>>]) {

View File

@@ -1,13 +1,13 @@
use log::*;
use rand::{thread_rng, Rng};
use serde::Serialize;
use solana_sdk::clock::{Slot, MAX_HASH_AGE_IN_SECONDS};
use solana_sdk::clock::{Slot, MAX_RECENT_BLOCKHASHES};
use solana_sdk::hash::Hash;
use solana_sdk::signature::Signature;
use std::collections::{HashMap, HashSet};
use std::sync::{Arc, Mutex};
pub const MAX_CACHE_ENTRIES: usize = MAX_HASH_AGE_IN_SECONDS;
pub const MAX_CACHE_ENTRIES: usize = MAX_RECENT_BLOCKHASHES;
const CACHED_SIGNATURE_SIZE: usize = 20;
// Store forks in a single chunk of memory to avoid another lookup.
@@ -430,4 +430,9 @@ mod tests {
assert_eq!(cache, status_cache);
}
#[test]
fn test_age_sanity() {
assert!(MAX_CACHE_ENTRIES <= MAX_RECENT_BLOCKHASHES);
}
}