View Single Post
  #8   Spotlight this post!  
Unread 28-02-2016, 23:45
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,106
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Efficiency of Network Tables

Quote:
Originally Posted by virtuald View Post
Not true for Java... if you look at the Java code most of the methods are marked as 'synchronized'. The DriverStation thread task calls getData() which goes into HAL a bunch so it's probably not particularly fast (JNI overhead) -- and it's also marked as synchronized, so they'll all block each other in various ways.

I didn't realize that C++ did this differently though, very interesting.
Yeah Java does it differently. I have some patches that bring Java and C++ closer together in Gerrit, but they are not going to be merged until after the season. They also use ReaderWriterLocks and double buffering in order to reduce memory usage and increase speed as well. Also Javas GetData doesn't get the status data anyway, so those are not cached and called individually.

Also, its not HAL or JNI overhead. For some reason, any call into the FRC_NetworkCommunication library takes 0.2-0.3ms. Doesn't matter which language, just entering those takes the time. So when the DriverStation Robot Mode check methods are called, every single time they enter that library, and every single call takes 0.2-0.3ms. If you run a loop in Teleop, that in a for loop calls DriverStation.IsEnabled 300 times, that entire sequence will take about 60 ms to run.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.