-
Notifications
You must be signed in to change notification settings - Fork 84
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
Insane CPU usage compared to running same executable from terminal (Mac OS) #97
Comments
@mrlimbic Very strange. Is Jadeo outputting something constantly to stderr or stdout? Have you tried attaching a profiler to see where the time is being spent? I would be very interested to see the profile. |
The protocol is simple and short. You type a simple one line text command which receives a simple text confirmation (usually also one line). If you start the app with arg --remote it will work in remote mode. Example remote control commands.. It's Jadeo itself that uses lots of CPU (but only when started from java), not the java app talking to it. I'm not sure how to profile Jadeo. I could profile the java app if that would help? |
@mrlimbic Profiling the Java-side could still (possibly) be interesting. Is this on Mac, Linux, or Windows? |
I don't know if this happens on other platforms. I am working in Mac OS so it may be specific. |
@mrlimbic Thanks. The code paths are different for each platform, so knowing the platform helps narrow down the code to be considered. The fact that the same issue occurs with ProcessBuilder and PipedXXXStreams is an interesting datapoint. It is pretty complex, but you can investigate running dtrace on the Jadeo process. It would give a good idea of where Jadeo is spending its time. If you do run a dtrace, please attach the trace log here. Though it would still be interesting to see the Java-side profile. |
How do I run dtrace on Jadeo when starting it from java? If I start Jadeo via dtrace in the terminal then the problem isn't replicated so that information won't be so useful. Which classes should I profile on the java side? Is there a way to profile native calls? |
@mrlimbic It looks like you can "attach" to a running process. Search for the word "attach" on the linked dtrace page. You're going to need to dig a little deep here, and google/research on your own about dtrace on OS X... |
Does this help? I used the dtrace script called syscallbypid.d The numbers for Jadeo were way bigger when run from java than any other process on the machine.
When run from terminal the numbers way lower and similar ranges to other process. These two were were the highest.
|
I don't know whether it's true with Jadeo (never heard of this application), but some applications I've seen (Git, for example) attempt to detect whether there's a PTY attached to the process and they run differently if there is. Perhaps the difference here is that when you run the process via NuProcess there's no PTY, but when you run it via the terminal there is? You might experiment with using |
Thanks @bturner. I gave up on this for a while due to no progress but will try your suggestion tomorrow. It's still something important that I'd like to be possible without setting fire to the laptop. |
When attempting to repoduce the problem from another language instead of Java I came across this difference in Python. I think you are right @bturner. The question is how can I do this from Java now. 100+% CPU usage like this.. But only 1% CPU usage like this.. |
Running process through bash reduces CPU from 100% to 15%. However still nowehere near as good as Python using shell=True.
|
I was trying to use remote control mode with Jadeo (MTC sync video player app) on Mac OS. In this mode Jadeo runs like an interpreter, so need to use I/O to send it commands and receive responses.
What is very strange is that CPU usage is 20x higher when using NuProcess vs running Jadeo in remote control mode from the Mac terminal.
What could be causing this? I tried to switch to using NuProcess because I had same issue when using ProcessBuilder and piped streams and thought it was blocking I/O with PipedStreams causing it. But NuProcess also does same. Why only from Java?
The text was updated successfully, but these errors were encountered: