-
Type:
Enhancement
-
Resolution: Duplicate
-
Priority:
P3
-
Affects Version/s: 8, 12
-
Component/s: core-svc
-
x86_64
-
linux
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
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
- duplicates
-
JDK-8372584 [Linux]: Replace reading proc to get thread user CPU time with clock_gettime
-
- Open
-