From 5e2a19ce73ce23c60ee472a848a34850c81b8874 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Thu, 31 Jul 2025 14:24:17 +0300 Subject: [PATCH] cargo fmt --- pgxn/neon/communicator/src/file_cache.rs | 8 +++---- .../neon/communicator/src/global_allocator.rs | 21 ++++++++++++------- .../neon/communicator/src/integrated_cache.rs | 21 +++++++++++-------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/pgxn/neon/communicator/src/file_cache.rs b/pgxn/neon/communicator/src/file_cache.rs index 4470bdfb37..0b52956f2d 100644 --- a/pgxn/neon/communicator/src/file_cache.rs +++ b/pgxn/neon/communicator/src/file_cache.rs @@ -14,10 +14,10 @@ use std::path::Path; use std::sync::Arc; use std::sync::Mutex; -use measured::{Gauge, MetricGroup}; -use measured::metric::gauge::GaugeState; -use measured::metric::MetricEncoding; use measured::metric; +use measured::metric::MetricEncoding; +use measured::metric::gauge::GaugeState; +use measured::{Gauge, MetricGroup}; use crate::BLCKSZ; @@ -136,7 +136,7 @@ impl FileCache { } } -impl MetricGroup for FileCache +impl MetricGroup for FileCache where GaugeState: MetricEncoding, { diff --git a/pgxn/neon/communicator/src/global_allocator.rs b/pgxn/neon/communicator/src/global_allocator.rs index e7a08d23d2..250cad1eb0 100644 --- a/pgxn/neon/communicator/src/global_allocator.rs +++ b/pgxn/neon/communicator/src/global_allocator.rs @@ -18,10 +18,10 @@ use std::alloc::{GlobalAlloc, Layout, System}; use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; -use measured::{Gauge, MetricGroup}; -use measured::metric::gauge::GaugeState; -use measured::metric::MetricEncoding; use measured::metric; +use measured::metric::MetricEncoding; +use measured::metric::gauge::GaugeState; +use measured::{Gauge, MetricGroup}; pub(crate) struct MyAllocator { allocations: AtomicU64, @@ -83,19 +83,24 @@ impl MyAllocatorCollector { } } -impl MetricGroup for MyAllocatorCollector +impl MetricGroup for MyAllocatorCollector where GaugeState: MetricEncoding, { fn collect_group_into(&self, enc: &mut T) -> Result<(), ::Err> { // Update the gauges with fresh values first - self.metrics.communicator_mem_allocations + self.metrics + .communicator_mem_allocations .set(GLOBAL.allocations.load(Ordering::Relaxed) as i64); - self.metrics.communicator_mem_deallocations + self.metrics + .communicator_mem_deallocations .set(GLOBAL.allocations.load(Ordering::Relaxed) as i64); - self.metrics.communicator_mem_allocated + self.metrics + .communicator_mem_allocated .set(GLOBAL.allocated.load(Ordering::Relaxed) as i64); - self.metrics.communicator_mem_high.set(GLOBAL.high.load(Ordering::Relaxed) as i64); + self.metrics + .communicator_mem_high + .set(GLOBAL.high.load(Ordering::Relaxed) as i64); self.metrics.collect_group_into(enc) } diff --git a/pgxn/neon/communicator/src/integrated_cache.rs b/pgxn/neon/communicator/src/integrated_cache.rs index b4bb994980..abcd8d682a 100644 --- a/pgxn/neon/communicator/src/integrated_cache.rs +++ b/pgxn/neon/communicator/src/integrated_cache.rs @@ -32,11 +32,11 @@ use crate::file_cache::{CacheBlock, FileCache}; use crate::init::alloc_from_slice; use pageserver_page_api::RelTag; -use measured::{Counter, Gauge, MetricGroup}; +use measured::metric; +use measured::metric::MetricEncoding; use measured::metric::counter::CounterState; use measured::metric::gauge::GaugeState; -use measured::metric::MetricEncoding; -use measured::metric; +use measured::{Counter, Gauge, MetricGroup}; use neon_shmem::hash::{HashMapInit, entry::Entry}; use neon_shmem::shmem::ShmemHandle; @@ -85,7 +85,6 @@ struct IntegratedCacheMetricGroup { clock_iterations_counter: Counter, // metrics from the hash map - /// Allocated size of the block cache hash map block_map_num_buckets: Gauge, @@ -775,20 +774,24 @@ impl<'t> IntegratedCacheWriteAccess<'t> { } } -impl MetricGroup for IntegratedCacheWriteAccess<'_> +impl MetricGroup for IntegratedCacheWriteAccess<'_> where CounterState: MetricEncoding, GaugeState: MetricEncoding, { fn collect_group_into(&self, enc: &mut T) -> Result<(), ::Err> { // Update gauges - self.metrics.block_map_num_buckets + self.metrics + .block_map_num_buckets .set(self.block_map.get_num_buckets() as i64); - self.metrics.block_map_num_buckets_in_use + self.metrics + .block_map_num_buckets_in_use .set(self.block_map.get_num_buckets_in_use() as i64); - self.metrics.relsize_cache_num_buckets + self.metrics + .relsize_cache_num_buckets .set(self.relsize_cache.get_num_buckets() as i64); - self.metrics.relsize_cache_num_buckets_in_use + self.metrics + .relsize_cache_num_buckets_in_use .set(self.relsize_cache.get_num_buckets_in_use() as i64); if let Some(file_cache) = &self.file_cache {