FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Unloading and Reloading

 
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries
View previous topic :: View next topic  
Author Message
bgeradz



Joined: 15 Aug 2008
Posts: 2

PostPosted: Tue Aug 26, 2008 1:36 am    Post subject: Unloading and Reloading Reply with quote

Seems that the best covered topic in realm of dynamic library loading (whether it's C, D, or Java) are facilities to LOAD something.

But UNLOADING is usually something no one ever cares about, some systems won't even allow one to do so.

As for DDL - so far the only thing I've found in tutorial was
Code:

 auto testFn = inSitu.getDExport!(void function(),"reflect.test")();
 testFn();

And comment:
Note the 'export' in the function definition above. This is important since nothing else calls test(), and the linker will be inclined to throw it away

I'd appreciate if someone could briefly explain
- what 'nothing else' above means,
- is there a way to control unloading automatically or manually
- maybe point to some RTFM's, or whatever concerns unloading.

What I'm thinking of -
Let's say you have a shared server with tons of CGI scripts, let's say PHP, from different users, scripts get frequently edited, etc.

What's good in PHP for this scenario, as long as the visitor activity is low, PHP/webserver won't eat any resources regardless of the total millions lines of code
But the huge drawback is - when activity is high, PHP needs to parse any script every time, even if nothing changes there which means huge CPU resource losses.

PHP was given just as an example, it's not about PHP.
Imagine PHP scripts were compiled. The engine loads compiled scripts and depending on their usage frequencies tracs permanently what might be unloaded to save space for scripts residing in memory. Smart handling of unloading would be of ultimate importance.
Another thing is RELOADING - schipt has changed, throw away old code from memory and replace by newly compiled.
There's DSP project put on hold and waiting for DDL to mature, I guess smart un/reloading is also hot topic for DSP.

I would appreciate any thoughts in context of DDL or generally, or pointing to further resources on that topic.

Kind regards!





[/code]
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Tue Aug 26, 2008 4:56 am    Post subject: Re: Unloading and Reloading Reply with quote

Howdy!

bgeradz wrote:
But UNLOADING is usually something no one ever cares about, some systems won't even allow one to do so.

That may be because unloading is the really tricky part. Once you load a lib, create some objects from it or generally reference data in it, you can't simply unload it. If you have some objects whose classes are defined in the lib and you try to call something on them once the lib is unloaded, you'll get access violations. Similarly with just data or function pointers. The GC could theoretically take care of the references and be able to tell you when the lib is no longer needed (I guess that's the plan), but I'm not sure it will be enough, since the GC is not exact but conservative, thus it may fail to state that the lib can be safely unloaded.
Anyway, unloading will require considerable effort, but I'm sure it's on the DDL task list.

Quote:
As for DDL - so far the only thing I've found in tutorial was
Code:

 auto testFn = inSitu.getDExport!(void function(),"reflect.test")();
 testFn();

And comment:
Note the 'export' in the function definition above. This is important since nothing else calls test(), and the linker will be inclined to throw it away

I'd appreciate if someone could briefly explain
- what 'nothing else' above means,

`No function transitively accessible from exported functions` would be my guess.

Quote:
- is there a way to control unloading automatically or manually

As far as I know, nope.

As for the `linker will be inclined to throw it away` comment, it does not relate to DDL's unlinking, but the compiler/linker that is used to build the library/object file from D source.


Quote:
Smart handling of unloading would be of ultimate importance.
Another thing is RELOADING - schipt has changed, throw away old code from memory and replace by newly compiled.
There's DSP project put on hold and waiting for DDL to mature, I guess smart un/reloading is also hot topic for DSP.

What you're saying is of course true and unloading is important for DDL, heck, it's important for my own use as well Wink DDL was in fact conceived for DSP, by DSP's creator - pragma. He's been experiencing some real-life time-eaters, but hopefully he'll be back on track pretty soon Smile
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries All times are GMT - 6 Hours
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


Powered by phpBB © 2001, 2005 phpBB Group