20260416_2 并行优化phase1后进行snapshot fast path优化,通过四方面关键优化技术消除了验证主链路上snapshot构建是的db访问性能热点问题,性能热点转移到ROA验证处理本身,目前APNIC+ARIN全量同步从500秒压缩到212秒,离rpkclient 112秒差距变小
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use rpki::fetch::http::{BlockingHttpFetcher, HttpFetcherConfig};
|
||||
@@ -52,7 +52,7 @@ impl RsyncFetcher for AlwaysFailRsyncFetcher {
|
||||
struct CountingDenyUriFetcher {
|
||||
inner: BlockingHttpFetcher,
|
||||
deny_uri: String,
|
||||
counts: std::rc::Rc<RefCell<HashMap<String, u64>>>,
|
||||
counts: Arc<Mutex<HashMap<String, u64>>>,
|
||||
}
|
||||
|
||||
impl CountingDenyUriFetcher {
|
||||
@@ -60,18 +60,28 @@ impl CountingDenyUriFetcher {
|
||||
Self {
|
||||
inner,
|
||||
deny_uri,
|
||||
counts: std::rc::Rc::new(RefCell::new(HashMap::new())),
|
||||
counts: Arc::new(Mutex::new(HashMap::new())),
|
||||
}
|
||||
}
|
||||
|
||||
fn count(&self, uri: &str) -> u64 {
|
||||
*self.counts.borrow().get(uri).unwrap_or(&0)
|
||||
*self
|
||||
.counts
|
||||
.lock()
|
||||
.expect("lock counts")
|
||||
.get(uri)
|
||||
.unwrap_or(&0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Fetcher for CountingDenyUriFetcher {
|
||||
fn fetch(&self, uri: &str) -> Result<Vec<u8>, String> {
|
||||
*self.counts.borrow_mut().entry(uri.to_string()).or_insert(0) += 1;
|
||||
*self
|
||||
.counts
|
||||
.lock()
|
||||
.expect("lock counts")
|
||||
.entry(uri.to_string())
|
||||
.or_insert(0) += 1;
|
||||
if uri == self.deny_uri {
|
||||
return Err(format!("snapshot fetch denied: {uri}"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user