Go to Post FIRST is like we have traveled to the future, and we dont like what we saw when we got there. So we came back and now we are attempting to alter the future - KenWittlief [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-03-2013, 14:02
Phalanx's Avatar
Phalanx Phalanx is offline
Formerly Team 1089 (Mercury)
AKA: Michael Reffler
FRC #5431 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jun 2005
Rookie Year: 1999
Location: Lewisville, TX (previously NJ)
Posts: 384
Phalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond repute
JVM Pegs CRIO at 100% CPU Regardless of Code

We switched from Labview to Java (bad idea IMO) as that is what is taught in school. In making the transition I wanted to be certain we were not exceeding our capacity. I looked at the "Driver Station Log Viewer" and the logs from various runs both in competition and not.

One glaring issue that I have uncovered is that the CRIO CPU is pegged at 100% utilization regardless of how much code we have. Even a simple "Tank Drive" only with no other code also pegs the CPU at 100%.

Has anyone else noticed this? Is this normal for this JVM?

If this is true then you have no useful way to actually measure your code load, and be able to monitor when you are reaching the limits of processing on the CRIO from a JAVA environment perspective.

If this is true, then this needs to be addressed, would opening a tracker be the next logical step?
__________________
Don't just ask the experts, become one!
Leadership is not about ability. It's about responsibility!
Diagonally Parked in a Parallel Universe. It's okay we do Quantum Physics


Reply With Quote
  #2   Spotlight this post!  
Unread 25-03-2013, 14:08
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

Why in your opinion was the switch a bad idea? Our team moved to Java from Labview last season and have been nothing but happy with the switch. What problems have you run into other than the CPU running at 100%? Our CPU isn't pegged, or even close to being pegged with our competition code. Are you using command based robot, simple, or iterative?
Reply With Quote
  #3   Spotlight this post!  
Unread 25-03-2013, 14:24
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,080
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

This is almost certainly due to some feature of your code rather than the JVM itself. Our usage seldom goes above 80%.

Are you using the Simple Robot template? If so, do you have a while loop that does not have a Thread.sleep() in it?
Reply With Quote
  #4   Spotlight this post!  
Unread 25-03-2013, 14:31
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

Put us as a third team that does not peg the CPU with Java. I definitely agree that a simple robot template with no sleeps seems like the most likely cause.
Reply With Quote
  #5   Spotlight this post!  
Unread 25-03-2013, 14:46
Phalanx's Avatar
Phalanx Phalanx is offline
Formerly Team 1089 (Mercury)
AKA: Michael Reffler
FRC #5431 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jun 2005
Rookie Year: 1999
Location: Lewisville, TX (previously NJ)
Posts: 384
Phalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

I won't get into the reasons as to why I think it's a bad idea here. That's another long drawn out philosophical discussion. Just look it at from my perspective where I work with code at level that even a few nanoseconds in execution time matters.

Thanks for all the feedback, I'll look have our Teacher and Java educator along with our lead programmer take a deeper look at our code.

I think for comparisons sake, I'll build for myself from scratch a new SimpleRobot project.
__________________
Don't just ask the experts, become one!
Leadership is not about ability. It's about responsibility!
Diagonally Parked in a Parallel Universe. It's okay we do Quantum Physics



Last edited by Phalanx : 25-03-2013 at 16:41.
Reply With Quote
  #6   Spotlight this post!  
Unread 25-03-2013, 14:49
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

Quote:
Originally Posted by Phalanx View Post
I think for comparisons sake, I'll build for myself from scratch a new SimpleRobot project.
Follow the directions here: http://wpilib.screenstepslive.com/s/...ot-programming
Reply With Quote
  #7   Spotlight this post!  
Unread 25-03-2013, 15:20
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 1,942
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

I think you can code successfully in any of the 3 predominate languages used in First. If not all the powerhouse team would be using the same language. Bad idea to switch in the middle (or beginning) of build season though. Better to rewrite the code in last seasons robot to find the pitfalls.
Reply With Quote
  #8   Spotlight this post!  
Unread 25-03-2013, 16:02
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,188
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

Another thing to watch out for is SmartDashboard stuff. We had a SmartDashboard :: putData in one of our controller classes (that runs iteratively in a separate thread) which pegged us near 100%. Calling this 50 times less per second (aka 50HZ to 0Hz) brought us from near 100% CPU usage to ~50%.

(Without looking at the code, I'm guessing without a receiving dashboard app we were spamming handshakes?)
Reply With Quote
  #9   Spotlight this post!  
Unread 25-03-2013, 16:43
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

Quote:
Originally Posted by Phalanx View Post
If this is true then you have no useful way to actually measure your code load, and be able to monitor when you are reaching the limits of processing on the CRIO from a JAVA environment perspective
This caught my eye.

Why couldn't you instrument each thread in your code to read how long each thread takes to execute and whether or not it's being scheduled at the expected rate.


Reply With Quote
  #10   Spotlight this post!  
Unread 25-03-2013, 16:46
apples000's Avatar
apples000 apples000 is offline
Registered User
no team
 
Join Date: Mar 2012
Rookie Year: 2012
Location: United States
Posts: 222
apples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant future
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

When using threads/parallel processing in Java, it is easier to goof up than in LabView. Our robot has ~20 threads running, 5 PID loops, and vision, and it never goes over 85%. If you post your code, we can help you with it. One of the biggest problems is that sending errors to the DS can waste huge amounts of CPU usage, so you should check the diagnostics tab of the DS. I've actually found that Java is really efficient, and the difference between C++, LV, and Java(in terms of performance/speed) aren't noticeable to FRC teams.
Reply With Quote
  #11   Spotlight this post!  
Unread 25-03-2013, 16:47
Phalanx's Avatar
Phalanx Phalanx is offline
Formerly Team 1089 (Mercury)
AKA: Michael Reffler
FRC #5431 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jun 2005
Rookie Year: 1999
Location: Lewisville, TX (previously NJ)
Posts: 384
Phalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

Quote:
Originally Posted by Tom Bottiglieri View Post
Another thing to watch out for is SmartDashboard stuff. We had a SmartDashboard :: putData in one of our controller classes (that runs iteratively in a separate thread) which pegged us near 100%. Calling this 50 times less per second (aka 50HZ to 0Hz) brought us from near 100% CPU usage to ~50%.
Thanks Tom, We'll look at that as we are using the SmartDashboard.

Quote:
Originally Posted by Ether View Post
This caught my eye.

Why couldn't you instrument each thread in your code to read how long each thread takes to execute and whether or not it's being scheduled at the expected rate.


Thanks Ether, Yes we can do that, if we need to. Just didn't want to resort to doing that if we didn't have too.
__________________
Don't just ask the experts, become one!
Leadership is not about ability. It's about responsibility!
Diagonally Parked in a Parallel Universe. It's okay we do Quantum Physics


Reply With Quote
  #12   Spotlight this post!  
Unread 25-03-2013, 17:54
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: JVM Pegs CRIO at 100% CPU Regardless of Code

Quote:
Originally Posted by Phalanx View Post
Just didn't want to resort to doing that if we didn't have too.
I wonder if it might give more detailed insight into your thread execution.


Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:19.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi