junaiddshaukat opened a new issue, #37704: URL: https://github.com/apache/beam/issues/37704
### What needs to happen? ### What happened? In `ReadFromKafkaDoFn.java`, a Guava `Stopwatch` is currently used to measure the latency of `consumer.poll()` and report it to the `RpcLatency` metric. As noted in an existing `TODO` comment in the codebase, this timer uses `System.nanoTime()`. When a consumer has prefetches waiting to be returned immediately, the overhead of `System.nanoTime()` can contribute more latency than it actually measures (see [nanotrusting-nanotime](https://shipilev.net/blog/2014/nanotrusting-nanotime/)). To fix this, we should: 1. Remove the `pollTimer` (`Stopwatch`) from the `while` loop in `ReadFromKafkaDoFn`. 2. Stop manually reporting to `updateSuccessfulRpcMetrics` in this hot path, and instead rely on Kafka's native `fetch-latency-avg` JMX metric which users can already monitor. 3. Replace the `remainingTimeout` calculation with a lower-overhead `System.currentTimeMillis()` check to ensure we still respect the `consumerPollingTimeout` without the `nanoTime` penalty. ### Issue Priority Priority: 2 (default / most normal work should be filed as P2) ### Issue Components - [ ] Component: Python SDK - [x] Component: Java SDK - [ ] Component: Go SDK - [ ] Component: Typescript SDK - [x] Component: IO connector - [ ] Component: Beam YAML - [ ] Component: Beam examples - [ ] Component: Beam playground - [ ] Component: Beam katas - [ ] Component: Website - [ ] Component: Infrastructure - [ ] Component: Spark Runner - [ ] Component: Flink Runner - [ ] Component: Samza Runner - [ ] Component: Twister2 Runner - [ ] Component: Hazelcast Jet Runner - [ ] Component: Google Cloud Dataflow Runner -- 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]
