Bizarre profiler results

C

Chris

I'm using a CPU profiler to find the bottlenecks in my app. When I run my
app normally, a particularly time-critical part takes 58 seconds to run.
When I use a CPU profiler on it, and set the profiling method to "samples",
the execution time is 40 seconds.

That's right -- it runs faster with the profiler going in the background.
This makes no sense.

Perhaps someone can speculate as to why this is happening.

I had thought that perhaps the profiler was messing with the system clock
and it wasn't *really* going faster, but I timed it with a wall clock.
Nope -- it's really faster.

I had thought that it was an IDE thing. Nope -- if I run the app on the
command line, it's slow, and if I add the -Xrunhprof:cpu=samples option to
the command line, it runs fast.

I'm using JDK 1.3.1
 
J

Jon Skeet

Chris said:
I'm using a CPU profiler to find the bottlenecks in my app. When I run my
app normally, a particularly time-critical part takes 58 seconds to run.
When I use a CPU profiler on it, and set the profiling method to "samples",
the execution time is 40 seconds.

That's right -- it runs faster with the profiler going in the background.
This makes no sense.

Perhaps someone can speculate as to why this is happening.

Completely wild speculation: perhaps running in the profiler turns off
some JIT compiler optimisations which happen to unfortunately be
"pessimisations" on your code.
 
D

Daniel Dyer

I'm using a CPU profiler to find the bottlenecks in my app. When I run my
app normally, a particularly time-critical part takes 58 seconds to run.
When I use a CPU profiler on it, and set the profiling method to
"samples",
the execution time is 40 seconds.

That's right -- it runs faster with the profiler going in the background.
This makes no sense.

Perhaps someone can speculate as to why this is happening.

I had thought that perhaps the profiler was messing with the system clock
and it wasn't *really* going faster, but I timed it with a wall clock.
Nope -- it's really faster.

I had thought that it was an IDE thing. Nope -- if I run the app on the
command line, it's slow, and if I add the -Xrunhprof:cpu=samples option
to
the command line, it runs fast.

I'm using JDK 1.3.1


I have no idea, but it certainly sounds interesting. What is your code
doing (is it CPU-bound or IO-bound)? What platform are you using? Is it a
multi-processor machine? What other switches are you using with Java?


Dan.
 
R

Roedy Green

I'm using a CPU profiler to find the bottlenecks in my app. When I run my
app normally, a particularly time-critical part takes 58 seconds to run.
When I use a CPU profiler on it, and set the profiling method to "samples",
the execution time is 40 seconds.

It is a well known effect that employees are more productive when the
boss is watching.

-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top