hi!
i tried profiling my app, but it turns out there are some impediments
which make profiler4j not work with guice.
i as soon as i fire up an injector while under the -
javaagent:agent.jar i get the following stacktrace:
anyone experienced something similar? has anyone used a profiler
successfully with guice?
Hi!
This is just me wondering out loud, hoping for a cluestick:
Haven't there been slightly more than a few of these inconsistent
stack heights problems, with various tools? I've never heard of that
error before Guice, and now I feel I've seen them several times.
Here's two more than this third:
http://code.google.com/p/google-guice/issues/detail?id=168
http://forum.limewire.org/showthread.php?t=3602
Where is this stack depth measurement done?
I don't understand how it
is possible to get such inconsistencies given correct behavior from
all parts (although I got to admit that this is way out on the fringe
of my knowledge): If one set of bytecode transformations or
productions is legal and consistent, and another set also is legal and
consistent, how is it possible that the combination of those two
aren't?
I could see something like, figuratively, trying to make some
HTML text bold and then italic using two distinct transformations, and
ending up with <b><i>BoldItalic</b></i>. But if something remotely
like that is happening, then one of those tools is doing something
illegal, right?
.. and doesn't this potentially point to some rather obscure, and
possibly slightly illegal stuff, done by CGLib, or is it always the
other tool getting it wrong (which now then includes at least TPTP,
profiler4j, and some "performance monitoring & profiling tool from
HP")? The tool that last touches the code is the prime suspect, right?
Is that CGLib or the other tool?
Thanks for a very informative answer!
>
> if CGLIB was generating invalid bytecode then I would expect to see
> the verify error when you didn't use a profiler - so far I've only seen
> this when profilers are involved...
Well, the idea was that only when it came "last" to the code,
transformations it yielded could end up wrong. Thus you would never
observe an error with this as the sole tool. Also, one of the tools
could be more robust than the other, so that it consistently handled
being last, while the other didn't tackle that. Just musings..
I think that CGLib should fix that "unusualness" of itself (apparently
the number of explicit pops it sticks in before the multiple return
points it generates?!), adhering to Postel's law: Be conservative in
what you do; be liberal in what you accept from others. At least, it
could have some switch that could produce conservative code (default),
or drop this for the last bit of performance. And obviously, it might
well be that it really is the other tools that are in error - but that
isn't very helpful.
Endre.
Aren't all profiling tools using the same Java Virtual Machine
Profiling Interface? If so, we only have one CGLIB against one JVMPI,
_not_ one CGLIB against many profiling tools. Profiling tools are
merely front-ends that exchange events with JVMPI. So either CGLIB or
JVMPI (or both) could be responsible for the error.
Anyway, I'll have to agree with Stuart. Profiling dynamically
generated byte-code may not give you reliable numbers. It is better to
exclude generated classes from instrumentation target list and instead
measure the performance of classes that call generated code. Note that
I am only talking about CPU profiling. Memory is a different issue.
Have you tried different profiling modes (memory, CPU, code coverage)?
Are all of them failing?
Yegor
On Mar 16, 11:23 am, Endre Stølsvik <stols...@gmail.com> wrote:
> Hi!
>
> Thanks for a very informative answer!
>
>
>
> > if CGLIB was generating invalid bytecode then I would expect to see
> > the verify error when you didn't use a profiler - so far I've only seen
> > this when profilers are involved...
>
> Well, the idea was that only when it came "last" to the code,
> transformations it yielded could end up wrong. Thus you would never
> observe an error with this as the sole tool. Also, one of the tools
> could be more robust than the other, so that it consistently handled
> being last, while the other didn't tackle that. Just musings..
>
> I think that CGLib should fix that "unusualness" of itself (apparently
> the number of explicit pops it sticks in before the multiple return
> points it generates?!), adhering to Postel's law: Be conservative in
> what you do; be liberal in what you accept from others. At least, it
> could have some switch that could produce conservative code (default),
> or drop this for the last bit of performance. And obviously, it might
> well be that it really is the other tools that are in error - but that
> isn't very helpful.
>
> Endre.
It is JVMTI (Tools Interface), which is a superset of both JVMPI and
JVMDI (Profiling and Debug, respectively).
And no: As a user of the TI's debug-mode, one just get the entire
class' bytecode "presented" before it is created into an actual class
(whatever internal representation the VM use), to jack it up with
whatever instrumentation one wants to stick in. So TI has nothing to
do with it - it is algorithms one use to instrument the class that
thus is at fault. And Stuart most certainly has a point: It thus is
the profiling system that "last touches" the class: I kinda thought
that TI /first/ manipulated the class, before it was passed through
the other classloaders and whatnot - something that obviously doesn't
make much sense at all.
Endre
i tried to get profiler4j to work with guice, without success. excluding
*ByGuice* did not seem to work, my impression was, it does not allow
rules with two wildcards.
-Xverify:none did also not work, i just got a different error message,
also during startup, "invalid bytecode".
so i tried something simple: i downloaded the latest version of netbeans
6.5. after setting up the project correctly in netbeans (took about an
hour) it worked flawlessly. the netbeans debugger worked perfectly on
the exact same code profiler4j stumbled upon. the cglib classes did show
up in the profiler, although with no significant cpu/heap resources - i
did also find the cpu bottleneck i was facing - it was a simple issue of
excessive logging and rendering of sql statements. altering the log4j
parameters did fix this.
thanks so much for the suggestions in this thread!