OCCRA
Go to Post "We just fundraised $5000 for registration, and you spent it all on balloons?" - [more]
Home
Go Back   Chief Delphi > Technical > Programming
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 11-13-2017, 08:10 PM
JamieSinn's Avatar
JamieSinn JamieSinn is offline
Mentor
FRC #1334 (Red Devils)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2009
Location: Canada
Posts: 33
JamieSinn will become famous soon enough
Profiling the roboRIO? Why not?



Currently working on getting some data regarding a memory leak in our code. Made YourKit work on the roboRIO after some fiddling and editing.

I can post the tweaks required if anyone's interested.
__________________


1334/1374 Programming and Electrical Mentor
Reply With Quote
  #2   Spotlight this post!  
Unread 11-13-2017, 08:37 PM
gerthworm's Avatar
gerthworm gerthworm is offline
Making the 1's and 0's
FRC #1736 (Robot Casserole)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Peoria, IL
Posts: 201
gerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of light
Re: Profiling the roboRIO? Why not?

I'd be interested in details! I'm primarily interested to investigate which parts of our user code take the longest to execute. Memory usage would also be pretty nifty to know about too.
Reply With Quote
  #3   Spotlight this post!  
Unread 11-13-2017, 10:15 PM
JamieSinn's Avatar
JamieSinn JamieSinn is offline
Mentor
FRC #1334 (Red Devils)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2009
Location: Canada
Posts: 33
JamieSinn will become famous soon enough
Re: Profiling the roboRIO? Why not?

Quick list of things needed to be done in order to get YourKit working on the rio:
  • Make sure that tools.jar is in the JRE - you'll need to download this if it's not already there. Put it in JAVA_HOME/lib/ext
  • Add swap space, you won't be able to attach unless you have some RAM/Swap available
  • Clear out the majority of the the YourKit zip file, as there's limited space on the rio's flash, alternatively you could run this from a USB.
  • Run YourKit as lvuser, due to PID restrictions of some type.
  • A few others I'm probably forgetting

Here's a pretty image of what kind of CPU profiling I was able to do. NavX was taking a serious amount of CPU time. I need to cut down on that.

__________________


1334/1374 Programming and Electrical Mentor
Reply With Quote
  #4   Spotlight this post!  
