#48558 introduced a CompensatedSum helper class to reduce duplicate code in aggregations that computed kahan summations for things like centroid, and average calculations. It definitely consolidated this code, but also resulted in multiple creations of these objects that can be avoided.
Possible solution:
A lot of the use-cases of CompensatedSum work off values from DoubleArrays, so maybe it is worth exploring a dedicated DoubleArray that has the kahan-summation logic baked into it. That way the calculation can be consolidated and in-line with no object allocations.