Closed Twolewis closed 1 week ago
Thank you for the report. I've added your fix to search in the parent directories first since it will be correct in most of the cases.
I've also kept the old behavior where it search in the whole project because we can have special cases where the pkproj is not directly in a parent folder like in the O3DEPopcornFXExamples project. In this case it will still be slow but we're looking for a way to improve that in future versions.
The fix is pushed on the development branch here daa4a75 and will be included in the next 2.20.1 patch.
The FindMatchingPkproj function in PackLoader.cpp takes an exceptionally long time, as it will scan the entire project directory for any files matching .pkproj, which will include .git folders, and so on.
This is most noticeable in the Asset Processor, as any pkfx processed file will rescan the entire project directory.
In our project, we've modified that function to only search the immediate files of the parent directory that contains assetPath, and failing that, traverses one directory up and repeats the process. The assumption here is that the pkproj will be found somewhere up the direct project hierarchy, which is true for our case. e.g
We check:
MyProject/SomeDir/AnotherDir/*.pkproj (fail)
MyProject/SomeDir/*.pkproj (fail)
MyProject/*.pkproj (success -> MyProject.pkproj)
If the pkproj is located outside the directory hierarchy, our solution will fail entirely. Since I don't know what the assumptions are wrt pkproj (can pkfx files be located outside the project folder?) I haven't made a PR for this change. It does work well for our setup, however.
Nevertheless, in its current implementation, FindMatchingPkproj gets slower the larger the project becomes, multiplied by the # of pkfx assets to process.