OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Avoid call of SetupThreads in DatabasePager Constructor


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission
View previous topic :: View next topic  
Author Message
remoe
User


Joined: 11 Jul 2011
Posts: 41

PostPosted: Sun Apr 30, 2017 2:05 pm    Post subject:
Avoid call of SetupThreads in DatabasePager Constructor
Reply with quote

Hi,

Any reviews for:

https://github.com/openscenegraph/OpenSceneGraph/pull/252

?

Thank you!

Cheers,
Remo
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11192

PostPosted: Sun Apr 30, 2017 4:13 pm    Post subject:
Avoid call of SetupThreads in DatabasePager Constructor
Reply with quote

It's the weekend so just popping online briefly, will take a proper
look in the week. As a general note just ripping out code because it
doesn't work in certain usage cases isn't a good approach, it tells us
nothing about what was the actual problem, how to reproduce it and
hence how to properly evaluation what the fix should be, As is it
looks like a workaround hack that will have consequence s rather than
an actual fix.

On 30 April 2017 at 15:05, Remo Eichenberger <> wrote:
Quote:
Hi,

Any reviews for:

https://github.com/openscenegraph/OpenSceneGraph/pull/252

?

Thank you!

Cheers,
Remo

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70864#70864








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
remoe
User


Joined: 11 Jul 2011
Posts: 41

PostPosted: Sun Apr 30, 2017 4:35 pm    Post subject:
Reply with quote

Hi Robert

How one should change the number of threads dynamic before DatabasePager initialise it in his singleton?

Code:
   
int cores = Registry::capabilities().getNumProcessors();
osg::DisplaySettings::instance()->setNumOfDatabaseThreadsHint( osg::clampAbove(cores, 2) );
osg::DisplaySettings::instance()->setNumOfHttpDatabaseThreadsHint( osg::clampAbove(cores/2, 1) );


It will not work. It works only with an environment variable. The singleton should not setup the threads on startup. The constructor of a singleton is at beginning of application startup. The order of initialise is not defined (only from the compiler).

Cheers,
Remo
Back to top
View user's profile Send private message
Jason Beverage
Guest





PostPosted: Fri May 05, 2017 4:02 pm    Post subject:
Avoid call of SetupThreads in DatabasePager Constructor
Reply with quote

Hey Robert,

I took a look at this and I think Remo is right.  Basically the issue is that if you do anything that forces the osgDB library to be loaded before you have a chance to set your desired settings in osg::DisplaySettings then they won't take effect b/c the prototype DatabasePager is created here on library load:
https://github.com/openscenegraph/OpenSceneGraph/blob/10d8ac7f65b177a3a92a28e2f976413c9c641489/src/osgDB/DatabasePager.cpp#L1243



So if you happen to do what Remo is doing by using osgDB to get the number of processors, your DisplaySettings won't take effect b/c the prototype pager has already been created.


I've been bit by this a few times as well, so it's something worth looking at.  It's also a hard problem to track down b/c it just usually manifests itself as "Why is osgearth slow in my app but not in osgviewer"


Perhaps the answer is to create the prototype on demand instead of on library load?


Jason


On Sun, Apr 30, 2017 at 12:31 PM Remo Eichenberger < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi Robert

How one should change the number of threads dynamic before DatabasePager initialise it in his singleton?


Code:

int cores = Registry::capabilities().getNumProcessors();
osg::DisplaySettings::instance()->setNumOfDatabaseThreadsHint( osg::clampAbove(cores, 2) );
osg::DisplaySettings::instance()->setNumOfHttpDatabaseThreadsHint( osg::clampAbove(cores/2, 1) );




It will not work. It works only with an environment variable. The singleton should not setup the threads on startup. The constructor of a singleton is at beginning of application startup. The order of initialise is not defined (only from the compiler).

Cheers,
Remo

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70866#70866





_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Call for assistance: Migrating and up... Chris Hanson General 10 Mon Oct 09, 2017 4:07 pm View latest post
No new posts Call for testing, preparing for 3.5.6... bouffa General 23 Thu May 11, 2017 4:25 pm View latest post
No new posts How to avoid stencil interference bet... pugdogfan General 1 Wed Feb 15, 2017 10:58 am View latest post
No new posts How to check if pagedLod already exis... srappose General 10 Tue Nov 29, 2016 10:15 am View latest post
No new posts osgViewer::GraphicsWindowEmbedded con... Davide Raccagni Submission 4 Wed Sep 28, 2016 9:19 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP