<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word" xmlns:x =
"urn:schemas-microsoft-com:office:excel"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1528" name=GENERATOR>
<STYLE>@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
P.MsoNormal {
FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
COLOR: blue; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
COLOR: navy; FONT-FAMILY: Arial; mso-style-type: personal-reply
}
DIV.Section1 {
page: Section1
}
OL {
MARGIN-BOTTOM: 0in
}
UL {
MARGIN-BOTTOM: 0in
}
</STYLE>
</HEAD>
<BODY lang=EN-US vLink=blue link=blue>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>1.
When a tuple element is changed, a new copy of the tuple</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>is
created, but keep in mind that it is just the pointers to </FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>the
elements that are copied. You have to make pretty large</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>tuples
(say, over 100 elements) in order for this to be noticable.</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>2. The
State parameter is copied any time the callback module</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>does
something to it, but the gen_server module doesn't ever</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>modify
it.</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>3.
Large binaries are passed by reference. Lists are always
copied.</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>4.
There will be overhead, but it is hard to measure.</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>5.
No</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>6. I
think this is a matter of taste. There is a WxWidgets
library</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>for
erlang, and Mats Cronquist's gtkNode. Joe Armstrong has also</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>done
some nice things with tcl (but hasn't released it yet.) Joe is
</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>also
doing wonderful stuff with JavaScript & Erlang (also not
</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2>released yet.) Other people have used Delphi to design the
</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2>front-end, and then erlang for the backend.</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>7. I
don't know if there's a universal answer to this one, except</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>that
it depends on the particular application and the access
patterns.</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>If you
_would_ want to separate the DB and application, you may </FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>want
to create a high-level database API customized to your </FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2>application, where you can perhaps group dabase operations
</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2>together. Otherwise, the performance penalty of
communicating</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>may
eat up the advantages of having two processors.</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>8. Not
if the key is bound in your pattern. It will to a linear
search</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2>through the set of objects matching the key. If the key is
unbound,</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>it
will be a linear search no matter what table type you're
using.</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff
size=2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=075152514-03032006><FONT face=Arial color=#0000ff size=2>Ulf
W</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> owner-erlang-questions@erlang.org
[mailto:owner-erlang-questions@erlang.org] <B>On Behalf Of </B>Eranga
Udesh<BR><B>Sent:</B> den 3 mars 2006 15:18<BR><B>To:</B>
erlang-questions@erlang.org<BR><B>Subject:</B> Optimizing
Erlang<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=Section1>
<DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Hi,<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">I have a couple of
questions regarding Erlang CPU/memory
Optimization.<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<OL style="MARGIN-TOP: 0in" type=1>
<LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"><FONT
face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Due to the single assignment
restriction in Erlang, when changing values in a record as
below.<o:p></o:p></SPAN></FONT> </LI></OL>
<P class=MsoNormal style="MARGIN-LEFT: 1in"><FONT face=Arial color=navy
size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Eg:
NewRecord = OldRecord#record_type{attribute =
Value}.<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">
does Erlang take a full copy of the record to change only the attribute called
“attribute”? If so, isn’t that a waste of full memory copying to just change
one attribute and if the old copy is never used?<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<OL style="MARGIN-TOP: 0in" type=1 start=2>
<LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"><FONT
face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">In gen_server
handle_call/handle_cast/etc, does the State parameter makes a new copy in
each call/cast/etc? Or changes the same State?<o:p></o:p></SPAN></FONT>
</LI></OL>
<P class=MsoNormal style="MARGIN-LEFT: 0.25in"><FONT face=Arial color=navy
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<OL style="MARGIN-TOP: 0in" type=1 start=3>
<LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"><FONT
face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">When passing large
lists/binary/etc to a function, are they going as references or values (a
full copy of data)?<o:p></o:p></SPAN></FONT> </LI></OL>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<OL style="MARGIN-TOP: 0in" type=1 start=4>
<LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"><FONT
face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Is there any overhead difference
between writing functions in the form of, fun(A, B, C) or fun([A,B,C]) or
fun({A,B,B})?<o:p></o:p></SPAN></FONT> </LI></OL>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<OL style="MARGIN-TOP: 0in" type=1 start=5>
<LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"><FONT
face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Is there any overhead difference
between if and case expressions?<o:p></o:p></SPAN></FONT> </LI></OL>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<OL style="MARGIN-TOP: 0in" type=1 start=6>
<LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"><FONT
face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Is it Ober or jInterface better
to write Java based GUIs for Erlang Backends? Any other better language for
this? GS doesn’t have much support in designing good
interfaces.<o:p></o:p></SPAN></FONT> </LI></OL>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<OL style="MARGIN-TOP: 0in" type=1 start=7>
<LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"><FONT
face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">In a high capacity system, is it
better to run the Mnesia DB in the same Erlang instance (no data transfer
between processes) or have it as a RDBMS in a separate Erlang instance, so
that in a multi-CPU environment can gives a higher
capacity?<o:p></o:p></SPAN></FONT> </LI></OL>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<OL style="MARGIN-TOP: 0in" type=1 start=8>
<LI class=MsoNormal style="COLOR: navy; mso-list: l0 level1 lfo1"><FONT
face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Does Mnesia bag type database
does an exhaustive search when called
mnesia_match_object/3?<o:p></o:p></SPAN></FONT> </LI></OL>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Thanks,<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">-
Eranga<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.25in"><FONT face=Arial color=navy
size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P></DIV></DIV></DIV></BLOCKQUOTE></BODY></HTML>