xoofx / zio

A cross-platform abstract/virtual filesystem framework with many built-ins filesystems for .NET
BSD 2-Clause "Simplified" License
827 stars 61 forks source link

Speed up EnumeratePathsImpl in AggregateFileSystem #58

Closed garrynewman closed 3 years ago

garrynewman commented 3 years ago

Simplify the behaviour of EnumeratePathsImpl in AggregateFileSystem by querying child filesystems with the same arguments instead of querying all all filesystems for every file and directory potentially 1000's of times.

In one query in our game, where we had an AggregateFileSystem as a child of another AggregateFileSystem this took it from 3.38 seconds to 0.16 seconds.

xoofx commented 3 years ago

The idea looks good (I really don't remember why I implemented it that way). The CI is failing on one test.

xoofx commented 3 years ago

So incidentally, I'm profiling an app that is making an heavy use of Aggregate FS and the internal lock is causing x2 times slower execution, so I might add more a bit more optimizations on top of your code. Though, I have probably a different use case (mainly relying on TryGetPath).

garrynewman commented 3 years ago

That fixes the broken test for me ❤

xoofx commented 3 years ago

Thanks!