Nexus-Mods / NexusMods.Paths

Custom path library used by NexusMods.App.
https://nexus-mods.github.io/NexusMods.Paths/
GNU General Public License v3.0
6 stars 0 forks source link

Current Implementation of GetAllDescendentFiles is Slow #22

Closed Sewer56 closed 11 months ago

Sewer56 commented 1 year ago

Improvement

Currently

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.

Sewer56 commented 11 months ago

This wasn't closed despite moved to Done, closing.