Skip to content

Commit 0746c03

Browse files
Fix typos in Efficiency Guide
Co-authored-by: Maria Scott <maria-12648430@hnc-agency.org>
1 parent 5c44cb6 commit 0746c03

11 files changed

Lines changed: 55 additions & 55 deletions

system/doc/efficiency_guide/benchmarking.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,22 @@ crypto:strong_rand_bytes(2). 1 2286 Ki 437 ns 29%
4343
```
4444

4545
From the **Time** column we can read out that on average a call to
46-
[`rand:bytes(2)`](`rand:bytes/1`) executes in 128 nano seconds, while
46+
[`rand:bytes(2)`](`rand:bytes/1`) executes in 128 nanoseconds, while
4747
a call to
4848
[`crypto:strong_rand_bytes(2)`](`crypto:strong_rand_bytes/1`) executes
49-
in 437 nano seconds.
49+
in 437 nanoseconds.
5050

5151
From the **QPS** column we can read out how many calls that can be
5252
made in a second. For `rand:bytes(2)`, it is 7,784,000 calls per second.
5353

5454
The **Rel** column shows the relative differences, with `100%` indicating
5555
the fastest code.
5656

57-
When generating two random bytes at the time, `rand:bytes/1` is more
57+
When generating two random bytes at a time, `rand:bytes/1` is more
5858
than three times faster than `crypto:strong_rand_bytes/1`. Assuming
5959
that we really need strong random numbers and we need to get them as
6060
fast as possible, what can we do? One way could be to generate more
61-
than two bytes at the time.
61+
than two bytes at a time.
6262

6363
```text
6464
% erlperf 'rand:bytes(100).' 'crypto:strong_rand_bytes(100).'
@@ -67,7 +67,7 @@ rand:bytes(100). 1 2124 Ki 470 ns 100%
6767
crypto:strong_rand_bytes(100). 1 1915 Ki 522 ns 90%
6868
```
6969

70-
`rand:bytes/1` is still faster when we generate 100 bytes at the time,
70+
`rand:bytes/1` is still faster when we generate 100 bytes at a time,
7171
but the relative difference is smaller.
7272

7373
```
@@ -77,7 +77,7 @@ crypto:strong_rand_bytes(1000). 1 1518 Ki 658 ns 100%
7777
rand:bytes(1000). 1 284 Ki 3521 ns 19%
7878
```
7979

80-
When we generate 1000 bytes at the time, `crypto:strong_rand_bytes/1` is
80+
When we generate 1000 bytes at a time, `crypto:strong_rand_bytes/1` is
8181
now the fastest.
8282

8383
## Benchmarking using Erlang/OTP functionality

system/doc/efficiency_guide/binaryhandling.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ limitations under the License.
2323

2424
This section gives a few examples on how to handle binaries in an efficient way.
2525
The sections that follow take an in-depth look at how binaries are implemented
26-
and how to best take advantages of the optimizations done by the compiler and
26+
and how to best take advantage of the optimizations done by the compiler and
2727
runtime system.
2828

2929
Binaries can be efficiently _built_ in the following way:
@@ -118,12 +118,12 @@ Four types of binary objects are available internally:
118118

119119
> #### Change {: .info }
120120
>
121-
> In Erlang/OTP 27, the handling of binaries and bitstrings were
121+
> In Erlang/OTP 27, the handling of binaries and bitstrings was
122122
> rewritten. To fully leverage those changes in the run-time system,
123123
> the compiler needs to be updated, which is planned for a future
124124
> release.
125125
>
126-
> Since, practically speaking, not much have changed from an efficiency
126+
> Since, practically speaking, not much has changed from an efficiency
127127
> and optimization perspective, the following description has not yet
128128
> been updated to describe the implementation in Erlang/OTP 27.
129129
@@ -196,7 +196,7 @@ This optimization is applied by the runtime system in a way that makes it
196196
effective in most circumstances (for exceptions, see
197197
[Circumstances That Force Copying](binaryhandling.md#forced_copying)). The
198198
optimization in its basic form does not need any help from the compiler.
199-
However, the compiler add hints to the runtime system when it is safe to apply
199+
However, the compiler adds hints to the runtime system when it is safe to apply
200200
the optimization in a more efficient way.
201201

202202
> #### Change {: .info }
@@ -427,7 +427,7 @@ all_but_zeroes_to_list(<<Byte,T/binary>>, Acc, Remaining) ->
427427

428428
The compiler removes building of sub binaries in the second and third clauses,
429429
and it adds an instruction to the first clause that converts `Buffer` from a
430-
match context to a sub binary (or do nothing if `Buffer` is a binary already).
430+
match context to a sub binary (or does nothing if `Buffer` is already a binary).
431431

432432
But in more complicated code, how can one know whether the optimization is
433433
applied or not?

system/doc/efficiency_guide/commoncaveats.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ naive_reverse([]) ->
4949
As the `++` operator copies its left-hand side operand, the growing
5050
result is copied repeatedly, leading to quadratic complexity.
5151

52-
On the other hand, using `++` in loop like this is perfectly fine:
52+
On the other hand, using `++` in a loop like this is perfectly fine:
5353

5454
**OK**
5555

@@ -64,7 +64,7 @@ naive_but_ok_reverse([], Acc) ->
6464
```
6565

