Re: Shutting Down the RTS

2003-01-12 Thread John Meacham
An advantage of solution #2 is that the finalizers dont go through and
touch all the pages they modify causing them to be loaded into memory if
they had been swapped to disk and thrash the page lookup cache on the
CPU. The overhead of the RTS in general might drown out these concerns
but they are definatly considered important when writing efficient
C utilities.
John

On Mon, Jan 13, 2003 at 12:41:17AM +0100, Wolfgang Thaller wrote:
> I'm almost ready to send in a patch that should fix most of the current 
> issues with the threaded RTS.
> But I'm stuck at the problem of terminating the RTS in a proper way.
> 
> According to the GHC manual, a concurrent Haskell program should 
> terminate when the main action terminates. This sounds reasonable and 
> matches the behaviour of C programs on most platforms.
> 
> In the threaded RTS, this behaviour has never been implemented. We 
> can't simply return from schedule(), because we might no longer be 
> running in the thread of the RTS main() routine. The thread where 
> rts_mainEvalIO was called might be busy executing some foreign code 
> that we know nothing about.
> 
> (Im)possible solution #1: As soon as the main action terminates, call 
> shutdownHaskellAndExit(). At first, this seems to work fine.
> But then, shutdownHaskellAndExit() comes along and tries to run 
> finalizers. For every finalizer, the RTS is started back up again using 
> rts_mainEvalIO(), and this time, we really have to exit by returning 
> from rts_mainEvalIO().
> 
> Possible solution #2: Forget about running finalizers at program 
> termination and just exit().
> In most of the situations where I'd use finalizers, I don't need to run 
> them upon program termination, the OS cleans up after me. Also, the 
> finalizers are not run in the correct order anyway, and there are 
> situations where running them in the wrong order might be worse than 
> not running them at all.
> And, most of all, solution #2 is easy to implement.
> 
> Can somebody suggest a third solution, or shall I go for #2 for the 
> time being?
> 
> 
> Cheers,
> 
> Wolfgang
> 
> ___
> Glasgow-haskell-users mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
> 

-- 
---
John Meacham - California Institute of Technology, Alum. - [EMAIL PROTECTED]
---
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Shutting Down the RTS

2003-01-12 Thread Wolfgang Thaller
I'm almost ready to send in a patch that should fix most of the current 
issues with the threaded RTS.
But I'm stuck at the problem of terminating the RTS in a proper way.

According to the GHC manual, a concurrent Haskell program should 
terminate when the main action terminates. This sounds reasonable and 
matches the behaviour of C programs on most platforms.

In the threaded RTS, this behaviour has never been implemented. We 
can't simply return from schedule(), because we might no longer be 
running in the thread of the RTS main() routine. The thread where 
rts_mainEvalIO was called might be busy executing some foreign code 
that we know nothing about.

(Im)possible solution #1: As soon as the main action terminates, call 
shutdownHaskellAndExit(). At first, this seems to work fine.
But then, shutdownHaskellAndExit() comes along and tries to run 
finalizers. For every finalizer, the RTS is started back up again using 
rts_mainEvalIO(), and this time, we really have to exit by returning 
from rts_mainEvalIO().

Possible solution #2: Forget about running finalizers at program 
termination and just exit().
In most of the situations where I'd use finalizers, I don't need to run 
them upon program termination, the OS cleans up after me. Also, the 
finalizers are not run in the correct order anyway, and there are 
situations where running them in the wrong order might be worse than 
not running them at all.
And, most of all, solution #2 is easy to implement.

Can somebody suggest a third solution, or shall I go for #2 for the 
time being?


Cheers,

Wolfgang

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users