From 1aa88b294a1d30963d96cddb38c157171905169b Mon Sep 17 00:00:00 2001 From: Jianjian Date: Thu, 26 Sep 2024 14:04:33 -0700 Subject: [PATCH] fix cache miss metrics --- .../client/file/cache/LocalCacheManager.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dora/core/client/fs/src/main/java/alluxio/client/file/cache/LocalCacheManager.java b/dora/core/client/fs/src/main/java/alluxio/client/file/cache/LocalCacheManager.java index d5c418ba2d9a..0f6c22a40b2a 100644 --- a/dora/core/client/fs/src/main/java/alluxio/client/file/cache/LocalCacheManager.java +++ b/dora/core/client/fs/src/main/java/alluxio/client/file/cache/LocalCacheManager.java @@ -225,6 +225,8 @@ public Optional getDataFileChannel( MetricsSystem.meter(MetricKey.CLIENT_CACHE_BYTES_READ_CACHE.getName()).mark(bytesToRead); cacheContext.incrementCounter(MetricKey.CLIENT_CACHE_BYTES_READ_CACHE.getMetricName(), BYTE, bytesToRead); + cacheContext.incrementCounter( + MetricKey.CLIENT_CACHE_PAGE_READ_CACHE_TIME_NS.getMetricName(), NANO, System.nanoTime() - startTime); LOG.debug("getDataChannel({},pageOffset={}) exits", pageId, pageOffset); return Optional.of(dataFileChannel); } catch (PageNotFoundException e) { @@ -242,10 +244,6 @@ public Optional getDataFileChannel( return Optional.empty(); } } - } finally { - cacheContext.incrementCounter( - MetricKey.CLIENT_CACHE_PAGE_READ_CACHE_TIME_NS.getMetricName(), NANO, - System.nanoTime() - startTime); } } @@ -640,14 +638,11 @@ public int get(PageId pageId, int pageOffset, int bytesToRead, ReadTargetBuffer } MultiDimensionalMetricsSystem.CACHED_DATA_READ.inc(bytesRead); MetricsSystem.meter(MetricKey.CLIENT_CACHE_BYTES_READ_CACHE.getName()).mark(bytesRead); - cacheContext.incrementCounter(MetricKey.CLIENT_CACHE_BYTES_READ_CACHE.getMetricName(), BYTE, - bytesRead); + cacheContext.incrementCounter(MetricKey.CLIENT_CACHE_BYTES_READ_CACHE.getMetricName(), BYTE, bytesRead); + cacheContext.incrementCounter( + MetricKey.CLIENT_CACHE_PAGE_READ_CACHE_TIME_NS.getMetricName(), NANO, System.nanoTime() - startTime); LOG.debug("get({},pageOffset={}) exits", pageId, pageOffset); return bytesRead; - } finally { - cacheContext.incrementCounter( - MetricKey.CLIENT_CACHE_PAGE_READ_CACHE_TIME_NS.getMetricName(), NANO, - System.nanoTime() - startTime); } }