0

Running a small jetty application on a raspberry pi I noticed that after the first access, the application keeps burning around 3% CPU. A quick inspection showed that the same is true, with less %, on my laptop. Checking with strace I find a never ending sequence of

...
12:58:01.999717 clock_gettime(CLOCK_MONOTONIC, {2923, 200177551}) = 0
12:58:01.999864 futex(0x693a0f44, FUTEX_WAIT_BITSET_PRIVATE, 1, {2923, 250177551}, ffffffff) = -1 ETIMEDOUT (Connection timed out)
12:58:02.050090 futex(0x693a0f28, FUTEX_WAKE_PRIVATE, 1) = 0
12:58:02.050236 gettimeofday({1436093882, 50296}, NULL) = 0
12:58:02.050403 gettimeofday({1436093882, 50444}, NULL) = 0
12:58:02.050767 clock_gettime(CLOCK_MONOTONIC, {2923, 251228114}) = 0
...

(This is Java 7 on ubuntu 14.04 with Jetty 9.3.* using an h2 db, just in case this rings any bells for someone.)

I learned that it suffices to capture strace -f -tt -p <pid> -o out.txt, grep for clock_gettime, extract the pid, sort and uniq -c to find the thread calling clock_gettime most often. Plotting the delta times nicely shows a line at 50 milliseconds. Further the PID can be found in a thread dump taken with jvisualvm as the nid in hex and turns out to be 'VM Periodic Task Thread'. But why so often? This does not seem to be a standard behaviour of the JVM.

Harald
  • 4,575
  • 5
  • 33
  • 72
  • strace just shows system calls. that doesn't really tell you which thread actually burns CPU time. after all they could be spent entirely in userspace. so what leads you to conclude that it's this particular thread or that it's the system calls that burn CPU time? – the8472 Jul 05 '15 at 15:30
  • I see it in htop, where exactly this thread is the only one accumulating used CPU time. – Harald Jul 05 '15 at 15:47
  • @the8472: Thanks for planting the doubt. I restarted and watched where the CPU time accrues. This time it is another thread, which makes a lot more sense: "MVStore background writer" of the h2 database. No idea why this did not pop up high in htop last time. – Harald Jul 05 '15 at 17:10

0 Answers0