Skip to content

Commit

Permalink
Merge of #6204
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 20, 2024
2 parents 834be3a + 3654744 commit e150ee6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions beacon_node/beacon_chain/src/canonical_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ impl<E: EthSpec> CachedHead<E> {
pub struct CanonicalHead<T: BeaconChainTypes> {
/// Provides an in-memory representation of the non-finalized block tree and is used to run the
/// fork choice algorithm and determine the canonical head.
pub fork_choice: CanonicalHeadRwLock<BeaconForkChoice<T>>,
fork_choice: CanonicalHeadRwLock<BeaconForkChoice<T>>,
/// Provides values cached from a previous execution of `self.fork_choice.get_head`.
///
/// Although `self.fork_choice` might be slightly more advanced that this value, it is safe to
/// consider that these values represent the "canonical head" of the beacon chain.
pub cached_head: CanonicalHeadRwLock<CachedHead<T::EthSpec>>,
cached_head: CanonicalHeadRwLock<CachedHead<T::EthSpec>>,
/// A lock used to prevent concurrent runs of `BeaconChain::recompute_head`.
///
/// This lock **should not be made public**, it should only be used inside this module.
Expand Down Expand Up @@ -383,11 +383,13 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {

/// Access a read-lock for fork choice.
pub fn fork_choice_read_lock(&self) -> RwLockReadGuard<BeaconForkChoice<T>> {
let _timer = metrics::start_timer(&metrics::FORK_CHOICE_READ_LOCK_AQUIRE_TIMES);
self.fork_choice.read()
}

/// Access a write-lock for fork choice.
pub fn fork_choice_write_lock(&self) -> RwLockWriteGuard<BeaconForkChoice<T>> {
let _timer = metrics::start_timer(&metrics::FORK_CHOICE_WRITE_LOCK_AQUIRE_TIMES);
self.fork_choice.write()
}
}
Expand Down
14 changes: 14 additions & 0 deletions beacon_node/beacon_chain/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,20 @@ pub static FORK_CHOICE_AFTER_FINALIZATION_TIMES: LazyLock<Result<Histogram>> =
exponential_buckets(1e-3, 2.0, 10),
)
});
pub static FORK_CHOICE_READ_LOCK_AQUIRE_TIMES: LazyLock<Result<Histogram>> = LazyLock::new(|| {
try_create_histogram_with_buckets(
"beacon_fork_choice_read_lock_aquire_seconds",
"Time taken to aquire the fork-choice read lock",
exponential_buckets(1e-4, 4.0, 7),
)
});
pub static FORK_CHOICE_WRITE_LOCK_AQUIRE_TIMES: LazyLock<Result<Histogram>> = LazyLock::new(|| {
try_create_histogram_with_buckets(
"beacon_fork_choice_write_lock_aquire_seconds",
"Time taken to aquire the fork-choice write lock",
exponential_buckets(1e-3, 4.0, 7),
)
});
pub static FORK_CHOICE_SET_HEAD_LAG_TIMES: LazyLock<Result<Histogram>> = LazyLock::new(|| {
try_create_histogram(
"beacon_fork_choice_set_head_lag_times",
Expand Down

0 comments on commit e150ee6

Please sign in to comment.