justramesh2000 commented on code in PR #21091:
URL: https://github.com/apache/kafka/pull/21091#discussion_r2594296477
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:
##########
@@ -148,8 +154,15 @@ private void registerMetrics() {
e2eLatencySensor =
StateStoreMetrics.e2ELatencySensor(taskId.toString(), metricsScope, name(),
streamsMetrics);
iteratorDurationSensor =
StateStoreMetrics.iteratorDurationSensor(taskId.toString(), metricsScope,
name(), streamsMetrics);
StateStoreMetrics.addNumOpenIteratorsGauge(taskId.toString(),
metricsScope, name(), streamsMetrics,
- (config, now) -> openIterators.sum());
- openIterators = new OpenIterators(taskId, metricsScope, name(),
streamsMetrics);
+ (config, now) -> numOpenIterators.sum());
+ StateStoreMetrics.addOldestOpenIteratorGauge(taskId.toString(),
metricsScope, name(), streamsMetrics,
+ (config, now) -> {
+ try {
+ return openIterators.isEmpty() ? 0L :
openIterators.first().startTimestamp();
Review Comment:
could this potentially lead to Time of check time of use condition ? how
about
`try {
return openIterators.first().startTimestamp();
} catch (final NoSuchElementException ignore) {
return 0L;
}`
exceptions in hot path might also be of concern in terms of performance, so
does following seem better ?
`(config, now) -> {
final Iterator<MeteredIterator> iter = openIterators.iterator();
return iter.hasNext() ? iter.next().startTimestamp() : 0L;
}`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]