Commit 8c4c38a1 authored by simonpj's avatar simonpj
Browse files

[project @ 2002-06-18 12:43:42 by simonpj]

Notes about par/seq
parent 5451c866
......@@ -12,6 +12,30 @@
values, RULES pragmas, and so on) to make the heavily used Prelude code
as fast as possible.
<h4>Par, seq, and lazy</h4>
In GHC.Conc you will dinf
pseq a b = a `seq` lazy b
What's this "lazy" thing. Well, <tt>pseq</tt> is a <tt>seq</tt> 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 <em>before</em> a, which is all wrong.
Solution: wrap the 'b' in a call to <tt>GHC.Base.lazy</tt>. 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 <tt>lazy</tt> look
lazy, and have no inlining. So the strictness analyser gets no traction.
In the worker/wrapper phase, after strictness analysis, <tt>lazy</tt> 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.
There is a lot of magic in <a
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment