cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Maya UDIM expansion slow (findAllFilesForPattern)

Maya UDIM expansion slow (findAllFilesForPattern)

Since Maya introduced official support for UDIM uv tiling Maya internally has a procedure for expanding a UDIM expression in a path to a list of files. This procedure slows down Maya's interactivity immensely when working with File nodes in the attribute editor and the Hypershade. It also slows down dependency queries.

 

After many hours of debugging some severe interactivity performance problems we were having with Maya on a production asset we narrowed down the source of these problems to this expansion function.

 

Maya/Python/Lib/site-packages/maya/app/general/fileTexturePathResolver.py - findAllFilesForPattern

 

This expansion function is not written in the most efficient manner. On the asset in question we had a single directory with around 1600 texture files. If you look at the way this function works you will quickly discover that the performance of this routine degrades severely when the size of the directory increases due to it's "os.path.isfile" check before the the re.match.

 

We have "monkey patched" our maya deployment to improve the performance of this function. With our changes we reduced a cmds.file(q=True, l=True) dependency query down from 3m-10m to 5-10s. 

We also noticed that when selecting file nodes it calls this function (likely to draw the UI controls on the file node). That's not surprising, but what is surprising is it appears to call this function twice. Doubling the expensive IO call. Selecting file nodes in this asset would lockup maya for about 10s. Now the lockup is hardly noticeable.

 

I have two suggestions.
1. At the very least, reverse the os.path.isfile and re.match calls in findAllFilesForPattern. Simply reversing them provides equivalent functionality with massive performance improvements.
2. Better yet, take advantage of python's os.scandir (new to python3, but there is a 3rd party backport to 2.7) which removes the need for the separate os.path.isfile call.

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea