~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to system/doc/efficiency_guide/advanced.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2010-03-09 17:34:57 UTC
  • mfrom: (10.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100309173457-4yd6hlcb2osfhx31
Tags: 1:13.b.4-dfsg-3
Manpages in section 1 are needed even if only arch-dependent packages are
built. So, re-enabled them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE chapter SYSTEM "chapter.dtd">
 
3
 
 
4
<chapter>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>2001</year><year>2009</year>
 
8
      <holder>Ericsson AB. All Rights Reserved.</holder>
 
9
    </copyright>
 
10
    <legalnotice>
 
11
      The contents of this file are subject to the Erlang Public License,
 
12
      Version 1.1, (the "License"); you may not use this file except in
 
13
      compliance with the License. You should have received a copy of the
 
14
      Erlang Public License along with this software. If not, it can be
 
15
      retrieved online at http://www.erlang.org/.
 
16
    
 
17
      Software distributed under the License is distributed on an "AS IS"
 
18
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
19
      the License for the specific language governing rights and limitations
 
20
      under the License.
 
21
    
 
22
    </legalnotice>
 
23
 
 
24
    <title>Advanced</title>
 
25
    <prepared>Kenneth Lundin</prepared>
 
26
    <docno></docno>
 
27
    <date>2001-08-21</date>
 
28
    <rev></rev>
 
29
    <file>advanced.xml</file>
 
30
  </header>
 
31
 
 
32
  <section>
 
33
    <title>Memory</title>
 
34
    <p>A good start when programming efficiently is to have knowledge about
 
35
      how much memory different data types and operations require. It is
 
36
      implementation-dependent how much memory the Erlang data types and
 
37
      other items consume, but here are some figures for
 
38
      erts-5.2 system (OTP release R9B). (There have been no significant
 
39
      changes in R13.)</p>
 
40
 
 
41
      <p>The unit of measurement is memory words. There exists both a 32-bit
 
42
      and a 64-bit implementation, and a word is therefore, 4 bytes or
 
43
      8 bytes, respectively.</p>
 
44
    <table>
 
45
      <row>
 
46
        <cell align="center" valign="middle">Data type</cell>
 
47
        <cell align="center" valign="middle">Memory size</cell>
 
48
      </row>
 
49
      <row>
 
50
        <cell align="left" valign="middle">Integer (-16#7FFFFFF &lt; i &lt;16#7FFFFFF)</cell>
 
51
        <cell align="left" valign="middle">1 word</cell>
 
52
      </row>
 
53
      <row>
 
54
        <cell align="left" valign="middle">Integer (big numbers)</cell>
 
55
        <cell align="left" valign="middle">3..N words</cell>
 
56
      </row>
 
57
      <row>
 
58
        <cell align="left" valign="middle">Atom</cell>
 
59
        <cell align="left" valign="middle">1 word. Note: an atom refers into
 
60
        an atom table which also consumes memory.
 
61
        The atom text is stored once for each unique atom in this table.
 
62
        The atom table is <em>not</em> garbage-collected.</cell>
 
63
      </row>
 
64
      <row>
 
65
        <cell align="left" valign="middle">Float</cell>
 
66
        <cell align="left" valign="middle">On 32-bit architectures: 4 words        <br></br>
 
67
On 64-bit architectures: 3 words</cell>
 
68
      </row>
 
69
      <row>
 
70
        <cell align="left" valign="middle">Binary</cell>
 
71
        <cell align="left" valign="middle">3..6 + data (can be shared)</cell>
 
72
      </row>
 
73
      <row>
 
74
        <cell align="left" valign="middle">List</cell>
 
75
        <cell align="left" valign="middle">1 word per element + the size of each element</cell>
 
76
      </row>
 
77
      <row>
 
78
        <cell align="left" valign="middle">String (is the same as a list of integers)</cell>
 
79
        <cell align="left" valign="middle">2 words per character</cell>
 
80
      </row>
 
81
      <row>
 
82
        <cell align="left" valign="middle">Tuple</cell>
 
83
        <cell align="left" valign="middle">2 words + the size of each element</cell>
 
84
      </row>
 
85
      <row>
 
86
        <cell align="left" valign="middle">Pid</cell>
 
87
        <cell align="left" valign="middle">1 word for a process identifier from the current local node, and 5 words for a process identifier from another node. Note: a process identifier refers into a process table and a node table which also consumes memory.</cell>
 
88
      </row>
 
89
      <row>
 
90
        <cell align="left" valign="middle">Port</cell>
 
91
        <cell align="left" valign="middle">1 word for a port identifier from the current local node, and 5 words for a port identifier from another node. Note: a port identifier refers into a port table and a node table which also consumes memory.</cell>
 
92
      </row>
 
93
      <row>
 
94
        <cell align="left" valign="middle">Reference</cell>
 
95
        <cell align="left" valign="middle">On 32-bit architectures: 5 words for a reference from the current local node, and 7 words for a reference from another node.        <br></br>
 
96
On 64-bit architectures: 4 words for a reference from the current local node, and 6 words for a reference from another node. Note: a reference refers into a node table which also consumes memory.</cell>
 
97
      </row>
 
98
      <row>
 
99
        <cell align="left" valign="middle">Fun</cell>
 
100
        <cell align="left" valign="middle">9..13 words + size of environment. Note: a fun refers into a fun table which also consumes memory.</cell>
 
101
      </row>
 
102
      <row>
 
103
        <cell align="left" valign="middle">Ets table</cell>
 
104
        <cell align="left" valign="middle">Initially 768 words + the size of each element (6 words + size of Erlang data). The table will grow when necessary.</cell>
 
105
      </row>
 
106
      <row>
 
107
        <cell align="left" valign="middle">Erlang process</cell>
 
108
        <cell align="left" valign="middle">327 words when spawned including a heap of 233 words.</cell>
 
109
      </row>
 
110
      <tcaption>Memory size of different data types</tcaption>
 
111
    </table>
 
112
  </section>
 
113
 
 
114
  <section>
 
115
    <title>System limits</title>
 
116
    <p>The Erlang language specification puts no limits on number of processes,
 
117
     length of atoms etc., but for performance and memory saving reasons,
 
118
      there will always be limits in a practical implementation of the Erlang
 
119
      language and execution environment.</p>
 
120
    <taglist>
 
121
      <tag><em>Processes</em></tag>
 
122
      <item>
 
123
        <p>The maximum number of simultaneously alive Erlang processes is
 
124
          by default 32768. This limit can be raised up to at most 268435456
 
125
          processes at startup (see documentation of the system flag
 
126
          <seealso marker="erts:erl#max_processes">+P</seealso> in the
 
127
          <seealso marker="erts:erl">erl(1)</seealso> documentation).
 
128
          The maximum limit of 268435456 processes will at least on a 32-bit
 
129
          architecture be impossible to reach due to memory shortage.</p>
 
130
      </item>
 
131
      <tag><em>Distributed nodes</em></tag>
 
132
      <item>
 
133
        <taglist>
 
134
          <tag>Known nodes</tag>
 
135
          <item>
 
136
            <p>A remote node Y has to be known to node X if there exist
 
137
              any pids, ports, references, or funs (Erlang data types) from Y
 
138
              on X, or if X and Y are connected. The maximum number of remote
 
139
              nodes simultaneously/ever known to a node is limited by the
 
140
              <seealso marker="#atoms">maximum number of atoms</seealso>
 
141
              available for node names. All data concerning remote nodes,
 
142
              except for the node name atom, are garbage-collected.</p>
 
143
          </item>
 
144
          <tag>Connected nodes</tag>
 
145
          <item>The maximum number of simultaneously connected nodes is limited by
 
146
           either the maximum number of simultaneously known remote nodes,
 
147
          <seealso marker="#ports">the maximum number of (Erlang) ports</seealso>
 
148
           available, or
 
149
          <seealso marker="#files_sockets">the maximum number of sockets</seealso>
 
150
           available.</item>
 
151
        </taglist>
 
152
      </item>
 
153
      <tag><em>Characters in an atom</em></tag>
 
154
      <item>255</item>
 
155
      <tag><em>Atoms </em></tag>
 
156
      <item>      <marker id="atoms"></marker>
 
157
The maximum number of atoms is 1048576. </item>
 
158
      <tag><em>Ets-tables</em></tag>
 
159
      <item>The default is 1400, can be changed with the environment variable <c>ERL_MAX_ETS_TABLES</c>.</item>
 
160
      <tag><em>Elements in a tuple</em></tag>
 
161
      <item>The maximum number of elements in a tuple is 67108863 (26 bit unsigned integer). Other factors
 
162
       such as the available memory can of course make it hard to create a tuple of that size. </item>
 
163
      <tag><em>Size of binary</em></tag>
 
164
      <item>In the 32-bit implementation of Erlang, 536870911 bytes is the
 
165
       largest binary that can be constructed or matched using the bit syntax.
 
166
       (In the 64-bit implementation, the maximum size is 2305843009213693951 bytes.)
 
167
       If the limit is exceeded, bit syntax construction will fail with a
 
168
      <c>system_limit</c> exception, while any attempt to match a binary that is
 
169
       too large will fail.
 
170
       This limit is enforced starting with the R11B-4 release; in earlier releases,
 
171
       operations on too large binaries would in general either fail or give incorrect
 
172
       results.
 
173
       In future releases of Erlang/OTP, other operations that create binaries (such as
 
174
      <c>list_to_binary/1</c>) will probably also enforce the same limit.</item>
 
175
      <tag><em>Total amount of data allocated by an Erlang node</em></tag>
 
176
      <item>The Erlang runtime system can use the complete 32 (or 64) bit address space,
 
177
       but the operating system often limits a single process to use less than that.</item>
 
178
      <tag><em>length of a node name</em></tag>
 
179
      <item>An Erlang node name has the form host@shortname or host@longname. The node name is 
 
180
       used as an atom within the system so the maximum size of 255 holds for the node name too.</item>
 
181
      <tag><em>Open ports</em></tag>
 
182
      <item>
 
183
        <marker id="ports"></marker>
 
184
        <p>The maximum number of simultaneously open Erlang ports is
 
185
          by default 1024. This limit can be raised up to at most 268435456
 
186
          at startup (see environment variable
 
187
          <seealso marker="erts:erlang#ERL_MAX_PORTS">ERL_MAX_PORTS</seealso>
 
188
          in <seealso marker="erts:erlang">erlang(3)</seealso>)
 
189
          The maximum limit of 268435456 open ports will at least on a 32-bit
 
190
          architecture be impossible to reach due to memory shortage.</p>
 
191
      </item>
 
192
      <tag><em>Open files, and sockets</em></tag>
 
193
      <item>      <marker id="files_sockets"></marker>
 
194
 
 
195
       The maximum number of simultaneously open files and sockets
 
196
       depend on
 
197
      <seealso marker="#ports">the maximum number of Erlang ports</seealso>
 
198
       available, and operating system specific settings and limits.</item>
 
199
      <tag><em>Number of arguments to a function or fun</em></tag>
 
200
      <item>256</item>
 
201
    </taglist>
 
202
  </section>
 
203
</chapter>
 
204