[Haskell-cafe] SCC accounting
We've been trying to track down a memory leak, and by adding SCC annotations, pinned it down to a very brief expression. Unfortunately, the expression is just a variable! We even looked at the generated core: (case ([Soutei.Term Logic.BodyVar] - (...) - Logic.Frame - Logic.QState - FBackTrackT.Stream m_aYsk Logic.QState) lookup_aYPK pred_aXVH ctxIdx_aYpI of wild_B1 { Data.Maybe.Nothing - GHC.Err.patError ... Data.Maybe.Just x_aXVL - __scc {pqzifoozq Assertions} x_aXVL }); Note the __scc annotation just before x_aXVL at the end of the expression. Yet in the time and allocation profile, this SCC is charged for a lot of time and allocations in the individual column; individual inherited COST CENTREno.entries %time %alloc %time %alloc pq.foo'466 50001 8.0 12.1 8.0 13.2 and in the heap profile, it is a major memory leak. The Haskell code looks like predQuery pred = case lookup pred ctxIdx of Just f - {-# SCC pq.foo' #-} f Note that f is a function, which we expect to be expensive when it is called. However, that should be charged to the definition of the function, right? We tried pretty hard to reproduce this in a small test case, but never succeeded. Always, the cost was accounted to the definition of the function in the intuitive way. We're using ghc 6.4.1 and compiling without optimization. Can any ghc hacker suggest how this could happen, or give us any hints on what to try next? Andrew [1] http://haskell.org/ghc/docs/latest/html/users_guide/profiling.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] SCC accounting
On Wed, Feb 01, 2006 at 12:28:59AM -0800, Andrew Pimlott wrote: The Haskell code looks like predQuery pred = case lookup pred ctxIdx of Just f - {-# SCC pq.foo' #-} f Note that f is a function, which we expect to be expensive when it is called. However, that should be charged to the definition of the function, right? We found a work-around: We replaced f to the right of the annotation with \z z2 z3 - f z z2 z3 and suddenly the right SCCs showed up in the profile (which enabled us to find the real leak, which was fixed by one strictness annotation). Actually, f takes 4 arguments, and forcing only 2 of them was not sufficient; in fact, forcing only 2 caused a different misleading SCC to dominate the profile! I don't claim to understand why. Andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Number 1, at least for now
On 2/1/06, Donald Bruce Stewart [EMAIL PROTECTED] wrote: Haskell is now ranked number 1 on the Great Language Shootout! http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=all Hooray :) That is neat. Mostly for dispelling the pure lazy fp is inherently slow argument. It's not likely to last though, as soon as someone implements the three missing C programs we'll be bumped down again. But it's still pretty cool! /S -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Known Unknowns
Donald Bruce Stewart wrote: This entry in fact runs faster than the original (though not the new vectorised entry) optimised C entry (and faster than all other languages): http://shootout.alioth.debian.org/gp4/benchmark.php?test=partialsumslang=all So, by carefully tweaking things, we first squished a space leak, and then gained another 30%. In summary: * Check the Core that is generated * Watch out for optimisations that are missed * Read the generated C for the tight loops. * Make sure tight loops are unboxed * Use -fexcess-precision and -optc-ffast-math for doubles This is roughly the process I used for the other shootout entries. Cheers, Don I just looked hard at the new vectorised entry and the original entry for C. In both, the last two functions, which use the alt-ernating sign, are *not* done in the required naive fashion: sum = 0.0; for (k = 1; k = n-1; k += 2) sum += 1.0/kd; for (k = 2; k = n; k += 2) sum -= 1.0/kd; printf(%.9f\tAlternating Harmonic\n, sum); sum = 0.0; for (k = 1; k = 2*n-1; k += 4) sum += 1.0/kd; for (k = 3; k = 2*n; k += 4) sum -= 1.0/kd; printf(%.9f\tGregory\n, sum); As you can see, all the positive terms are added to sum, then all the negative terms. The double precision math comes to a different result, but this is hidden by printing only 9 digits. I just modified the g++ entry and the Haskell entry which do it right and the c entry to print more digits (e.g. show sum in Haskell). The Haskell entry and g++ entry agree, as expected. The c entry does *not* agree: AltHarm 0.6931469805600938 Haskell 0.6931469805600938283163259256980381906032562255859375... g++ 0.69314698056038037687898167860112152993679046630859375000... gcc Gregory 0.7853980633974356 Haskell 0.785398063397435564070292457472532987594604492187500... g++ 0.7853980633973864922126040255534462630748748779296875000... gcc The gcc entry is computing a different answer since it uses the wrong order for making the partial sum. -- Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: unary pattern matching
John Meacham wrote: On Fri, Jan 27, 2006 at 04:57:14AM -0500, Cale Gibbard wrote: Or if we're going to allow @ as an infix operator, we could use (@ pat), reminiscent of section notation. (exp @) of course would make no sense, seeing as there's no representation for patterns as values. oooh. I like that. what fixity do you think @ should have? perhaps even lower than $... I like it too, but I discovered you can get pretty close with a type class: class Match a b where (@@) :: a - b - Bool instance Match a b = Match (Maybe a) (Maybe b) where Just a @@ Just b = a @@ b Nothing @@ Nothing = True _ @@ _ = False instance Match a () where x @@ () = True The trick is that () behaves like a wildcard. eg: *Main Just undefined @@ Just () True *Main Just Nothing @@ Just () True *Main Just Nothing @@ Just (Just ()) False *Main Just Nothing @@ Just Nothing interactive:1:13: Ambiguous type variables `a', `a1' in the constraint: `Match a a1' arising from use of `@@' at interactive:1:13-14 Probable fix: add a type signature that fixes these type variable(s) *Main Just (Just undefined) @@ Just () True *Main Just (Just undefined) @@ Just (Just ()) True Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: SCC accounting
Andrew Pimlott wrote: On Wed, Feb 01, 2006 at 12:28:59AM -0800, Andrew Pimlott wrote: The Haskell code looks like predQuery pred = case lookup pred ctxIdx of Just f - {-# SCC pq.foo' #-} f Note that f is a function, which we expect to be expensive when it is called. However, that should be charged to the definition of the function, right? We found a work-around: We replaced f to the right of the annotation with \z z2 z3 - f z z2 z3 and suddenly the right SCCs showed up in the profile (which enabled us to find the real leak, which was fixed by one strictness annotation). Actually, f takes 4 arguments, and forcing only 2 of them was not sufficient; in fact, forcing only 2 caused a different misleading SCC to dominate the profile! I don't claim to understand why. I don't understand why either, but I do know that cost-centre stacks behave strangely in some corner cases. I have some examples stashed away somewhere, and it's been a long term ToDo item to really pin down the semantics of CCSs. If you could encapsulate your example as a bug report (preferably make it as small as possible), that would be great. Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] EclipseFP (Haskell IDE) 0.9.1 released
Thiago Arrais wrote: EclipseFP 0.9.1 has been released since last Friday. It is an open-source development environment for Haskell code. EclipseFP integrates GHC with an Haskell-aware code editor and also supports quick file browsing through an outline view, automatic building/compiling and quick one-button code execution. Downloads and more information are available on the project home page http://eclipsefp.sourceforge.net/ We are open for comments and general discussion. Actually we would really appreciate comments from both newbie and veteran Haskell programmers. This is open-source development and everyone on the Haskell community is welcome to participate. More of a meta-comment than a comment... [I should say that I haven't yet actually tried this software, though I'd like to do so when I get some time.] One of the features of Haskell that I like is that it doesn't require lots of IDE support to write complex programs... the compact syntax and clean separation of concerns that can be achieved make it iasy enough to program using nothing more than a regular text editor, and no long wait for the development environment to start up. I can imagine programming Haskell on a palm-top device. So is there a compelling feature in this Eclipse plugin that isn't easily achieved using simpler tools? (Please don't take this as a negative response to your efforts -- I can imagine things that would really help Haskell development based on this kind of framework, such as features in quickly inspect intermediate results in complex programs without visible recompilation, and instrumentation of intermediate results for creating regression tests, though I don't know how such might be provided.) #g -- Graham Klyne For email: http://www.ninebynine.org/#Contact ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Known Unknowns
Hello Donald, Wednesday, February 01, 2006, 8:00:04 AM, you wrote: DBS Here's a brief introduction. I intend to write up (on the performance page on DBS the wiki) a list of things we've done to improve the shootout entries. N.B DBS we're now the 3rd *fastest* language, behind C and only a little behind D (a C DBS varient) !! 3rd fastest or 3rd overall, counting program lines and so on? -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] EclipseFP (Haskell IDE) 0.9.1 released
On Wed, 2006-02-01 at 13:21 +, Graham Klyne wrote: Thiago Arrais wrote: EclipseFP 0.9.1 has been released since last Friday. It is an open-source development environment for Haskell code. EclipseFP integrates GHC with an Haskell-aware code editor and also supports quick file browsing through an outline view, automatic building/compiling and quick one-button code execution. Downloads and more information are available on the project home page http://eclipsefp.sourceforge.net/ We are open for comments and general discussion. Actually we would really appreciate comments from both newbie and veteran Haskell programmers. This is open-source development and everyone on the Haskell community is welcome to participate. More of a meta-comment than a comment... [I should say that I haven't yet actually tried this software, though I'd like to do so when I get some time.] One of the features of Haskell that I like is that it doesn't require lots of IDE support to write complex programs... the compact syntax and clean separation of concerns that can be achieved make it iasy enough to program using nothing more than a regular text editor, and no long wait for the development environment to start up. I can imagine programming Haskell on a palm-top device. Indeed, this is probably why there has not been so much demand for an IDE for Haskell as there is for other languages. It's not so hard coding in Haskell that we really need lots of tool support. Our motivation in starting the hIDE project (not the same as this EclipseFP) is not to create new tools but to tie existing tools together to make the way we program now that bit quicker. We're not trying to tie you down with auto-generated code or non-standard build tools. Apart from the basics of an editor with accurate syntax highlighting we can get integrated syntax and type errors. We can automate building with cabal. We can get jump to definition, jump to documentation. Such an IDE would also be ideal to plug in existing refactoring and debugging tools. Then there is the fact that not all Haskell programmers are comfortable with editors like emacs or vim. Fortunately using an IDE is optional. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Known Unknowns
Bulat Ziganshin wrote: Hello Donald, Wednesday, February 01, 2006, 8:00:04 AM, you wrote: DBS Here's a brief introduction. I intend to write up (on the performance page on DBS the wiki) a list of things we've done to improve the shootout entries. N.B DBS we're now the 3rd *fastest* language, behind C and only a little behind D (a C DBS varient) !! 3rd fastest or 3rd overall, counting program lines and so on? That's the unconceivable thing. It is 3rd fastest. Looking at just Full CPU Time: C gcc 35.90 3 D Digital Mars 32.72 3 Haskell GHC 30.25 0 SML MLton 28.72 3 OCaml 27.92 1 Eiffel Smart26.17 6 C++ g++ 25.73 3 Nice24.43 4 Ada 95 GNAT 23.45 4 Clean 23.32 7 Java JDK 1.4 -server22.69 5 Java JDK -server22.39 5 Java JDK -client19.19 5 C# Mono 16.99 2 Only C gcc and D Digital Mars are ahead. Looking at Just Memory Use, Haskell is 8th languagescore missing C gcc 39.00 3 D Digital Mars 29.21 3 Forth GForth28.63 2 Ada 95 GNAT 27.12 4 Pascal Free 26.53 7 Eiffel Smart24.53 6 C++ g++ 24.46 3 Haskell GHC 24.28 0 OCaml 21.55 1 Fortran G95 20.21 6 Lua 19.63 2 SML MLton 17.80 3 Looking at Just Lines Of Code, Haskell is 1st by a mile: Haskell GHC 41.84 0 SML MLton 34.47 3 Forth GForth32.50 2 OCaml 30.86 1 Tcl 30.83 3 Python Psyco30.49 0 Python 30.33 1 Lua 29.17 2 Ruby27.69 4 Perl25.50 5 Nice25.09 4 C# Mono 24.59 2 D Digital Mars 22.79 3 C++ g++ 22.60 3 Java JDK -client21.12 5 Java JDK -Xint 21.12 5 Java JDK 1.4 -server21.12 5 Java JDK -server21.12 5 C gcc 20.98 3 Where I had to include lots of languages to get down to C gcc. Lookat at the 1:1:1 even balance of the above three, Haskell is 1st: Haskell GHC 96.37 0 C gcc 95.87 3 D Digital Mars 84.72 3 SML MLton 81.00 3 OCaml 80.33 1 Forth GForth75.17 2 C++ g++ 72.79 3 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Known Unknowns
--- Chris Kuklewicz [EMAIL PROTECTED] wrote: -snip,snip- It is 3rd fastest. Looking at Just Memory Use, Haskell is 8th Looking at Just Lines Of Code, Haskell is 1st Lookat at the 1:1:1 even balance Haskell is 1st Programmer skill and effort really does matter ;-) Congratulations. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] EclipseFP (Haskell IDE) 0.9.1 released
2006/2/1, Graham Klyne [EMAIL PROTECTED]: [I should say that I haven't yet actually tried this software, though I'd like to do so when I get some time.] I really hope you find the time to do so. We would be glad to be hearing from you again. One of the features of Haskell that I like is that it doesn't require lots of IDE support to write complex programs... the compact syntax and clean separation of concerns that can be achieved make it iasy enough to program using nothing more than a regular text editor, and no long wait for the development environment to start up. I can imagine programming Haskell on a palm-top device. Very interesting idea. One that I have thought of some time ago. I wasn't thinking of Haskell, but Ruby instead. The idea is the same, but that's another thread. Every language experiences kind of a wave. At the time it is created, there aren't many tools. The early adopters work most of the time using a compiler/interpreter and a text editor. Then the wave starts to form. This is the time the second generation of tools start to flock. They are the test frameworks, the build automation tools and others. At some point of the wave, the integrated environments appear. They come, as the name says, to integrate the previous tools in an easy to use and productive environment. Not that the previous tools were hard to use or counter-productive, it is just that by integrating them much time is saved from the details and the programmer can spend more time on the creative and useful things only he can do. So is there a compelling feature in this Eclipse plugin that isn't easily achieved using simpler tools? When we write an Eclipse plugin, we get a lot of things for free. Just to cite one, there is already CVS integration support within every Eclipse installation, which includes a very neat diff viewer. Adding support for other version control systems isn't very hard. There are plugins, for example, for Darcs and Subversion too. Another very nice feature of the Eclipse platform is the refactoring support. Wouldn't you like to refactor your Haskell code as easily as selecting some context-menu item? Not to mention code assistance and 'go to declaration support' (click a module/function/whatever reference and open its corresponding declaration). This has saved me a lot of time when browsing code. Of course, you need to write the code to tell the platform about your language. That's what the EclipseFP team is trying to do. There is one issue, though, that touches a lot of sensitive areas. The Eclipse platform runs inside a Java Virtual Machine. Unfortunately, there isn't currently a way to compile Haskell to the JVM (at least I don't know of any, if someone knows, please let me know). This means the IDE has to be written in Java, not in Haskell. That's the price we are paying now. Writing a tool for a language in a different language. 2006/2/1, Duncan Coutts [EMAIL PROTECTED]: Fortunately using an IDE is optional. And should always be. An IDE should never be the only way to build things in any language. And the existing IDEs should always be backward compatible with the previous tools. They should not, for example, generate unreadable code or use any vendor-specific format. Cheers, Thiago Arrais ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell code for this example of flow control
I would use recrusion and the Prelude function until: until (=1) (/2) 1000 Cheers, Jared. -- http://www.updike.org/~jared/ reverse )-: ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe