Merged
Conversation
Phase 1 of performance optimization work ported from performance-tweaks-2. Profiling Infrastructure: - Robot.java: Track scheduler and gameState timing (>20ms threshold) - Drive.java: Track lock, gyro, modules, odometry timing (>5ms threshold) - Module.java: Track updateInputs and logging timing (>2ms threshold) - Vision.java: Track copyInputs, cameraLoop, consumer timing (>5ms threshold) - Intake.java: Track update and logging timing (>2ms threshold) - Feeder.java: Track spindexer and kicker timing (>2ms threshold) CAN Optimization: - Remove BaseStatusSignal.refreshAll() calls that block on CAN responses - Rely on Phoenix 6 auto-update at configured frequency (50Hz telemetry) - Position signals for odometry handled by PhoenixOdometryThread at 250Hz - Check connection status via .getStatus().isOK() instead of blocking refresh Files modified: - Drive.java: Remove batched signal refresh, add profiling - Module.java: Remove refreshSignals()/getStatusSignals(), add profiling - ModuleIO.java: Remove interface methods for signal refresh - ModuleIOTalonFX.java: Remove allSignals array and refresh methods - IntakeRollerIOTalonFX.java: Use non-blocking status checks - FlywheelIOTalonFX.java: Use non-blocking status checks Documentation: - Add doc/TWEAKS3.md explaining changes and methodology
Phase 2 of performance optimization work. Profiling: - Launcher.periodic(): Track update, log, aimLog, ballistics timing (>3ms) - Launcher.aim(): Track v0nom, baseSpeeds, v0replan, setPos timing (>500μs) Deferred Logging: - Cache values in aim() instead of calling Logger.recordOutput() directly - Log cached data in periodic() via logCachedAimData() - Moves Logger overhead out of time-critical aim() hot path Zero-Velocity Guard: - Check v_r < 1e-6 before calling Translation2d.getAngle() - Prevents ArithmeticException or NaN when velocity is near zero Method Renames: - getV0() → getV0Nominal() (for impact angle calculation) - getV0() → getV0Replanned() (for flywheel speed recalculation)
Phase 3: Analyzed subsystems added since performance-tweaks-2 was branched for blocking CAN calls and added profiling where needed. Changes: - Add profiling to Hopper.java periodic() with 2ms threshold - Document Phase 3 analysis in TWEAKS3.md Analysis findings: - All Spark-based IOs (Spindexer, Kicker, Hood, Turret) already use SparkOdometryThread for non-blocking CAN reads - GyroIOBoron uses CanandgyroThread for non-blocking reads - Pneumatic IOs (Hopper, IntakeArm) use DoubleSolenoid which has no blocking CAN concerns The codebase is well-structured with consistent use of background threading for motor controller IO operations.
Profiling showed [Intake] update=23ms spikes caused by Logger.recordOutput() calls inside IntakeRollerIOTalonFX.updateInputs(). Each Logger call can take 10-30ms due to serialization overhead. Fix: Move follower telemetry into the IntakeRollerIOInputs struct so it gets logged via Logger.processInputs() in the subsystem's periodic() instead of blocking inside updateInputs(). Changes: - IntakeRollerIO: Add followerAppliedVolts, followerCurrentAmps fields - IntakeRollerIOTalonFX: Populate input fields instead of Logger calls - TWEAKS3.md: Document Phase 5 fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deploys and runs fine, though I only tested it in disabled.