Optimization suggestion
Posted: Wed Jan 29, 2020 3:04 pm
Hi,
I've made a test for my software consisting in adding about 120 point lights in my environment.
It appears that when loading the scene, hlms shader creation takes a looooooots of times just inside the Hlms::findBlockEnd function (about 76% of the whole loading time, see the screenshot)

By looking at the code, it seems you just try to check if a string begin with a test string :
or
and if the main string is big (and it is because it's a hlms file) there is a lot of time wasted by looking after the beginning of the string.
What I suggest you is to add an SubStringRef::startWith function (or whatever name you want) to replace those test in the Hlms::findBlockEnd (and maybe in other places)
My test was made with the function :
Which seems right and reduced a lot the shader compile time for my test.
NB : Ok, my version of Ogre 2.1 is not up to date because I cannot update it. BUT the same advice apply in the actual branch of Ogre 2.1 as I checked...
I've made a test for my software consisting in adding about 120 point lights in my environment.
It appears that when loading the scene, hlms shader creation takes a looooooots of times just inside the Hlms::findBlockEnd function (about 76% of the whole loading time, see the screenshot)

By looking at the code, it seems you just try to check if a string begin with a test string :
Code: Select all
size_t idx = subString.find( "end" );
if( idx == 0 )Code: Select all
size_t idxBlock = subString.find( blockNames[i] );
if( idxBlock == 0 )What I suggest you is to add an SubStringRef::startWith function (or whatever name you want) to replace those test in the Hlms::findBlockEnd (and maybe in other places)
My test was made with the function :
Code: Select all
bool startWith( const char *stringCompare, size_t size) const
{
return strncmp(mOriginal->c_str() + mStart, stringCompare, size) == 0;
}NB : Ok, my version of Ogre 2.1 is not up to date because I cannot update it. BUT the same advice apply in the actual branch of Ogre 2.1 as I checked...