The GetAllDescendentFiles method in NexusMods.App is implemented using Linq's SelectMany recursively.
This method can potentially be a hot path, especially for large mod deployments.
The current implementation suffers from performance issues due to SelectMany working with a state machine under the hood, which leads to heap allocations. The recursive nature of the method exacerbates this issue by constructing multiple nested state machines, causing a significant slowdown.
We want
We aim to improve the performance of GetAllDescendentFiles by rewriting the method to avoid using Linq's SelectMany recursively, thereby eliminating the need for heap-allocated state machines. The new implementation should be faster and more memory-efficient, especially for large mod deployments.
Improvement
Currently
The
GetAllDescendentFiles
method in NexusMods.App is implemented using Linq'sSelectMany
recursively. This method can potentially be a hot path, especially for large mod deployments.The current implementation suffers from performance issues due to
SelectMany
working with a state machine under the hood, which leads to heap allocations. The recursive nature of the method exacerbates this issue by constructing multiple nested state machines, causing a significant slowdown.We want
We aim to improve the performance of
GetAllDescendentFiles
by rewriting the method to avoid using Linq'sSelectMany
recursively, thereby eliminating the need for heap-allocated state machines. The new implementation should be faster and more memory-efficient, especially for large mod deployments.