Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot capture performace #4

Closed
ivenhov opened this issue Jul 19, 2015 · 15 comments
Closed

Cannot capture performace #4

ivenhov opened this issue Jul 19, 2015 · 15 comments

Comments

@ivenhov
Copy link

ivenhov commented Jul 19, 2015

Hi I've tagged my method with:

@JmxExport
@PerformanceMonitor(warnThresholdMillis=1, errorThresholdMillis=100, recorderSource = RecorderSourceInstance.Rs5m.class)

And I get exception on it:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.spf4j.perf.aspects.PerformanceMonitorAspect.aspectOf()Lorg/spf4j/perf/aspects/PerformanceMonitorAspect;

I'm starting application From Eclipse with JDK 1.7.0_55
-javaagent:depend/aspectj/1.8.6/lib/aspectjweaver-1.8.6.jar

and with aop-ajc.xml in src/META-INFO folder
`

` Also JMX Beans are not visible in VisualVM at this point What am I doing wrong?
@zolyfarkas
Copy link
Owner

if you are using JDK 1.7 you should use the latest aspect 1.7.* if I remember correctly 1.8.* are for jdk 1.8.*

For your class to be accessible via JMX, you will need to call on of Registry.export() methods supplying your instannce and custom naming is desired.

what version of spf4j are you using?

@zolyfarkas
Copy link
Owner

take a look at: PerformanceMonitorAspectTest it is is a example of what you are trying to do.

@zolyfarkas
Copy link
Owner

Daniel, let me know if you want to add anything to this issue, otherwise I will proceed and close it.
thank you

@ivenhov
Copy link
Author

ivenhov commented Aug 10, 2015

Thanks for the tips. I used aspectj 1.7 with JDK 1.7 but it still failed.
But then by change I changed aop-ajc.xml file to have
rather than com... (I took that from your website 4.2.2 Via Annotations).
So now I have my app up and running but I don't see my performance metrics exposed via JMX beans (I'm using VisualVM to check that)

My method is tagged as follows:

@JmxExport
@PerformanceMonitor(warnThresholdMillis=1, errorThresholdMillis=100, recorderSource = RecorderSourceInstance.Rs5m.class)
public void execute() throws InterruptedException {
    // some stuff
}

Any idea what am I missing?
Thanks

@zolyfarkas
Copy link
Owner

You should see current recorded metrics (what is currently aggregated in memory) under:

org/spf4j/perf/recorders/class_org.spf4j.annotations.RecorderSourceInstance.Rs5m

what version of the library are you using?

the entire history of metrics you will get from the tsdb file.

The @JmxExport annotation is no necessary for that...

@ivenhov
Copy link
Author

ivenhov commented Aug 10, 2015

I'm using 7.2.12.
I'm clearly doing something wrong here as I don't have JMX visible.
I also don't have any tsdb output file (I'm assuming it would be under Eclipse's Java project somewhere).

My current classpath looks like this

spf4j-example/bin:spf4j-example/depend/aspectj/aspectjrt-1.7.4.jar:spf4j-example/depend/spf4j/lib/spf4j-aspects-7.2.12.jar:spf4j-example/depend/spf4j/lib/spf4j-core-7.2.12.jar:depend/aspectj/aspectjweaver-1.7.4.jar

I'm on MacOSX 10.9.5 in case that matters.

@zolyfarkas
Copy link
Owner

To run the aspect runtime weaver, you also need to start you app with:
-javaagent:${project.build.directory}/lib/aspectjweaver-${aspectj.version}.jar

The tsdb files location is controlled via : -Dperf.db.folder=[whatever]
default location is whatever java.io.tmpdir points to in your system.

let me know. thank you

@ivenhov
Copy link
Author

ivenhov commented Aug 11, 2015

Sorry, I forgot to mention. Yes I'm running it with weaver.
-javaagent:depend/aspectj/aspectjweaver-1.7.4.jar

And have in console
objc[74627]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
[AppClassLoader@5e159d10] info AspectJ Weaver Version 1.7.4 built on Friday Oct 25, 2013 at 15:00:26 GMT
[AppClassLoader@5e159d10] info register classloader sun.misc.Launcher$AppClassLoader@5e159d10
[AppClassLoader@5e159d10] info using configuration /Users/daniel/Documents/dev/eclipse/workspace/spf4j-example/bin/META-INF/aop-ajc.xml
[AppClassLoader@5e159d10] info register aspect org.spf4j.perf.aspects.PerformanceMonitorAspect

And application starts as normal.

After adding -Dperf.db.folder=output I don't get anything in that folder, no files are being created,
that's why I'm thinking it's some basic thing I missed.

Thanks for help so far
Daniel

@zolyfarkas
Copy link
Owner

is your annotated method being invoked? The JMX registration is Lazy...

you can troubleshoot and see if your classes are being weaved with: weaver options="-verbose -debug"

You should see something like:
[WeavingURLClassLoader] debug weaving 'com.foo.bar.YourPerfMonitorAnnotatedClass'

let me know.

@ivenhov
Copy link
Author

ivenhov commented Aug 11, 2015

Hi Zoltan

