Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track live object set size during expensive checks #12846

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion crates/sui-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const NUM_SHARDS: usize = 4096;
struct AuthorityStoreMetrics {
sui_conservation_check_latency: IntGauge,
sui_conservation_live_object_count: IntGauge,
sui_conservation_live_object_size: IntGauge,
sui_conservation_imbalance: IntGauge,
sui_conservation_storage_fund: IntGauge,
sui_conservation_storage_fund_imbalance: IntGauge,
Expand All @@ -71,6 +72,11 @@ impl AuthorityStoreMetrics {
"Number of live objects in the store",
registry,
).unwrap(),
sui_conservation_live_object_size: register_int_gauge_with_registry!(
"sui_conservation_live_object_size",
"Size in bytes of live objects in the store",
registry,
).unwrap(),
sui_conservation_imbalance: register_int_gauge_with_registry!(
"sui_conservation_imbalance",
"Total amount of SUI in the network - 10B * 10^9. This delta shows the amount of imbalance",
Expand Down Expand Up @@ -1630,14 +1636,16 @@ impl AuthorityStore {
let cur_time = Instant::now();
let mut pending_objects = vec![];
let mut count = 0;
let mut size = 0;
let package_cache = PackageObjectCache::new(self.clone());
let (mut total_sui, mut total_storage_rebate) = thread::scope(|s| {
let pending_tasks = FuturesUnordered::new();
for o in self.iter_live_object_set(false) {
match o {
LiveObject::Normal(object) => {
pending_objects.push(object);
size += object.object_size_for_gas_metering();
count += 1;
pending_objects.push(object);
if count % 1_000_000 == 0 {
let mut task_objects = vec![];
mem::swap(&mut pending_objects, &mut task_objects);
Expand Down Expand Up @@ -1686,6 +1694,9 @@ impl AuthorityStore {
self.metrics
.sui_conservation_live_object_count
.set(count as i64);
self.metrics
.sui_conservation_live_object_size
.set(size as i64);
self.metrics
.sui_conservation_check_latency
.set(cur_time.elapsed().as_secs() as i64);
Expand Down