You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[turbopack] Reduce the size of module graph datastructures (#79706)
## Refactor module graph to reduce memory usage
### What?
This PR refactors the module graph implementation to reduce memory usage by:
1. Changing `graph_idx` from `usize` to `u32` to reduce memory footprint
2. Removing unused fields from `SingleModuleGraphModuleNode` (layer and issues)
3. Moving layer resolution to the point of use in dynamic imports and server actions
This is a small progression in runtime:

### Why?
These changes optimize memory usage in the module graph, which is particularly important for large applications. By removing unused fields and using more compact types, we can reduce the memory footprint of the graph.
Notably, SingleModuleGraphNode is now 24 bytes instead of 48. To make it smaller still we would need to reduce the size of visited moduel, perhaps by storing a reference to the graph that did the original visit? This would be tricky from a lifetimes perspective but much more optimal.
0 commit comments