imageworks/OpenShadingLanguage — pull request #195 by brechtvl (2012-12-21 17:35:38+00:00)
Title: Fix for slow compile and optimize times in the derivative tracking code

I got a report from a user that compiling this file gave 3GB+ memory usage and very long compile times.
http://download.blender.org/ftp/incoming/osl/slow_derivative_tracking.osl

It appears there is a O(n^2) time and memory behavior in the code that tracks which variables need derivatives. The fix itself is not very complex and the bad behavior seems to be there to make some debugging code work that is not compiled by default.

Note that the provided .osl will not actually work correctly when executed, it's unfinished code, but it should demonstrate the slow compilation.