Unread 11-15-2017, 09:08 AM
JesseK's Avatar
JesseK JesseK is online now
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 4,031
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by JamieSinn View Post
Here's a pretty image of what kind of CPU profiling I was able to do. NavX was taking a serious amount of CPU time. I need to cut down on that.
Last night I profiled cycle times from within Java, including a few new joystick mapping + logging methods. The total time to map an entire Logitech F310 (including POV's to DPad up/down/etc) from wpilib to my data structure was around 200 microseconds. Have you done something similar in code? I'm curious as to how long the NavX takes then.

Also note that the first run of any method in Java will not give accurate benchmarking data. This is because the class loader takes up so much time on the front-end to put the program code into memory. Yet subsequent runs (such as after the first few cycles of an iterative robot code) are more accurate. JProfiler had a setting to account for this by discarding the timing first few runs, but I'm not sure about YourKit.
__________________

Drive Coach, 1885 (2007-present)
Latest Project: Codex-based FRC Comms in Java

2017: Scoring Model | COPR Rank Simulator
1885: YouTube Channel | CAD Library | GitHub
Reply With Quote
  #5   Spotlight this post!  
Unread 11-15-2017, 02:05 PM
gerthworm's Avatar
gerthworm gerthworm is offline
Making the 1's and 0's
FRC #1736 (Robot Casserole)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Peoria, IL
Posts: 201
gerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of light
Re: Profiling the roboRIO? Why not?

Thanks so much! I'll probably give this a whirl in the next week or two!
Reply With Quote
  #6   Spotlight this post!  
Unread 11-15-2017, 03:25 PM
gerthworm's Avatar
gerthworm gerthworm is offline
Making the 1's and 0's
FRC #1736 (Robot Casserole)
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Peoria, IL
Posts: 201
gerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of lightgerthworm is a glorious beacon of light
Re: Profiling the roboRIO? Why not?

For swap space, I'm presuming this is implied to be on the roboRIO? Any special instructions for that? Or is simply a normal linux implementation going to work?
Reply With Quote
  #7   Spotlight this post!  
Unread 11-15-2017, 04:05 PM
marshall's Avatar
marshall marshall is online now
Discerning and exacting individual
FRC #0900 (The Zebracorns)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2003
Location: North Carolina
Posts: 1,994
marshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond repute
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by gerthworm View Post
For swap space, I'm presuming this is implied to be on the roboRIO? Any special instructions for that? Or is simply a normal linux implementation going to work?
It's a normal implementation from what I could tell. Definitely don't recommend doing it with a floppy drive though:



https://www.chiefdelphi.com/media/photos/45443
__________________
"La mejor salsa del mundo es la hambre" - Miguel de Cervantes
"The future is unwritten" - Joe Strummer
"Simplify, then add lightness" - Colin Chapman
Clarke's Laws
Reply With Quote
  #8   Spotlight this post!  
Unread 11-15-2017, 04:22 PM
JamieSinn's Avatar
JamieSinn JamieSinn is offline
Mentor
FRC #1334 (Red Devils)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2009
Location: Canada
Posts: 33
JamieSinn will become famous soon enough
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by gerthworm View Post
For swap space, I'm presuming this is implied to be on the roboRIO? Any special instructions for that? Or is simply a normal linux implementation going to work?
As Marshall said, it's just the normal procedure.
I made a 2GB swap file just to be safe, no issues for me with it.

I was running this test specifically for the beta testing, as there was a memory overallocation/leak in wpilib's SPI#read/write functions. (https://github.com/wpilibsuite/allwpilib/issues/733)

@JesseK - regarding the profiling, YourKit is the industry standard for java profiling - they do a lot more than JProfiler can. I believe they do ignore the first run of each function, but you could check the specifics if you wanted.

Attaching to the profiler will need a : instead of =. ie '-agentpath:/home/lvuser/yourkit/bin/linux-armv5-sf/libyjpagent.so'
__________________


1334/1374 Programming and Electrical Mentor
Reply With Quote
  #9   Spotlight this post!  
Unread 11-15-2017, 07:04 PM
JesseK's Avatar
JesseK JesseK is online now
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 4,031
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by JamieSinn View Post
@JesseK - regarding the profiling, YourKit is the industry standard for java profiling - they do a lot more than JProfiler can. I believe they do ignore the first run of each function, but you could check the specifics if you wanted.
Yea, that's good to know. I think I know what's throwing me off - the applications I've profiled don't typically call Thread.sleep().

Standard caveats about System.nanoTime() apply, but navx.getAngle() calls seem to be pretty fast. I suspect the profiler is calculating the time spent in each method call as raw, which effectively means the thread that the NavX software starts will be counted for the entirety of its instantiation, even though the thread asleep for most of the time.

I suspect that across all cycles of your robot, the NavX spent all but about 150ms asleep - meaning it took about 150ms of CPU time over 30 seconds. The good news is, your code is fine . Can you filter out any method that eventually calls a Thread.sleep() (including the wpilib Timer.delay() method)? That may give you a better understanding of what code is actually eating CPU.

__________________

Drive Coach, 1885 (2007-present)
Latest Project: Codex-based FRC Comms in Java

2017: Scoring Model | COPR Rank Simulator
1885: YouTube Channel | CAD Library | GitHub
Reply With Quote
  #10   Spotlight this post!  
Unread 11-15-2017, 07:30 PM
JamieSinn's Avatar
JamieSinn JamieSinn is offline
Mentor
FRC #1334 (Red Devils)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2009
Location: Canada
Posts: 33
JamieSinn will become famous soon enough
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by JesseK View Post
Yea, that's good to know. I think I know what's throwing me off - the applications I've profiled don't typically call Thread.sleep().

Standard caveats about System.nanoTime() apply, but navx.getAngle() calls seem to be pretty fast. I suspect the profiler is calculating the time spent in each method call as raw, which effectively means the thread that the NavX software starts will be counted for the entirety of its instantiation, even though the thread asleep for most of the time.

I suspect that across all cycles of your robot, the NavX spent all but about 150ms asleep - meaning it took about 150ms of CPU time over 30 seconds. The good news is, your code is fine . Can you filter out any method that eventually calls a Thread.sleep() (including the wpilib Timer.delay() method)? That may give you a better understanding of what code is actually eating CPU.

The CPU wasn't my goal for profiling, the memory was. Since there was this issue here: https://github.com/wpilibsuite/allwpilib/issues/733
__________________


1334/1374 Programming and Electrical Mentor
Reply With Quote
  #11   Spotlight this post!  
Unread 11-15-2017, 07:36 PM
JefferMC JefferMC is offline
Registered User
AKA: Jeff Corbett
FRC #1319 (Flash)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2005
Location: United States
Posts: 119
JefferMC has a spectacular aura aboutJefferMC has a spectacular aura about
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by JesseK View Post
Yea, that's good to know. I think I know what's throwing me off - the applications I've profiled don't typically call Thread.sleep().

Standard caveats about System.nanoTime() apply, but navx.getAngle() calls seem to be pretty fast. I suspect the profiler is calculating the time spent in each method call as raw, which effectively means the thread that the NavX software starts will be counted for the entirety of its instantiation, even though the thread asleep for most of the time.

I suspect that across all cycles of your robot, the NavX spent all but about 150ms asleep - meaning it took about 150ms of CPU time over 30 seconds. The good news is, your code is fine . Can you filter out any method that eventually calls a Thread.sleep() (including the wpilib Timer.delay() method)? That may give you a better understanding of what code is actually eating CPU.
Profilers, as a rule, wake up at a fixed interval and look at the PC, and the PCs in the call stack, and record them. Thus if the top of the call stack is sitting at an event wait (sleeps in most architectures are a queued timer that fires an event, followed by a wait for that event to happen), that should show up inside your routine, but it should also show the time spent in the system sleep routine.
Reply With Quote
  #12   Spotlight this post!  
Unread 11-15-2017, 08:35 PM
JesseK's Avatar
JesseK JesseK is online now
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 4,031
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by JamieSinn View Post
Here's a pretty image of what kind of CPU profiling I was able to do. NavX was taking a serious amount of CPU time. I need to cut down on that.
Quote:
Originally Posted by JamieSinn View Post
The CPU wasn't my goal for profiling, the memory was. Since there was this issue here: https://github.com/wpilibsuite/allwpilib/issues/733
Ah. Missed that part.
__________________

Drive Coach, 1885 (2007-present)
Latest Project: Codex-based FRC Comms in Java

2017: Scoring Model | COPR Rank Simulator
1885: YouTube Channel | CAD Library | GitHub
Reply With Quote
  #13   Spotlight this post!  
Unread 11-18-2017, 11:48 AM
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 871
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by JefferMC View Post
Profilers, as a rule, wake up at a fixed interval and look at the PC, and the PCs in the call stack, and record them. Thus if the top of the call stack is sitting at an event wait (sleeps in most architectures are a queued timer that fires an event, followed by a wait for that event to happen), that should show up inside your routine, but it should also show the time spent in the system sleep routine.
Careful with that statement. That's how sampling profilers work, not profilers in general.

Other profilers emulate all the instructions so they can be tracked or instrument the code to collect profiling information. Each profiler type has it's pros and cons.
Reply With Quote
  #14   Spotlight this post!  
Unread 11-18-2017, 12:29 PM
marshall's Avatar
marshall marshall is online now
Discerning and exacting individual
FRC #0900 (The Zebracorns)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2003
Location: North Carolina
Posts: 1,994
marshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond reputemarshall has a reputation beyond repute
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by AustinSchuh View Post
Careful with that statement. That's how sampling profilers work, not profilers in general.

Other profilers emulate all the instructions so they can be tracked or instrument the code to collect profiling information. Each profiler type has it's pros and cons.
This guy profiles.
__________________
"La mejor salsa del mundo es la hambre" - Miguel de Cervantes
"The future is unwritten" - Joe Strummer
"Simplify, then add lightness" - Colin Chapman
Clarke's Laws
Reply With Quote
  #15   Spotlight this post!  
Unread 11-19-2017, 04:52 PM
JefferMC JefferMC is offline
Registered User
AKA: Jeff Corbett
FRC #1319 (Flash)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2005
Location: United States
Posts: 119
JefferMC has a spectacular aura aboutJefferMC has a spectacular aura about
Re: Profiling the roboRIO? Why not?

Quote:
Originally Posted by AustinSchuh View Post
Careful with that statement. That's how sampling profilers work, not profilers in general.

Other profilers emulate all the instructions so they can be tracked or instrument the code to collect profiling information. Each profiler type has it's pros and cons.
Granted, there are different ways of executing profiling. Not all profiling is attempting to track where wall time is spent.
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 01:34 PM.

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