Thanks for tips on weaver options.
My class was not weaved and then I figured there was missing dot in aop-xml file

NOw it shows class is weaved but still fails

objc[40374]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
[AppClassLoader@5e159d10] info AspectJ Weaver Version 1.7.4 built on Friday Oct 25, 2013 at 15:00:26 GMT
[AppClassLoader@5e159d10] info register classloader sun.misc.Launcher$AppClassLoader@5e159d10
[AppClassLoader@5e159d10] info using configuration /Users/daniel/Documents/dev/eclipse/workspace-experimental/spf4j-example/bin/META-INF/aop-ajc.xml
[AppClassLoader@5e159d10] info register aspect org.spf4j.perf.aspects.PerformanceMonitorAspect
[AppClassLoader@5e159d10] debug weaving 'com.example.profile.Main'
[AppClassLoader@5e159d10] debug generating class 'com.example.profile.Main$AjcClosure1'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.Signature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.Factory'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.SignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.UnlockSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.UnlockSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.LockSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.LockSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.AdviceSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.AdviceSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.CodeSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.MemberSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.CodeSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.MemberSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.InitializerSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.InitializerSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.CatchClauseSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.CatchClauseSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.FieldSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.FieldSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.ConstructorSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.ConstructorSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.MethodSignatureImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.MethodSignature'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.reflect.SourceLocation'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.JoinPoint$StaticPart'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.JoinPoint'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.JoinPoint$EnclosingStaticPart'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.SignatureImpl$Cache'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.JoinPointImpl$StaticPartImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.SourceLocationImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.runtime.reflect.JoinPointImpl'
[AppClassLoader@5e159d10] debug cannot weave 'org.aspectj.lang.ProceedingJoinPoint'
[AppClassLoader@5e159d10] debug not weaving 'org.spf4j.perf.aspects.PerformanceMonitorAspect'
Exception in thread "main" java.lang.NoSuchMethodError: org.spf4j.perf.aspects.PerformanceMonitorAspect.aspectOf()Lorg/spf4j/perf/aspects/PerformanceMonitorAspect;
at com.example.profile.Main.execute(Main.java:15)
at com.example.profile.Main.main(Main.java:25)

I'm still on JDK1.7 and weaver 1.7.4

My current config

<?xml version="1.0" encoding="UTF-8"?>
<aspectj>
<aspects>
    <aspect name="org.spf4j.perf.aspects.PerformanceMonitorAspect" />
</aspects>
<weaver options="-verbose -debug">
    <include within="com.example..*" />
    <exclude within="org..*" />
</weaver>
</aspectj>

@zolyfarkas
Copy link
Owner

You should not exclude the aspect classes from weaving.
your exclude within="org..*" includes the PerformanceMonitorAspect...

I think including org.spf4j.perf.aspects.PerformanceMonitorAspect in your weaving should resolve your issue.

@ivenhov
Copy link
Author

ivenhov commented Aug 12, 2015

Yes, you're absolutely right. I excluded it only because of the errors. What I had do now was explicitly including org. in weaver, add guava + slf4j + logback as dependencies and my application starts! Thanks a bunch.
So aop-ajc.xml is now

<?xml version="1.0" encoding="UTF-8"?>
<aspectj>
<aspects>
    <aspect name="org.spf4j.perf.aspects.PerformanceMonitorAspect" />
</aspects>
<weaver options="-verbose -debug -showWeaveInfo">
    <include within="com.example..*" />
    <include within="org..*" />
</weaver>
</aspectj>

I still don't see JMX beans exported though...

Below my sample code

public class Main {
@JmxExport
@PerformanceMonitor(warnThresholdMillis=1, errorThresholdMillis=100, recorderSource = RecorderSourceInstance.Rs5m.class)
public void execute() throws InterruptedException {
    int i = 0;
    while (true) {
        System.out.println("Another iteration: " + i);
        i++;
        Thread.sleep(1000);
    }
}

public static void main(String[] args) throws Exception {
    Main m = new Main();
    m.execute();
}
}

@zolyfarkas
Copy link
Owner

What is you JMX aim?

If you want to be able to execute the method "execute()" via JMX, all you need to do is add:

Registry.export(m);

before m.execute()

If you want to see the aggregated measurements you will find them via JMX console underneath: org.spf4j.perf.recorders.

but since m.execute() does not ever finish, you will not find any measurements..

when you annotate the execute() method with PerformancceMonitor you basically measure the execution times of this method. if the method never finished nothing is ever recorded.

I am not sure what you are trying to do...

@ivenhov
Copy link
Author

ivenhov commented Aug 12, 2015

Thanks Zoltan

This is exactly what I missed. Of course method never finishes. I changed code and now I can see both JMX and logs from PerformanceMonitorAspect.

I had to add following dependencies (I'm not using Maven)
aspectj, avro, google-guava, jackson, slf4j, trove

Maybe it would be good idea to add info about that somewhere in the docs for future reference.

Thanks a bunch for your help.
I think you can close the issue now

@zolyfarkas
Copy link
Owner

Great!

I will update the docs based on our conversation... Documentation is never enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants