Conversation
|
Should we change all the Units to mutable units as well?? |
|
If it turns out to be an issue we should. Because I was using the default IO implementations here, there weren't any Unit allocs recorded, but we could duplicate this test on the actual robot to check the real IO impls. |
|
Ok, sounds good, lets test today and merge. Any reason this isn't the default for WPILIB? |
|
can u delete the |
|
The reason its not the default is more a Java issue than WPILib. There's some gotchas in how I implemented the mutable versions of the WPILib classes, especially when it comes to aliasing. Those are all nicely avoided in immutable versions, but in Java, those aren't cleaned up when they leave scope. Instead they're cleaned up whenever the JVM thinks is appropriate, but as we've seen in the shop, the JVM on the Rio isn't that smart. For what it's worth, the JVM on my desktop is able to keep memory manageable just fine, but I think the combination of the Rio's poor CPU and small amount of RAM makes Java ill-suited for the idiomatic "everything is immutable" style of programming that Java (and by extension, WPILib) encourages. |
Reduces GC pressure by reusing objects that have a lifetime smaller-than-or-equal-to the loop lifetime. This is done by using mutable versions of
Translation2d,Rotation2dandPose2d, which collision response made heavy use of. Over a minute test, these changes reduced the number of allocated bytes by ~78%.