@@ -31,15 +31,15 @@ class BlockHashType(NamedTuple):
31
31
32
32
33
33
class PrefixCachingMetrics :
34
- """Metrics for prefix caching with a hit rate of the most recent N requests.
34
+ """Metrics for prefix caching with a hit rate of the max recent N requests.
35
35
36
36
Args:
37
- interval : The number of the most recent requests to aggregate.
37
+ max_recent_requests : The number of the max recent requests to aggregate.
38
38
Defaults to 1000.
39
39
"""
40
40
41
- def __init__ (self , interval : int = 1000 ):
42
- self .interval = interval
41
+ def __init__ (self , max_recent_requests : int = 1000 ):
42
+ self .max_recent_requests = max_recent_requests
43
43
# The current aggregated values.
44
44
self .aggregated_requests = 0
45
45
self .aggregated_query_total = 0
@@ -54,7 +54,7 @@ def observe(self, stats: PrefixCacheStats):
54
54
are being scheduled and are looking for computed blocks.
55
55
56
56
When there are more than `interval` requests, the oldest set of
57
- requestsare removed from the metrics.
57
+ requests are removed from the metrics.
58
58
59
59
Args:
60
60
stats: The prefix cache stats.
@@ -71,7 +71,7 @@ def observe(self, stats: PrefixCacheStats):
71
71
self .aggregated_query_hit += stats .hits
72
72
73
73
# Remove the oldest stats if the number of requests exceeds.
74
- if self .aggregated_requests > self .interval :
74
+ if self .aggregated_requests > self .max_recent_requests :
75
75
old_requests , old_queries , old_hits = self .query_queue .popleft ()
76
76
self .aggregated_requests -= old_requests
77
77
self .aggregated_query_total -= old_queries
0 commit comments