Skip to content

Commit

Permalink
Merge #129
Browse files Browse the repository at this point in the history
129: Patch typos in speed-vs-size.md r=jamesmunns a=krepl



Co-authored-by: krepl <36075613+krepl@users.noreply.github.com>
  • Loading branch information
bors[bot] and krepl committed Feb 13, 2019
2 parents 0943409 + 90a88bd commit 700d073
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/unsorted/speed-vs-size.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Optimizations: the speed size tradeoff

Everyone wants their program to be super fast and super small but it's usually
not possible to have maximize both characteristics. This section discusses the
different optimization levels that `rustc` provides and how the affect the
not possible to have both characteristics. This section discusses the
different optimization levels that `rustc` provides and how they affect the
execution time and binary size of a program.

## No optimizations
Expand All @@ -25,15 +25,15 @@ debug = true

No optimizations is great for debugging because stepping through the code feels
like you are executing the program statement by statement, plus you can `print`
stack variables and function arguments in GDB. When the code is optimized trying
stack variables and function arguments in GDB. When the code is optimized, trying
to print variables results in `$0 = <value optimized out>` being printed.

The biggest downside of the `dev` profile is that the resulting binary will be
huge and slow. The size is usually more of a problem because unoptimized
binaries can occupy dozens of KiB of Flash, which your target device may not
have -- the result: your unoptimized binary doesn't fit in your device!

Can we have smaller debugger friendly binaries? Yes, there's a trick.
Can we have smaller, debugger friendly binaries? Yes, there's a trick.

### Optimizing dependencies

Expand Down Expand Up @@ -117,7 +117,7 @@ profile which defaults to `opt-level = 3`.

Both `opt-level = 2` and `3` optimize for speed at the expense of binary size,
but level `3` does more vectorization and inlining than level `2`. In
particular, you'll see that at `opt-level` equal or greater than `2` LLVM will
particular, you'll see that at `opt-level` equal to or greater than `2` LLVM will
unroll loops. Loop unrolling has a rather high cost in terms of Flash / ROM
(e.g. from 26 bytes to 194 for a zero this array loop) but can also halve the
execution time given the right conditions (e.g. number of iterations is big
Expand Down

0 comments on commit 700d073

Please sign in to comment.