From 436855423b51fa7140e839cc49a990b5f6481f8c Mon Sep 17 00:00:00 2001 From: davidsminor Date: Wed, 10 Feb 2016 14:48:07 -0800 Subject: [PATCH] Reduced hash cache clear frequency It looks like computing hashes in the instance scene is quite a bottleneck when using an instancer node. It turns out you can reduce procedural expansion time in an instancing scene by a factor of 6 by turning down the hash cache clearing frequency, at a memory cost of about 100 mb, which seems acceptable. This change does not appear to affect performance on scenes with no instancer. --- src/Gaffer/ValuePlug.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Gaffer/ValuePlug.cpp b/src/Gaffer/ValuePlug.cpp index 5c748f2ee4d..4c51b8d76ad 100644 --- a/src/Gaffer/ValuePlug.cpp +++ b/src/Gaffer/ValuePlug.cpp @@ -219,14 +219,15 @@ class ValuePlug::Computation { if( m_threadData->computationStack.empty() ) { - if( ++(m_threadData->hashCacheClearCount) == 100 || m_threadData->clearHashCache ) + if( ++(m_threadData->hashCacheClearCount) == 3200 || m_threadData->clearHashCache ) { // Prevent unbounded growth in the hash cache // if many computations are being performed // without any plugs being dirtied in between, // by clearing it after every Nth computation. - // N == 100 was chosen based on memory/performance - // analysis of a particularly heavy render process. + // N == 3200 was observed to be 6x faster than + // N == 100 for a procedural instancing scene at + // a memory cost of about 100 mb. m_threadData->hashCache.clear(); m_threadData->hashCacheClearCount = 0; m_threadData->clearHashCache = 0;