6666
Each list element is copied only once. The growing result `Acc` is the right-hand
67-
side operand, which it is _not_ copied.
67+
side operand, which is _not_ copied.
6868

6969
Experienced Erlang programmers would probably write as follows:
7070

@@ -167,14 +167,14 @@ the copied term can be many times larger than the original term. For example:
167167
```erlang
168168
init2() ->
169169
SharedSubTerms = lists:foldl(fun(_, A) -> [A|A] end, [0], lists:seq(1, 15)),
170-
#state{data=Shared}.
170+
#state{data=SharedSubTerms}.
171171
```
172172

173173
In the process that calls `init2/0`, the size of the `data` field in the `state`
174174
record will be 32 heap words. When the record is copied to the newly created
175175
process, sharing will be lost and the size of the copied `data` field will be
176176
131070 heap words. More details about
177-
[loss off sharing](eff_guide_processes.md#loss-of-sharing) are found in a later
177+
[loss of sharing](eff_guide_processes.md#loss-of-sharing) are found in a later
178178
section.
179179

180180
To avoid the problem, outside of the fun extract only the fields of the record

system/doc/efficiency_guide/drivers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ It is assumed that you have a good understanding of drivers.
3030
The runtime system always takes a lock before running any code in a driver.
3131

3232
By default, that lock is at the driver level, that is, if several ports have
33-
been opened to the same driver, only code for one port at the same time can be
34-
running.
33+
been opened to the same driver, only code for one port can be running
34+
at the same time.
3535

3636
A driver can be configured to have one lock for each port instead.
3737

system/doc/efficiency_guide/eff_guide_functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ limitations under the License.
2323

2424
## Pattern Matching
2525

26-
Pattern matching in function head as well as in `case` and `receive` clauses are
26+
Pattern matching in function head as well as in `case` and `receive` clauses is
2727
optimized by the compiler. With a few exceptions, there is nothing to gain by
2828
rearranging clauses.
2929

@@ -55,7 +55,7 @@ follows:
5555
single instruction that does a binary search; thus, quite efficient even if
5656
there are many values) to select which one of the first three clauses to
5757
execute (if any).
58-
- If none of the first three clauses match, the fourth clause match as a
58+
- If none of the first three clauses match, the fourth clause matches as a
5959
variable always matches.
6060
- If the guard test [`is_integer(Int)`](`is_integer/1`) succeeds, the fourth
6161
clause is executed.

system/doc/efficiency_guide/eff_guide_processes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The default initial heap size of 233 words is quite conservative to support
8888
Erlang systems with hundreds of thousands or even millions of processes. The
8989
garbage collector grows and shrinks the heap as needed.
9090

91-
In a system that use comparatively few processes, performance _might_ be
91+
In a system that uses comparatively few processes, performance _might_ be
9292
improved by increasing the minimum heap size using either the `+h` option for
9393
[erl](`e:erts:erl_cmd.md`) or on a process-per-process basis using the
9494
`min_heap_size` option for [spawn_opt/4](`erlang:spawn_opt/4`).
@@ -291,7 +291,7 @@ BEAM code and persistent terms). The amount of virtual address space reserved
291291
for literals can be changed by using the
292292
[`+MIscs option`](`e:erts:erts_alloc.md#MIscs`) when starting the emulator.
293293
294-
Here is an example how the reserved virtual address space for literals can be
294+
Here is an example of how the reserved virtual address space for literals can be
295295
raised to 2 GB (2048 MB):
296296
297297
```text
@@ -381,7 +381,7 @@ multi-CPU computer by running several Erlang scheduler threads
381381
382382
To gain performance from a multi-core computer, your application _must have more
383383
than one runnable Erlang process_ most of the time. Otherwise, the Erlang
384-
emulator can still only run one Erlang process at the time.
384+
emulator can still only run one Erlang process at a time.
385385
386386
Benchmarks that appear to be concurrent are often sequential. For
387387
example, the [EStone

system/doc/efficiency_guide/listhandling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ add_42_tail([], Acc) ->
221221
lists:reverse(Acc).
222222
```
223223

