mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 21:34:46 +00:00
add da cache metrics
This commit is contained in:
@@ -454,6 +454,24 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
pub fn persist_all(&self) -> Result<(), AvailabilityCheckError> {
|
||||
self.availability_cache.write_all_to_disk()
|
||||
}
|
||||
|
||||
/// Collects metrics from the data availability checker.
|
||||
pub fn metrics(&self) -> DataAvailabilityCheckerMetrics {
|
||||
DataAvailabilityCheckerMetrics {
|
||||
processing_cache_size: self.processing_cache.read().len(),
|
||||
num_store_entries: self.availability_cache.num_store_entries(),
|
||||
state_cache_size: self.availability_cache.state_cache_size(),
|
||||
block_cache_size: self.availability_cache.block_cache_size(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper struct to group data availability checker metrics.
|
||||
pub struct DataAvailabilityCheckerMetrics {
|
||||
pub processing_cache_size: usize,
|
||||
pub num_store_entries: usize,
|
||||
pub state_cache_size: usize,
|
||||
pub block_cache_size: usize,
|
||||
}
|
||||
|
||||
pub fn start_availability_cache_maintenance_service<T: BeaconChainTypes>(
|
||||
|
||||
@@ -363,6 +363,16 @@ impl<T: BeaconChainTypes> Critical<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the number of pending component entries in memory.
|
||||
pub fn num_blocks(&self) -> usize {
|
||||
self.in_memory.len()
|
||||
}
|
||||
|
||||
/// Returns the number of entries that have overflowed to disk.
|
||||
pub fn num_store_entries(&self) -> usize {
|
||||
self.store_keys.len()
|
||||
}
|
||||
}
|
||||
|
||||
/// This is the main struct for this module. Outside methods should
|
||||
@@ -671,6 +681,21 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
|
||||
pub fn state_lru_cache(&self) -> &StateLRUCache<T> {
|
||||
&self.state_cache
|
||||
}
|
||||
|
||||
/// Number of states stored in memory in the cache.
|
||||
pub fn state_cache_size(&self) -> usize {
|
||||
self.state_cache.lru_cache().read().len()
|
||||
}
|
||||
|
||||
/// Number of pending component entries in memory in the cache.
|
||||
pub fn block_cache_size(&self) -> usize {
|
||||
self.critical.read().num_blocks()
|
||||
}
|
||||
|
||||
/// Returns the number of entries in the cache that have overflowed to disk.
|
||||
pub fn num_store_entries(&self) -> usize {
|
||||
self.critical.read().num_store_entries()
|
||||
}
|
||||
}
|
||||
|
||||
impl ssz::Encode for OverflowKey {
|
||||
|
||||
@@ -38,6 +38,9 @@ impl<E: EthSpec> ProcessingCache<E> {
|
||||
}
|
||||
roots_missing_components
|
||||
}
|
||||
pub fn len(&self) -> usize {
|
||||
self.processing_cache.len()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -190,8 +190,7 @@ impl<T: BeaconChainTypes> StateLRUCache<T> {
|
||||
})
|
||||
}
|
||||
|
||||
/// returns the state cache for inspection in tests
|
||||
#[cfg(test)]
|
||||
/// returns the state cache for inspection
|
||||
pub fn lru_cache(&self) -> &RwLock<LruCache<Hash256, BeaconState<T::EthSpec>>> {
|
||||
&self.states
|
||||
}
|
||||
|
||||
@@ -1128,6 +1128,31 @@ lazy_static! {
|
||||
// Create a custom bucket list for greater granularity in block delay
|
||||
Ok(vec![0.1, 0.2, 0.3,0.4,0.5,0.75,1.0,1.25,1.5,1.75,2.0,2.5,3.0,3.5,4.0,5.0,6.0,7.0,8.0,9.0,10.0,15.0,20.0])
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Data Availability cache metrics
|
||||
*/
|
||||
pub static ref DATA_AVAILABILITY_PROCESSING_CACHE_SIZE: Result<IntGauge> =
|
||||
try_create_int_gauge(
|
||||
"data_availability_processing_cache_size",
|
||||
"Number of entries in the data availability processing cache."
|
||||
);
|
||||
pub static ref DATA_AVAILABILITY_OVERFLOW_MEMORY_BLOCK_CACHE_SIZE: Result<IntGauge> =
|
||||
try_create_int_gauge(
|
||||
"data_availability_overflow_memory_block_cache_size",
|
||||
"Number of entries in the data availability overflow block memory cache."
|
||||
);
|
||||
pub static ref DATA_AVAILABILITY_OVERFLOW_MEMORY_STATE_CACHE_SIZE: Result<IntGauge> =
|
||||
try_create_int_gauge(
|
||||
"data_availability_overflow_memory_state_cache_size",
|
||||
"Number of entries in the data availability overflow state memory cache."
|
||||
);
|
||||
pub static ref DATA_AVAILABILITY_OVERFLOW_STORE_CACHE_SIZE: Result<IntGauge> =
|
||||
try_create_int_gauge(
|
||||
"data_availability_overflow_store_cache_size",
|
||||
"Number of entries in the data availability overflow store cache."
|
||||
);
|
||||
}
|
||||
|
||||
/// Scrape the `beacon_chain` for metrics that are not constantly updated (e.g., the present slot,
|
||||
@@ -1155,6 +1180,24 @@ pub fn scrape_for_metrics<T: BeaconChainTypes>(beacon_chain: &BeaconChain<T>) {
|
||||
)
|
||||
}
|
||||
|
||||
let da_checker_metrics = beacon_chain.data_availability_checker.metrics();
|
||||
set_gauge_by_usize(
|
||||
&DATA_AVAILABILITY_PROCESSING_CACHE_SIZE,
|
||||
da_checker_metrics.processing_cache_size,
|
||||
);
|
||||
set_gauge_by_usize(
|
||||
&DATA_AVAILABILITY_OVERFLOW_MEMORY_BLOCK_CACHE_SIZE,
|
||||
da_checker_metrics.block_cache_size,
|
||||
);
|
||||
set_gauge_by_usize(
|
||||
&DATA_AVAILABILITY_OVERFLOW_MEMORY_STATE_CACHE_SIZE,
|
||||
da_checker_metrics.state_cache_size,
|
||||
);
|
||||
set_gauge_by_usize(
|
||||
&DATA_AVAILABILITY_OVERFLOW_STORE_CACHE_SIZE,
|
||||
da_checker_metrics.num_store_entries,
|
||||
);
|
||||
|
||||
if let Some((size, num_lookups)) = beacon_chain.pre_finalization_block_cache.metrics() {
|
||||
set_gauge_by_usize(&PRE_FINALIZATION_BLOCK_CACHE_SIZE, size);
|
||||
set_gauge_by_usize(&PRE_FINALIZATION_BLOCK_LOOKUP_COUNT, num_lookups);
|
||||
|
||||
Reference in New Issue
Block a user