(LedgerStore) Skip sampling check when ROCKSDB_PERF_CONTEXT_SAMPLES_IN_1K_DEFAULT = 0 (#24221)

#### Problem
Currently, even if SOLANA_METRICS_ROCKSDB_PERF_SAMPLES_IN_1K == 0, we are still doing
the sampling check for every RocksDB read.

```
thread_rng().gen_range(0, METRIC_SAMPLES_1K) > *ROCKSDB_PERF_CONTEXT_SAMPLES_IN_1K
```

#### Summary of Changes
This PR skips the sampling check when SOLANA_METRICS_ROCKSDB_PERF_SAMPLES_IN_1K
is set to 0.
This commit is contained in:
Yueh-Hsuan Chiang 2022-04-11 20:39:46 -07:00 committed by GitHub
parent 9b8850f99e
commit 5a48ef72fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -2295,6 +2295,9 @@ mod rocks_metrics_utils {
///
/// Returns true if the PerfContext is enabled.
pub fn maybe_collect_perf_context() -> bool {
if *ROCKSDB_PERF_CONTEXT_SAMPLES_IN_1K <= 0 {
return false;
}
if thread_rng().gen_range(0, METRIC_SAMPLES_1K) > *ROCKSDB_PERF_CONTEXT_SAMPLES_IN_1K {
return false;
}