224-
In early version of Erlang the tail-recursive function would typically
224+
In early versions of Erlang the tail-recursive function would typically
225225
be more efficient. In modern versions of Erlang, there is usually not
226226
much difference in performance between a body-recursive list function and
227227
tail-recursive function that reverses the list at the end. Therefore,

system/doc/efficiency_guide/maps.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The advantages of records compared to maps are:
4545

4646
- If the name of a record field is misspelled, there will be a compilation
4747
error. If a map key is misspelled, the compiler will give no warning and
48-
program will fail in some way when it is run.
48+
the program will fail in some way when it is run.
4949
- Records will use slightly less memory than maps, and performance is expected
5050
to be _slightly_ better than maps in most circumstances.
5151

@@ -67,7 +67,7 @@ module.
6767
it.
6868
- Always update the map using the `:=` operator (that is, requiring that an
6969
element with that key already exists). The `:=` operator is slightly more
70-
efficient, and it helps catching mispellings of keys.
70+
efficient, and it helps catch misspellings of keys.
7171
- Whenever possible, match multiple map elements at once.
7272
- Whenever possible, update multiple map elements at once.
7373
- Avoid default values and the `maps:get/3` function. If there are default
@@ -297,12 +297,12 @@ efficient than using the `=>` operator for a small map.
297297

298298
Here follows some notes about most of the functions in the `maps` module. For
299299
each function, the implementation language (C or Erlang) is stated. The reason
300-
we mention the language is that it gives an hint about how efficient the
300+
we mention the language is that it gives a hint about how efficient the
301301
function is:
302302

303303
- If a function is implemented in C, it is pretty much impossible to implement
304304
the same functionality more efficiently in Erlang.
305-
- However, it might be possible to beat the `maps` modules functions implemented
305+
- However, it might be possible to beat the `maps` module's functions implemented
306306
in Erlang, because they are generally implemented in a way that attempts to
307307
make the performance reasonable for all possible inputs.
308308

@@ -433,12 +433,12 @@ that will call `maps:update/3` to update only the values that have changed.
433433

