zookeeper
zookeeper copied to clipboard
ZOOKEEPER-4252: Fix flaky test RequestPathMetricsCollectorTest#testMultiThreadPerf
This test is asserting low performance threshold for RequestPathMetricsCollector#registerRequest. It fails at rate 20% according to jira reports. I think it caused by combination of:
- Unstable test environment.
Executors.newCachedThreadPoolis not suitable for cpu-bound operations.System.currentTimeMillisis not suitable for time counting due to possible wall clock skewing.
This pr try to fix flakyness through:
- Increase timeout for unstable test environment.
- Use
Executors.newWorkStealingPoolto execute register operation. - Use
System.nanoTimeto count elapsed time.
Additionally, it logs elapsed time for performance measurement.