Introduce buffer pooling (reuse temporary arrays across operations) for algorithms where memory allocation happens very frequently (like trees).
impl BaseTreeRegressor {
pub fn fit_with_pooling(/* params */) -> Self {
// Use pooling for tree construction
}
pub fn fit(/* params */) -> Self {
// Regular allocation for simple cases
self.fit_with_pooling(/* params */)
}
}
For an extensive overview: https://gist.github.com/Mec-iS/4a0a068e5d6b6901125812c27f9e3b97