From: simonpj Date: Tue, 18 Jun 2002 12:43:42 +0000 (+0000) Subject: [project @ 2002-06-18 12:43:42 by simonpj] X-Git-Tag: Approx_11550_changesets_converted~1954 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=8c4c38a1cb99c28d8a41bfa99b5165b06e0a7ad9;p=ghc-hetmet.git [project @ 2002-06-18 12:43:42 by simonpj] Notes about par/seq --- diff --git a/ghc/docs/comm/rts-libs/prelude.html b/ghc/docs/comm/rts-libs/prelude.html index 72147ab..4ad6c20 100644 --- a/ghc/docs/comm/rts-libs/prelude.html +++ b/ghc/docs/comm/rts-libs/prelude.html @@ -12,6 +12,30 @@ values, RULES pragmas, and so on) to make the heavily used Prelude code as fast as possible. +
+

Par, seq, and lazy

+ + In GHC.Conc you will dinf +
+  pseq a b = a `seq` lazy b
+
+ What's this "lazy" thing. Well, pseq is a seq for a parallel setting. + We really mean "evaluate a, then b". But if the strictness analyser sees that pseq is strict + in b, then b might be evaluated before a, which is all wrong. +

+Solution: wrap the 'b' in a call to GHC.Base.lazy. This function is just the identity function, +except that it's put into the built-in environment in MkId.lhs. That is, the MkId.lhs defn over-rides the +inlining and strictness information that comes in from GHC.Base.hi. And that makes lazy look +lazy, and have no inlining. So the strictness analyser gets no traction. +

+In the worker/wrapper phase, after strictness analysis, lazy is "manually" inlined (see WorkWrap.lhs), +so we get all the efficiency back. +

+This supersedes an earlier scheme involving an even grosser hack in which par# and seq# returned an +Int#. Now there is no seq# operator at all. + + +


fold/build

There is a lot of magic in