Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8210452

getCurrentThreadUserTime is 30x-400x times slower then getCurrentThreadCpuTime

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      On Linux getCurrentThreadUserTime is 30x-400x times slower then getCurrentThreadCpuTime. When getCurrentThreadCpuTime performance does not regress under higher concurrency, the getCurrentThreadUserTime performance is getting worse with every additional concurrent thread calling that method.

      getCurrentThreadCpuTime uses posix clocks, when getCurrentThreadUserTime parses the /proc/self/task/<process id>/stat system file

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Bechmark code: https://github.com/arhimondr/presto/blob/bechamark-cpu-counters/presto-array/src/test/java/com/facebook/presto/array/BenchmarkCPUCounters.java

      Some benchmark results: https://github.com/prestodb/presto/pull/10144#issuecomment-417365365

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      getCurrentThreadUserTime and getCurrentThreadCpuTime should take about the same time to execute
      ACTUAL -
      getCurrentThreadUserTime is 30x-400x times slower depending on the number of concurrent threads calling that method

      ---------- BEGIN SOURCE ----------
      https://github.com/arhimondr/presto/blob/bechamark-cpu-counters/presto-array/src/test/java/com/facebook/presto/array/BenchmarkCPUCounters.java
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Do not use getCurrentThreadUserTime. Use a native library, that can bypass the posix standard to obtain the CPU clock for the user time.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              lcable Larry Cable
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: