[osg-users] PagedLOD experts?

Paweł Księżopolski ksiezopolski at ai.com.pl
Thu Nov 5 06:32:52 PST 2009


 > What I haven't figured out is if there's ever a situation
 > where a node _leaves_ the inactive list and returns to the
 > active scenegraph without being deleted. In this case,
 > any tampering of the node name would have undesirable results.

There is at least one scenario in which PagedLODs named "NeedToRemove"
go to active list. It happens when you use 
Registry::instance()->_objectCache.

The scenario looks like this:
- PagedLODs marked as "NeedToRemove" are removed from _inactivePagedLODList.
  They also go to _fileRequestQueue->_childrenToDeleteList.
- request queue releases these PagedLODs, but they are still in 
Registry::instance()->_objectCache.
- _objectCache will release them in 10 seconds if no one will request 
for them.
- if databasePager will request using them again, FindPagedLODsVisitor 
will place these PagedLODs
  on _activePagedLODList  ( it's important to mention that these 
PagedLODs currently keep
  "NeedToRemove" name )
- sooner or later these PagedLODs will go to _inactivePagedLODList.
  Suppose we have 4 such PagedLODs( let's name them : A,B,C,D ).
- they will not be removed because variable numToRemove==0
- now, databasePager wants to remove another 4 PagedLODs ( marks them as 
"NeedToRemove",
  and places in _fileRequestQueue->_childrenToDeleteList ). Let's name those
  removed PagedLODs as : E,F,G,H.
- At that moment we have 8 PagedLODs marked as "NeedToRemove" on 
_inactivePagedLODList,
  but only 4 of them will be removed from _inactivePagedLODList because 
databasePager
  has variable numToRemove==4( probably A,B,C and D - thet're first on 
_inactivePagedLODList.
  But they probably shouldn't be removed now - their "NeedToRemove" name 
is here by accident ).
  This variable holds the quantity of PagedLods named "NeedToRemove" in 
last iteration ( E,F,G,H ).
- The quantity of PagedLODs named "NeedToRemove" in 
_inactivePagedLODList will raise
  until application takes all available memory.
- At that moment it is also possible that inactive PagedLODs named 
"NeedToRemove" go directly
  to active list if required ( and vice versa. See statistics below ).


In order to remove this error we've done two fixes :
1. We changed method DatabasePager::FindPagedLODsVisitor::apply() :
    virtual void apply(osg::PagedLOD& plod)
    {
        plod.setFrameNumberOfLastTraversal(_frameNumber);
    if(plod.getName()=="NeedToRemove")
        plod.setName("");
       
        _activePagedLODList.push_back(&plod);
        traverse(plod);
    }
2. We removed condition numRemoved<numToRemove, when PagedLODs named 
"NeedToRemove" are
   removed from _inactivePagedLODList:

   for(PagedLODList::iterator itr = _inactivePagedLODList.begin();
    itr!=_inactivePagedLODList.end() /*&& numRemoved<numToRemove*/; )

The second fix destroys optimization and is probably not necessary, 
because, we haven't
observed PagedLODs named "NeedToRemove", that go from 
_activePagedLODList to _inactivePagedLODList
after we used first fix.


At the end, we can show you some statistics for our terrain database - 
we where flying over the terrain
using the same AnimationPath:

1. Our application using original SVN source :
   See attached image PagedLOD_svn.png.
   Column B is the sum of PagedLODs (active+inactive), Column C - active 
PagedLODs,
   column D - inactive PagedLODs.

   As you can see - the count of inactive PagedLODs raises rapidly.
   The count of active PagedLODs moves chaotically between 150 and 300 
PagedLODs.

                Movement                        NTR / other names
   FindPagedLODsVisitor->_activePagedLODList  : 1008 / 3600
   _activePagedLODList->_inactivePagedLODList : 7358 / 12897
   _inactivePagedLODList->_activePagedLODList : 6101 / 8367
   _inactivePagedLODList->_objectCache        : 3232 / 3232

   We see heavy traffic between active and inactive list. Most of
   the PagedLODs moving from active to inactive ( and vice versa )
   has a name "NeedToRemove".
 
2. Our application using source with both fixes:
   See attached image PagedLOD_2_fixes.png.
   The Description of columns is the same as above.

   Sum of active and inactive PagedLODs is constant.
   The only thing that bothers me is the count of inactive PagedLODs.

                Movement                        NTR / other names
   FindPagedLODsVisitor->_activePagedLODList  : didnt test it
   _activePagedLODList->_inactivePagedLODList : 0 / 9583
   _inactivePagedLODList->_activePagedLODList : 0 / 5189
   _inactivePagedLODList->_objectCache        : 3992/3992

   No PagedLODs with name "NeedToRemove" goes from active to inactive
   or vice versa.

3.  Our application using only first fix :
   See attached image PagedLOD_1_fix.png.
   The Description of columns is the same as above.

   Sum of active and inactive PagedLODs is constant.
   Count of inactive PagedLODs is lower than in second example.

                Movement                        NTR / other names
   FindPagedLODsVisitor->_activePagedLODList  : 0/4584
   _activePagedLODList->_inactivePagedLODList : 0 / 9207
   _inactivePagedLODList->_activePagedLODList : 0 / 4609
   _inactivePagedLODList->_objectCache        : 4276/4276

   Example 2 and 3 look similar ( except for inactive to active movement,
   i dont know where is this difference coming from - need additional 
digging ),
   so there is no need to use second fix. Optimization is saved :)

-- 
Paweł Księżopolski



-------------- next part --------------
A non-text attachment was scrubbed...
Name: PagedLOD_svn.png
Type: image/png
Size: 24950 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20091105/e38a4fa6/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PagedLOD_1_fix.png
Type: image/png
Size: 26405 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20091105/e38a4fa6/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PagedLOD_2_fixes.png
Type: image/png
Size: 25790 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20091105/e38a4fa6/attachment-0005.png>


More information about the osg-users mailing list