rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Make `ModuleId` a tracked struct

Open Veykril opened this issue 6 months ago • 4 comments

This is in part an experiment. ~~I am partially hoping for this to have a positive memory impact (as it shrinks ModuleId from 12 to 4 bytes)~~ it did not sadge. Funnily enough I also revealed 2 bugs with this (and fixed them).

Veykril avatar Jun 14 '25 11:06 Veykril

What's the second bug?

flodiebold avatar Jun 14 '25 12:06 flodiebold

So this does increase memory usage by ~30mb 😕 I am not entirely sure why though I guess we have a lot of block def map queries, and us recording tracked structs in those now makes their memo's allocate the extra slot which is what is observable here? IO would've expected the ModuleId shrinking to balance that out at least. It might be better with the new salsa.

Veykril avatar Jun 14 '25 14:06 Veykril

So this does increase memory usage by ~30mb 😕 I am not entirely sure why though I guess we have a lot of block def map queries, and us recording tracked structs in those now makes their memo's allocate the extra slot which is what is observable here? IO would've expected the ModuleId shrinking to balance that out at least. It might be better with the new salsa.

Could working on #16368 mitigate this memory usage regression?

ShoyuVanilla avatar Jun 19 '25 05:06 ShoyuVanilla

Likely? Though that might also be orthogonal to this. Block def maps do have a lot of overhear iirespective of the changes here I'd say.

Veykril avatar Jun 19 '25 05:06 Veykril