Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-23 Thread Duncan Coutts
On Tue, 2008-12-23 at 03:56 +0100, wman wrote: Thanks to you all for inspiration. My web app (which otherwise ran ok) was getting stuck while getting harassed by ab (apache-benchmark) after receiving some 800+ requests in short succession (not less, never gotten to 900, what was weird that

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Malcolm Wallace
Don Stewart d...@galois.com wrote: Modify the 'unsafe' inports to be 'safe'? I don't think HDBC is going to call back in, so should be fine. John? For those who are puzzled, Don is suggesting that foreign import ccall unsafe foo :: Bar - Baz should simply be changed to foreign import

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 10:30 +, Malcolm Wallace wrote: For those who are puzzled, Don is suggesting that foreign import ccall unsafe foo :: Bar - Baz should simply be changed to foreign import ccall safe foo :: Bar - Baz And in case anyone is wondering whether fiddling with

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread John Goerzen
Duncan Coutts wrote: On Mon, 2008-12-22 at 10:30 +, Malcolm Wallace wrote: The terminology seems counter-intuitive, but in other other words, a safe call is slower but more flexible, an unsafe call is fast and dangerous. Therefore it is always OK to convert an unsafe declaration into a

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Günther Schmidt
Hi, I am not yet 100% certain that the unsafe calls are indeed the cause of the problem, eventhough I strongly suspect there are. I can tell you more once I have managed to rewrite all unsafe calls into safe once, reinstall HDBC.Sqlite3 and then run my app again to see the effects. My

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread John Goerzen
Günther Schmidt wrote: Hi, I am not yet 100% certain that the unsafe calls are indeed the cause of the problem, eventhough I strongly suspect there are. I can tell you more once I have managed to rewrite all unsafe calls into safe once, reinstall HDBC.Sqlite3 and then run my app again

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread GŸuenther Schmidt
John Goerzen schrieb: Günther Schmidt wrote: Hi, I am not yet 100% certain that the unsafe calls are indeed the cause of the problem, eventhough I strongly suspect there are. I can tell you more once I have managed to rewrite all unsafe calls into safe once, reinstall HDBC.Sqlite3 and

RE: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Bayley, Alistair
From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Günther Schmidt 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

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 08:15 -0600, John Goerzen wrote: Duncan Coutts wrote: On Mon, 2008-12-22 at 10:30 +, Malcolm Wallace wrote: The terminology seems counter-intuitive, but in other other words, a safe call is slower but more flexible, an unsafe call is fast and dangerous.

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread John Goerzen
On Mon, Dec 22, 2008 at 04:28:03PM -, Bayley, Alistair wrote: From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Günther Schmidt I understand that Takusen does not use unsafe calls and would like to try it with that one then, but

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Günther Schmidt
Hi guys, I just tried to forkIO-off the database code to keep the UI responsive using Takusen with Sqlite this time. The problem persists though, the UI freezes. AFAIK the sqlite-Takusen code does not use unsafe ccall which would block the thread, so that might not be the cause of the

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 22:12 +0100, Günther Schmidt wrote: Hi guys, I just tried to forkIO-off the database code to keep the UI responsive using Takusen with Sqlite this time. The problem persists though, the UI freezes. You might need to provide us more details on the GUI code. As I

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Günther Schmidt
Hi, I put in on hpaste: http://hpaste.org/13264 slightly simplified Günther Am 22.12.2008, 22:36 Uhr, schrieb Duncan Coutts duncan.cou...@worc.ox.ac.uk: On Mon, 2008-12-22 at 22:12 +0100, Günther Schmidt wrote: Hi guys, I just tried to forkIO-off the database code to keep the UI

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Sterling Clover
Thanks John! I've been running into this quite a bit with the ODBC backend as well. Having an entire server app freeze because MS SQL Server decides to deadlock is rather unpleasant. Cheers, Sterl. On Mon, Dec 22, 2008 at 3:59 PM, John Goerzen jgoer...@complete.org wrote: On Mon, Dec 22, 2008

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 22:55 +0100, Günther Schmidt wrote: Hi, I put in on hpaste: http://hpaste.org/13264 slightly simplified Ok, that works fine when the action is something like threadDelay so it's clearly not blocking the UI. Duncan ___

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread GŸuenther Schmidt
Hi Duncan, are you saying then that the db-code is what's blocking the UI? Günther Duncan Coutts schrieb: On Mon, 2008-12-22 at 22:55 +0100, Günther Schmidt wrote: Hi, I put in on hpaste: http://hpaste.org/13264 slightly simplified Ok, that works fine when the action is

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Ryan Ingram
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

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Günther Schmidt
Hi Ryan, BINGO! that did it. Thanks a lot. It certainly works now, finally, eventhough I don't really know what the implications are. Günther Am 23.12.2008, 02:14 Uhr, schrieb Ryan Ingram ryani.s...@gmail.com: You shouldn't need forkOS, but without -threaded (and related RTS switches to

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread John Goerzen
Günther Schmidt wrote: Hi Ryan, BINGO! that did it. Thanks a lot. It certainly works now, finally, eventhough I don't really know what the implications are. Did it still work with the unmodified HDBC as well? Just curious. -- John ___

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread wman
Thanks to you all for inspiration. My web app (which otherwise ran ok) was getting stuck while getting harassed by ab (apache-benchmark) after receiving some 800+ requests in short succession (not less, never gotten to 900, what was weird that running like 500 reqs - pause - 500 reqs ... went

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-21 Thread Mads Lindstrøm
Hi Günther, Hi Mads, I'm using HDBC with sqlite3 Looking at http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Connection.hs and http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Statement.hsc you can see

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-21 Thread Don Stewart
redcom: Hi Mads, I just noticed that too. I had been wondering why this problem does not occur with the sample app from RWH eventhough I was employing the same technics as they did. It just occured to me that all the DB interactions in their app are fairly short and thus the

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-21 Thread Günther Schmidt
Hi Mads, I just noticed that too. I had been wondering why this problem does not occur with the sample app from RWH eventhough I was employing the same technics as they did. It just occured to me that all the DB interactions in their app are fairly short and thus the problem never becomes

Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-21 Thread Günther Schmidt
Hi Don, Modify the 'unsafe' inports to be 'safe'? I don't think HDBC is going to call back in, so should be fine. John? Sorry, total noob here, could you be more specific? Günther That said, we use Takusen or sqlite3 at work, without troubles. I might also check into that. -- Don