space efficiency question

Simon Peyton-Jones simonpj@microsoft.com
Tue, 18 Dec 2001 04:05:14 -0800


This is a multi-part message in MIME format.

--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C187BC.400FB006"

------_=_NextPart_001_01C187BC.400FB006
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

[redirected to haskell-cafe]
=20
No, GHC doesn't test pointer equality first.  It's unsound to
do so, since it might turn bottom into non-bottom, or remove
`seq` calls that kill space leaks.
=20
S

-----Original Message-----
From: Frank Dellaert [mailto:frank@cc.gatech.edu]=20
Sent: 18 December 2001 11:48
To: Simon Peyton-Jones; Haskell@haskell.org
Subject: Re: space efficiency question


Thanks !
=20
Now, a small follow-up question: if I subsequently test 2 Instances
whether they were instantiated with the same Attributes value, as in
=20
test (Instance a1 _) (Instance a2 _) =3D (a1=3D=3Da2)
=20
will this be implemented efficiently ? I.e. will it check first whether
the pointers happen to be the same, and only then do a full Eq
comparison ?
=20
Cheers
Frank

----- Original Message -----=20
From: Simon  <mailto:simonpj@microsoft.com> Peyton-Jones=20
To: Frank Dellaert <mailto:frank@cc.gatech.edu>  ; Haskell@haskell.org=20
Sent: Monday, December 17, 2001 10:24 AM
Subject: RE: space efficiency question

Now: if I have a couple of thousand of these Instances, created with the
same Attributes value, as in:

=20
a =3D Attributes ["a","bc"]
i0000 =3D Instance a [1,2]
i0001 =3D Instance a [1,1]
...
i7896 =3D Instance a [2,1]
=20
can I be assured that there are not thousands of actual copies of a but
that they simply have a pointer to a ? I'm interested in the answer for
both ghc (compiled/interpreted) as interpreted Hugs.=20

Yes for GHC: you'll only get one copy of 'a'.
=20
Simon
=20


------_=_NextPart_001_01C187BC.400FB006
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<TITLE>Message</TITLE>

<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><SPAN class=3D031445511-18122001><FONT face=3DArial color=3D#0000ff =

size=3D2>[redirected to haskell-cafe]</FONT></SPAN></DIV>
<DIV><SPAN class=3D031445511-18122001><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D031445511-18122001><FONT face=3DArial color=3D#0000ff =
size=3D2>No,=20
GHC doesn't test pointer equality first.&nbsp; It's unsound=20
to</FONT></SPAN></DIV>
<DIV><SPAN class=3D031445511-18122001><FONT face=3DArial color=3D#0000ff =
size=3D2>do so,=20
since it might turn bottom into non-bottom, or =
remove</FONT></SPAN></DIV>
<DIV><SPAN class=3D031445511-18122001><FONT face=3DArial color=3D#0000ff =
size=3D2>`seq`=20
calls that kill space leaks.</FONT></SPAN></DIV>
<DIV><SPAN class=3D031445511-18122001><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D031445511-18122001><FONT face=3DArial color=3D#0000ff =

size=3D2>S</FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px =
solid; MARGIN-RIGHT: 0px">
  <DIV></DIV>
  <DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr =
align=3Dleft><FONT=20
  face=3DTahoma size=3D2>-----Original Message-----<BR><B>From:</B> =
Frank Dellaert=20
  [mailto:frank@cc.gatech.edu] <BR><B>Sent:</B> 18 December 2001=20
  11:48<BR><B>To:</B> Simon Peyton-Jones; =
Haskell@haskell.org<BR><B>Subject:</B>=20
  Re: space efficiency question<BR><BR></FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Thanks !</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Now, a small follow-up question: if I =

  subsequently test 2 Instances whether they were instantiated with the =
same=20
  Attributes value, as in</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>test (Instance a1 _) (Instance a2 _) =
=3D=20
  (a1=3D=3Da2)</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>will this be implemented efficiently =
? I.e. will=20
  it check first whether the pointers happen to be the same, and only =
then do a=20
  full Eq comparison ?</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Cheers</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Frank</FONT></DIV>
  <BLOCKQUOTE dir=3Dltr=20
  style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
    <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
    <DIV=20
    style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
    <A title=3Dsimonpj@microsoft.com =
href=3D"mailto:simonpj@microsoft.com">Simon=20
    Peyton-Jones</A> </DIV>
    <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3Dfrank@cc.gatech.edu=20
    href=3D"mailto:frank@cc.gatech.edu">Frank Dellaert</A> ; <A=20
    title=3DHaskell@haskell.org=20
    href=3D"mailto:Haskell@haskell.org">Haskell@haskell.org</A> </DIV>
    <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Monday, December 17, =
2001 10:24=20
    AM</DIV>
    <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> RE: space efficiency =

    question</DIV>
    <DIV><BR></DIV>
    <DIV><FONT face=3DArial size=3D2>Now: if I have a couple of thousand =
of these=20
    Instances, created with the same Attributes value, as =
in:</FONT></DIV>
    <BLOCKQUOTE dir=3Dltr=20
    style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff =
2px solid; MARGIN-RIGHT: 0px">
      <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
      <DIV><FONT face=3DArial size=3D2>a =3D Attributes =
["a","bc"]</FONT></DIV>
      <DIV><FONT face=3DArial size=3D2>i0000 =3D Instance a =
[1,2]</FONT></DIV>
      <DIV><FONT face=3DArial size=3D2>i0001 =3D Instance a =
[1,1]</FONT></DIV>
      <DIV><FONT face=3DArial size=3D2>...</FONT></DIV>
      <DIV><FONT face=3DArial size=3D2>i7896 =3D Instance a =
[2,1]</FONT></DIV>
      <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
      <DIV><FONT face=3DArial><FONT size=3D2>can I be assured that there =
are not=20
      thousands of actual copies of a but that they simply have a =
pointer to a ?=20
      I'm interested in the answer for both ghc (compiled/interpreted) =
as=20
      interpreted Hugs.<SPAN class=3D268132109-17122001><FONT=20
      =
color=3D#0000ff>&nbsp;</FONT></SPAN></FONT></FONT></DIV></BLOCKQUOTE>
    <DIV dir=3Dltr><FONT face=3DArial><FONT size=3D2><SPAN=20
    class=3D268132109-17122001><FONT color=3D#0000ff>Yes for GHC: you'll =
only get=20
    one copy of 'a'.</FONT></SPAN></FONT></FONT></DIV>
    <DIV dir=3Dltr><FONT face=3DArial><FONT size=3D2><SPAN=20
    class=3D268132109-17122001></SPAN></FONT></FONT>&nbsp;</DIV>
    <DIV dir=3Dltr><FONT face=3DArial><FONT size=3D2><SPAN=20
    class=3D268132109-17122001><FONT=20
    color=3D#0000ff>Simon</FONT></SPAN></FONT></FONT></DIV>
    <DIV dir=3Dltr><FONT face=3DArial><FONT size=3D2><SPAN=20
    =
class=3D268132109-17122001></SPAN></FONT></FONT>&nbsp;</DIV></BLOCKQUOTE>=
</BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C187BC.400FB006--

--------------InterScan_NT_MIME_Boundary--