Skip to content

Commit fbc1844

Browse files
Savio-Souvezenovm
andauthored
Grammar and readability improvements
Co-authored-by: Maxim Vezenov <mvezenov@gmail.com>
1 parent 62e6e64 commit fbc1844

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/docs/tooling/profiler.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn main(ptr: pub u32, mut array: [u32; 32]) -> pub [u32; 32] {
4242
}
4343
```
4444

45-
Change directory into the project and compile the program using `nargo compile`. We are ready then to try the profiler out.
45+
Change into the project directory and compile the program using `nargo compile`. We are now ready to try out the profiler.
4646

4747
#### Flamegraphing
4848

@@ -52,17 +52,17 @@ Let's take a granular look at our program's ACIR opcode footprint using the prof
5252
noir-profiler opcodes --artifact-path ./target/program.json --output ./target/
5353
```
5454

55-
The command will generate a flamegraph in your _target_ folder that maps the number of ACIR opcodes and their corresponding locations in your program source code.
55+
The command generates a flamegraph in your _target_ folder that maps the number of ACIR opcodes to their corresponding locations in your program's source code.
5656

5757
Opening the flamegraph in a web browser will provide a more interactive experience, allowing you to click into different regions of the graph and examine them.
5858

5959
Flamegraph of the demonstrative project generated with Nargo v1.0.0-beta.2:
6060

6161
![ACIR Flamegraph Unoptimized](@site/static/img/tooling/profiler/acir-flamegraph-unoptimized.png)
6262

63-
The demonstrative project consists of 387 ACIR opcodes in total, which from the flamegraph we can see that the majority of them comes from the write to `array[i]`.
63+
The demonstrative project consists of 387 ACIR opcodes in total. From the flamegraph, we can see that the majority come from the write to `array[i]`.
6464

65-
Knowing the insight on our program's bottleneck, let's optimize it.
65+
With insight into our program's bottleneck, let's optimize it.
6666

6767
#### Optimizing array writes with reads
6868

@@ -93,7 +93,7 @@ unconstrained fn zero_out_array(ptr: u32, mut array: [u32; 32]) -> [u32; 32] {
9393
}
9494
```
9595

96-
Instead of writing our array in a fully constrained manner, we first write our array inside an unconstrained function and then assert every value in the array returned from the unconstrained function in a constrained manner.
96+
Instead of writing our array in a fully constrained context, we first write our array inside an unconstrained function. Then, we assert every value in the array returned from the unconstrained function in a constrained context.
9797

9898
This brings the ACIR opcodes count of our program down to a total of 284 opcodes:
9999

@@ -111,7 +111,7 @@ Check "Matched" in the bottom right corner to learn the percentage out of total
111111

112112
If you try searching for `memory::op` before and after the optimization, you will find that the search will no longer have matches after the optimization.
113113

114-
This comes from the optimization removing the use of a dynamic array (i.e. an array with a dynamic index, that is its values rely on witness inputs). After the optimized rewrite into reading two arrays from known constant indices, simple arithmetic operations replaces the original memory operations.
114+
This comes from the optimization removing the use of a dynamic array (i.e. an array with a dynamic index, that is its values rely on witness inputs). After the optimization, the program reads from two arrays with known constant indices, replacing the original memory operations with simple arithmetic operations.
115115

116116
:::
117117

@@ -162,7 +162,7 @@ For example, we can find a 13.9% match `new_array` in the flamegraph above.
162162
In contrast, if we profile the pre-optimization demonstrative project:
163163
![Brillig Trace Initial Program](@site/static/img/tooling/profiler/brillig-trace-initial-32.png)
164164

165-
You will notice that it does not consist any `new_array`, and executes a total of 1,582 Brillig opcodes (versus 2,125 Brillig opcodes post-optimization).
165+
You will notice that it does not contain `new_array` and executes a total of 1,582 Brillig opcodes (versus 2,125 Brillig opcodes post-optimization).
166166

167167
As new unconstrained functions were added, it is reasonable that the program would consist of more Brillig opcodes. That said, the tradeoff is often easily justifiable by the fact that proving speeds are more commonly the major bottleneck of Noir programs versus execution speeds.
168168

0 commit comments

Comments
 (0)