Microchip's PIC32 toolchain strongly encourages the use of their framework, Harmony. Harmony does a lot of things well, but it isn't appropriate for every situation, and the Laser Galvo clock had one of those situations.
The PIC32 periodically drives a DAC via SPI. In the following oscilloscope screenshot, the yellow pulse shows the time taken to handle an interrupt. The blue lines show the SPI clock, and indicate when the transfers are taking place.
In total, it was taking about 32us, even though much SPI output was taking about 3us in total.
I changed the code to output via the lower level PLIB, and got this:
It's now taking less than 6us in total.
Because it is taking less time to output DAC changes, that means we can output them more frequently and perhaps draw smoother figures.