Re: [PATCH 1/3] rust: maple_tree: add MapleTree
From: Matthew Wilcox
Date: Sat Jul 26 2025 - 12:23:53 EST
On Sat, Jul 26, 2025 at 01:23:22PM +0000, Alice Ryhl wrote:
> +struct ma_state rust_helper_MA_STATE(struct maple_tree *mt, unsigned long start, unsigned long end)
> +{
> + MA_STATE(mas, mt, start, end);
> + return mas;
> +}
This seems very inefficient. Returning a struct larger than two words
(on x86 anyway) means that the compiler implements this as:
void rust_helper_MA_STATE(struct ma_state *masp, ...)
{
MA_STATE(mas, mt, start, end);
*masp = mas;
}
so that's about 72 bytes being memcpy'd per access to the maple tree.
Sure, it's stack, so it's cache hot, but surely we can implement
the equivalent of MA_STATE in Rust and see a significant performance
win, at least on read operations.