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

After looping over thousands times, the binding failed #3

Closed
tongqingwu opened this issue Dec 17, 2016 · 13 comments
Closed

After looping over thousands times, the binding failed #3

tongqingwu opened this issue Dec 17, 2016 · 13 comments

Comments

@tongqingwu
Copy link

In the testing java file, add more than 10000 loops, the fake time will change back to real time. So if we use the fake time agent for over hundreds threads and more test cases, it stops working.

@lukepeeler
Copy link

This will work with the following JVM options:

-XX:+UnlockDiagnosticVMOptions 
-XX:DisableIntrinsic=_currentTimeMillis 
-XX:CompileCommand=exclude,java/lang/System.currentTimeMillis

@lukepeeler
Copy link

This was for Java version:

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

@arvindsv
Copy link
Owner

@lukepeeler: Are you saying that the method got jitted and it was replaced with some intrinsic version of System.currentTimeMillis?? Wow. Ok. If so, I might need to find out if there's a way to disable that, for this method, from the agent.

@arvindsv
Copy link
Owner

I guess, not jitted. But, replaced with a native call, without JNI overhead.

@arvindsv
Copy link
Owner

Looks like you're right. The C2 compiler has a threshold of 10000 calls.

@lukepeeler
Copy link

Yeah, I got it to work initially with just -Xint which disabled JITing entirely but slows everything else down horribly as well.
The last option I listed above just tells the JVM not to JIT compile for this method, but it didn't prevent the mapping to the intrinsic method that the JVM usually associates with it, so I needed the extra option to disable the intrinsic mapping.

@arvindsv
Copy link
Owner

Ok, thanks!

It gets too hairy to try and do this in JVMTI, in my opinion. So, maybe we should document this?

@arvindsv
Copy link
Owner

If you agree, and want to make a change in the README, please do so. If you think something else can be done, I'm all ears.

@lukepeeler
Copy link

lukepeeler commented Dec 20, 2016

Yeah, I agree. And I think polluting the JVMTI code you have with what really amounts to a special case would make it harder for others to make it reusable for more general cases of binding natives. I think documentation is fine. There's a whole list of native methods that get the intrinsic treatment (though this probably differs by flavor/version of JVM): http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/87ee5ee27509/src/share/vm/classfile/vmSymbols.hpp#l581

@arvindsv
Copy link
Owner

Ok. Makes sense.

@tongqingwu, since you opened the original issue, can you verify that the suggested flags fix the issue for you too? If so, I can update the README.

@arvindsv
Copy link
Owner

@lukepeeler: Yes, I saw vmSymbols.hpp, when I was seeing if it's easy to disable intrinsics for this method. I was hoping for an easily accessible method to do that. But, it doesn't look like there is one.

@tongqingwu
Copy link
Author

@arvindsv : The solutions from Luke @lukepeeler works great! You should update the README.

This is the java version I am testing on, and with over hundreds of threads.

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

arvindsv added a commit that referenced this issue Dec 20, 2016
@arvindsv
Copy link
Owner

Done! I'll close this issue then. Thanks to both of you!

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

3 participants