434434
`maps:merge/2` is implemented in C. For [small maps](maps.md#terminology), the
435435
key tuple may be shared with any of the argument maps if that argument map
436-
contains all the keys. Literal key tuples are prefered if possible.
436+
contains all the keys. Literal key tuples are preferred if possible.
437437

438438
> #### Change {: .info }
439439
>
440440
> The sharing of key tuples by `maps:merge/2` was introduced in OTP 26.0. Older
441-
> versions always contructed a new key tuple on the callers heap.
441+
> versions always constructed a new key tuple on the caller's heap.
442442
443443
### maps:merge_with/3
444444

system/doc/efficiency_guide/profiling.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ Even experienced software developers often guess wrong about where the
2727
performance bottlenecks are in their programs. Therefore, profile your program
2828
to see where the performance bottlenecks are and concentrate on optimizing them.
2929

30-
Erlang/OTP contains several tools to help finding bottlenecks:
30+
Erlang/OTP contains several tools to help find bottlenecks:
3131

3232
- `m:tprof` is a tracing profiler that can measure call count, call time, or
3333
heap allocations per function call.
3434
- `m:fprof` provides the most detailed information about where the program time
3535
is spent, but it significantly slows down the program it profiles.
36-
- `m:dbg` is the generic erlang tracing frontend. By using the `timestamp` or
36+
- `m:dbg` is the generic Erlang tracing frontend. By using the `timestamp` or
3737
`cpu_timestamp` options it can be used to time how long function calls in a
3838
live system take.
3939
- `m:lcnt` is used to find contention points in the Erlang Run-Time System's
4040
internal locking mechanisms. It is useful when looking for bottlenecks in
41-
interaction between process, port, ETS tables, and other entities that can be
41+
interaction between processes, ports, ETS tables, and other entities that can be
4242
run in parallel.
4343

4444
The tools are further described in [Tools](profiling.md#profiling_tools).
@@ -85,7 +85,7 @@ detailed breakdown of where memory is used.
8585
Processes, ports, and ETS tables can then be inspected using their respective
8686
information functions, that is,
8787
[`process_info/2`](`m:erlang#process_info_memory`),
88-
[`erlang:port_info/2 `](`m:erlang#port_info_memory`), and `ets:info/1`.
88+
[`erlang:port_info/2`](`m:erlang#port_info_memory`), and `ets:info/1`.
8989

9090
Sometimes the system can enter a state where the reported memory from
9191
`erlang:memory(total)` is very different from the memory reported by
@@ -117,7 +117,7 @@ with more or less overhead.
117117
variety of information about the running system.
118118
- `m:etop` is a command line tool that can connect to remote nodes and display
119119
information similar to what the UNIX tool top shows.
120-
- `m:msacc` allows the user to get a view of what the Erlang Run-Time system is
120+
- `m:msacc` allows the user to get a view of what the Erlang Run-Time System is
121121
spending its time doing. Has a very low overhead, which makes it useful to run
122122
in heavily loaded systems to get some idea of where to start doing more
123123
granular profiling.
@@ -191,19 +191,19 @@ _Table: Tool Summary_
191191

192192
`dbg` is a generic Erlang trace tool. By using the `timestamp` or
193193
`cpu_timestamp` options it can be used as a precision instrument to profile how
194-
long time a function call takes for a specific process. This can be very useful
194+
long a function call takes for a specific process. This can be very useful
195195
when trying to understand where time is spent in a heavily loaded system as it
196196
is possible to limit the scope of what is profiled to be very small. For more
197197
information, see the `m:dbg` manual page in Runtime Tools.
198198

199199
### lcnt
200200

201-
`lcnt` is used to profile interactions in between entities that run in parallel.
202-
For example if you have a process that all other processes in the system needs
201+
`lcnt` is used to profile interactions between entities that run in parallel.
202+
For example if you have a process that all other processes in the system need
203203
to interact with (maybe it has some global configuration), then `lcnt` can be
204204
used to figure out if the interaction with that process is a problem.
205205

206-
In the Erlang Run-time System entities are only run in parallel when there are
206+
In the Erlang Run-Time System entities are only run in parallel when there are
207207
multiple schedulers. Therefore `lcnt` will show more contention points (and thus
208208
be more useful) on systems using many schedulers on many cores.
209209

system/doc/efficiency_guide/system_limits.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ see the [`+P`](`e:erts:erl_cmd.md#max_processes`) command-line flag
3232
in the [`erl(1)`](`e:erts:erl_cmd.md`) manual page in ERTS.
3333

3434
- [](){: #unique_pids } **Unique Local Process Identifiers on a
35-
Runtime System Instance ** - On a 64 bit system at most `2⁶⁰ - 1`
35+
Runtime System Instance** - On a 64 bit system at most `2⁶⁰ - 1`
3636
unique process identifiers can be created, and on a 32 bit system at most `2²⁸ - 1`.
3737

3838
- **Known nodes** - A remote node Y must be known to node X if there exists
@@ -61,7 +61,7 @@ In the 64-bit run-time system, the maximum size is 2,305,843,009,213,693,951 byt
6161
If the limit is exceeded, bit syntax construction fails with a `system_limit`
6262
exception, while any attempt to match a binary that is too large
6363
fails. From Erlang/OTP 27, all other operations that create binaries (such as
64-
[`list_to_binary/1`](`list_to_binary/1`)) also enforces the same limit.
64+
[`list_to_binary/1`](`list_to_binary/1`)) also enforce the same limit.
6565

6666
- **Total amount of data allocated by an Erlang node** - The Erlang runtime system
6767
can use the complete 32-bit (or 64-bit) address space, but the operating system
@@ -91,10 +91,10 @@ variable.
9191

9292
- [](){: #unique_references } **Unique References on a Runtime System Instance** -
9393
Each scheduler thread has its own set of references, and all other threads have
94-
a shared set of references. Each set of references consist of `2⁶⁴ - 1`unique
94+
a shared set of references. Each set of references consists of `2⁶⁴ - 1` unique
9595
references. That is, the total amount of unique references that can be produced
9696
on a runtime system instance is `(NumSchedulers + 1) × (2⁶⁴ - 1)`. If a scheduler
97-
thread create a new reference each nano second, references will at earliest be
97+
thread creates a new reference each nanosecond, references will at earliest be
9898
reused after more than 584 years. That is, for the foreseeable future they are
9999
sufficiently unique.
100100

@@ -109,11 +109,11 @@ sufficiently unique.
109109
the total amount of unique integers without the `monotonic`
110110
modifier is `(NumSchedulers + 1) × (2⁶⁴ - 1)`.
111111

112-
If a unique integer is created each nano second, unique integers will be
112+
If a unique integer is created each nanosecond, unique integers will be
113113
reused at earliest after more than 584 years. That is, for the foreseeable future
114114
they are sufficiently unique.
115115

116-
- ** Timer resolution ** - On most systems, millisecond resolution. For more
116+
- **Timer resolution** - On most systems, millisecond resolution. For more
117117
information, see the [*Timers*](`e:erts:time_correction.md#timers`) section of
118118
the [*Time and Time Correction in Erlang*](`e:erts:time_correction.md`) ERTS
119119
User's guide.

0 commit comments

Comments
 (0)