@@ -47,15 +47,15 @@ class BlockHashType(NamedTuple):
47
47
48
48
49
49
class PrefixCachingMetrics :
50
- """Metrics for prefix caching with a hit rate of the most recent N requests.
50
+ """Metrics for prefix caching with a hit rate of the max recent N requests.
51
51
52
52
Args:
53
- interval : The number of the most recent requests to aggregate.
53
+ max_recent_requests : The number of the max recent requests to aggregate.
54
54
Defaults to 1000.
55
55
"""
56
56
57
- def __init__ (self , interval : int = 1000 ):
58
- self .interval = interval
57
+ def __init__ (self , max_recent_requests : int = 1000 ):
58
+ self .max_recent_requests = max_recent_requests
59
59
# The current aggregated values.
60
60
self .aggregated_requests = 0
61
61
self .aggregated_query_total = 0
@@ -70,7 +70,7 @@ def observe(self, stats: PrefixCacheStats):
70
70
are being scheduled and are looking for computed blocks.
71
71
72
72
When there are more than `interval` requests, the oldest set of
73
- requestsare removed from the metrics.
73
+ requests are removed from the metrics.
74
74
75
75
Args:
76
76
stats: The prefix cache stats.
@@ -87,7 +87,7 @@ def observe(self, stats: PrefixCacheStats):
87
87
self .aggregated_query_hit += stats .hits
88
88
89
89
# Remove the oldest stats if the number of requests exceeds.
90
- if self .aggregated_requests > self .interval :
90
+ if self .aggregated_requests > self .max_recent_requests :
91
91
old_requests , old_queries , old_hits = self .query_queue .popleft ()
92
92
self .aggregated_requests -= old_requests
93
93
self .aggregated_query_total -= old_queries
0 commit comments