Closed bhall-ctre closed 8 months ago
Maybe the HAL notifier that triggers TimedRobot's periodic functions is tightlooping? The FPGA clock handling changed in https://github.com/wpilibsuite/allwpilib/pull/5499, so it's possible rollover broke.
I can put together a simple C++ program that logs the measured time delta of robot periodic to test that.
it's possible rollover broke
My original test for this had some interesting results. I used DataLog to log the measured time delta, forgetting that it uses the FPGA clock for timestamps. My wpilog ended up having a hard cutoff at around 72 minutes (when the issue started to reproduce). That does imply that either robotPeriodic wasn't being called at all after the issue started reproducing, or the FPGA timestamp rollover isn't being handled correctly (and my log actually just jumped to some other timestamp).
Once I'm back in the office after Thanksgiving, I can redo the test with our .hoot
logger to get more conclusive results, since it uses a different monotonic timebase.
It appears the new timestamp function isn't getting the high part of the timestamp, so it's rolling over to zero instead of continuing to increment. It appears the FPGA may not be copying the high part of the timestamp to the memory buffer we grab the timestamp from.
Yep, that's what I now see in my logs as well. "FPGA Upper" is the value reported by global->readLocalTimeUpper(&status)
from the HAL layer, and "FPGA Time" is the value reported by frc::RobotController::GetFPGATime()
. Even though readLocalTimeUpper
properly reports the upper portion of the timestamp, it looks like the HMB is not reporting it.
I also separately proved that all of the periodic functions stop running completely once the FPGA timestamp rolls over, so I don't know what's actually causing the heightened CPU usage. Regardless, fixing the FPGA timestamp should resolve this issue.
It’s almost certainly something in libuv (used in ntcore)—we use the FPGA timestamp for the libuv timers.
This should be fixed by Beta 4 when it comes out.
I have confirmed that this issue no longer appears to reproduce with the 2024_v2.0 roboRIO image and WPILib beta-4.
As part of our periodic system testing, we found that the CPU usage of the roboRIO seems to periodically increase to very high levels with an empty TimedRobot project, shown below.
It takes 72 minutes for the issue to initially reproduce. Once it does, these cycles of increased CPU usage appear to occur with a period of around 72 minutes (36 minutes high, 36 minutes low). Our testing was performed with the roboRIO2_2024_v1.1 image and WPILib project information:
I've confirmed using
top
that the spike in CPU usage primarily comes from the robot program (/home/lvuser/frcUserProgram
), although interestinglyirq/61-atomiczy
also seems to be elevated.Normal CPU usage:![image](https://github.com/wpilibsuite/2024Beta/assets/73118262/db4576cb-34b8-435f-94fe-50b96110cb5d)
High CPU usage:![image](https://github.com/wpilibsuite/2024Beta/assets/73118262/479ea218-0d63-49e4-865c-99cb7a01b159)
During high CPU usage, code deploy often fails. Restarting robot code resolves the period of high CPU usage.