[Haskell-cafe] Re: Threads with high CPU usage
redcom at fedoms.com
Mon Dec 22 21:30:06 EST 2008
that did it.
Thanks a lot. It certainly works now, finally, eventhough I don't really
know what the implications are.
Am 23.12.2008, 02:14 Uhr, schrieb Ryan Ingram <ryani.spam at gmail.com>:
> You shouldn't need forkOS, but without -threaded (and related RTS
> switches to enable multithreading) I think you are sunk. Without
> enabling multithreading support, you are saying that your program
> (which might use concurrency features of Haskell) will run on a single
> OS thread. During a foreign call that never calls back into Haskell,
> then, there's no place for the RTS to pre-empt and switch back to
> Haskell code.
> It's kind of confusing with multiple things named threads; call a
> Haskell thread a "lightweight" thread, and an OS thread a "heavy"
> thread. Each heavy thread can either be executing Haskell lightweight
> threads, or inside a foreign out-call. Once you jump across to
> foreign-land, the heavy thread can't do anything (even for a "safe"
> out-call) until the out-call either makes an in-call back into Haskell
> code, or returns.
> Enabling -threaded allows the Haskell runtime to create more heavy
> threads; even without -threaded you can make as many lightweight
> threads as you like and the runtime will handle scheduling them for
> you; a heavy thread can carry many light threads. But a foreign call
> takes a whole heavy thread no matter what.
> -- ryan
> On Mon, Dec 22, 2008 at 1:12 PM, Günther Schmidt <redcom at fedoms.com>
>> Hi guys,
>> I just tried to forkIO-off the database code to keep the UI responsive
>> Takusen with Sqlite this time.
>> The problem persists though, the UI freezes.
>> AFAIK the sqlite-Takusen code does not use unsafe ccall which would
>> the thread, so that might not be the cause of the problem after all.
>> Before you guys make the effort to "fix" this you might see if you can
>> reproduce the problem maybe uploading a 50 MB file into an Sqlite
>> for instance, or something else that will keep the database busy for
>> time in a row.
>> I did not use -threaded and forkOS though.
>> Am 22.12.2008, 21:59 Uhr, schrieb John Goerzen <jgoerzen at complete.org>:
>>> On Mon, Dec 22, 2008 at 04:28:03PM -0000, Bayley, Alistair wrote:
>>>> > From: haskell-cafe-bounces at haskell.org
>>>> > [mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Günther
>>>> > I understand that Takusen does not use "unsafe" calls and
>>>> > would like to
>>>> > try it with that one then, but haven't find enough docs yet
>>>> > on how to use
>>>> > Takusen.
>>>> Not a lot of detailed examples exist for Takusen. I'm hoping the
>>>> documentation for Database.Enumerator is a reasonable place to start.
>>>> I just reviewed the Takusen code and, for no apparent reason, the ODBC
>>>> module specifies unsafe for all of its FFI imports, but the other
>>>> modules do
>>>> not (so they get the default, which I assume is safe). I also was not
>>>> of unsafe calls blocking other threads. I'll change the ODBC imports
>>>> to be
>>>> safe (or rather, unspecified).
>>> Makes sense. I will make the similar change in all HDBC backends.
>>> -- John
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe