You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/04/17 16:06:57 UTC

[GitHub] nicmichael opened a new issue #1354: Spin-Wait for I/O completion wastes CPU time in Bookkeeper Client (JDK8)

nicmichael opened a new issue #1354: Spin-Wait for I/O completion wastes CPU time in Bookkeeper Client (JDK8)
URL: https://github.com/apache/bookkeeper/issues/1354
 
 
   **BUG REPORT**
   
   1. Please describe the issue you observed:
   
   CPU Profiles of Bookkeeper Client code running with JDK8 show significant CPU time spent in SyncCallbackUtils.waitForResult() calling CompletableFuture.get() - in my case 6% of total CPU cycles. This is due to the implementation of CompletableFuture.get(), which in JDK 8 uses spin-wait (before blocking when reaching the spin timeout). Requests are generally slower than the spin timeout, so requests generally don't complete while spinning, therefore spinning doesn't gain us any latency but only wastes CPU time.
   
   The implementation of CompletableFuture.get() has changed in JDK9, where it now blocks immediately. This reduces CPU consumption of Bookkeeper Client code significantly and reduces the cost of SyncCallbackUtils.waitForResult() to near-zero.
   
   SyncCallbackUtils should eliminate spinning when waiting for the result of a CompletableFuture regardless of the JDK used.
   
   The alternative API CompletableFuture.get(long, TimeUnit) blocks immediately in both JDK 8 and 9 (if the result is not yet available) and produces the same result at the same cost as CompletableFuture.get() in JDK9 if called with a "large" timeout. Besides an additional call to System.nanoTime(), its implementation in JDK9 is nearly identical to that of CompletableFuture.get().

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services