Re: [Haskell-cafe] Turn GC off

2011-09-29 Thread Ovidiu Deac
To me this sounds like a problem where Erlang might be a better choice.

On Wed, Sep 28, 2011 at 4:04 PM, Andreas Voellmy
andreas.voel...@gmail.com wrote:
 On Sat, Sep 17, 2011 at 1:38 AM, Jesse Schalken jesseschal...@gmail.com
 wrote:

 There might be a way to do it, I don't know, but this sounds like an XY
 problem. Can I ask what you're trying to achieve by doing this, or is it
 just out of curiosity regarding how much garbage is created? (It's a lot, by
 the way. Since the only thing a purely functional program can do is create
 data and read data (as opposed to create, read and update in an impure
 program) I imagine a purely functional program without GC would hit OOM
 very, very quickly.)

 Sure. I'm writing a server that serves a number of long-lived TCP
 connections. The clients can be served mostly independently; there is a bit
 of shared state among the different connections. I'd like to use the
 concurrency available to scale the server to handle a large number of
 clients. Ideally I would just use more cores to handle a larger number of
 clients. It seems that GC is the biggest obstacle to doing this. The problem
 seems to be that the current GC stops all the processors before performing a
 GC. With a large number of processors this becomes expensive, and I find
 that a program that has really high mutator productivity with one processor
 can get terrible productivity at 12 or more processors. Of course, it helps
 to reduce the allocation rate of the program, but even after being very
 careful about how much memory is allocated, GC still takes up a significant
 amount of time. So I was looking for a way to turn off GC altogether just as
 an experiment to see how the program would perform without all the GC
 pauses.
 --Andreas



 On Thu, Sep 15, 2011 at 2:42 AM, Andreas Voellmy
 andreas.voel...@gmail.com wrote:
  Hi everyone,
  Is there a way to completely turn garbage collection off in the Haskell
  runtime system? I'm aware of the -A runtime option, but I'd like to
  completely turn it off, if possible. I'm OK with running the program
  until
  it runs out of memory, and I'm willing to recompile GHC if needed.
  Regards,
  Andreas
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [Haskell-beginners] No instance for (Show a)

2011-07-31 Thread Ovidiu Deac
It worked.

Initially I didn't understand what you mean but after some googleing I
figured it out what I had to do so I did this

instance Show a ⇒ Show (Stack a) where
show s = ...

Now, thinking about this, it totally makes sense because Stack cannot
be an instance of Show if the type a is not instance or Show.

Thanks again!

On Sun, Jul 31, 2011 at 12:26 PM, Mark Spezzano
mark.spezz...@chariot.net.au wrote:
 Hi,

 You might need a class constraint.

 instance (Show a) = Show (Stack a) where

 This basically lets Haskell know that if your a type is Showable then 
 Stack a is also Showable.

 Let me know if this works.

 Cheers,

 Mark Spezzano


 On 31/07/2011, at 6:49 PM, Ovidiu Deac wrote:

 For some reason ghc complains about not being able to call show on an
 Integer (?!?!?)

 Please enlighten me!

 ovidiu

 This is the hspec:
    it shows one element
        ( show (push 1 EmptyStack) ≡ Stack(1))

 ...this is the code:

 data Stack a =
    EmptyStack |
    StackEntry a (Stack a)
    deriving(Eq)


 instance Show (Stack a) where
    show s =
        Stack( ⊕ (showImpl s) ⊕ )
        where
            showImpl EmptyStack = 
            showImpl (StackEntry x _) = show x

 ...and this is the error:

 src/Stack.hs:12:22:
    No instance for (Show a)
      arising from a use of `showImpl'
    In the first argument of `(++)', namely `(showImpl s)'
    In the second argument of `(++)', namely `(showImpl s) ++ )'
    In the expression: Stack( ++ (showImpl s) ++ )

 ___
 Beginners mailing list
 beginn...@haskell.org
 http://www.haskell.org/mailman/listinfo/beginners



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe