Skip to content

Commit a7088f7

Browse files
committed
prettier md
1 parent 2e13d52 commit a7088f7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/sha256tree.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Information on the new (sha256tree) operator
22

3-
Adding `sha256tree` as a native operator made sense as it is one of the most common functions, used in nearly every shipped ChiaLisp puzzle.
3+
Adding `sha256tree` as a native operator made sense as it is one of the most common functions, used in nearly every shipped ChiaLisp puzzle.
44
Furthermore it has an innate inefficiency in it's in-language implementation.
55
Every internal hash is allocated as an atom in clvm_rs allocator.
66
In addition to this, a native operator also opens the door to future optimisations via caching.
@@ -9,8 +9,9 @@ In addition to this, a native operator also opens the door to future optimisatio
99

1010
The matter of how to assign Cost to the new operator was the subject of intense thought and debate.
1111
It should be costed in proportion to:
12+
1213
- the time to Cost vs other operators, and especially the `sha256` operator
13-
- the time to Cost ratio of the ChiaLisp implementation
14+
- the time to Cost ratio of the ChiaLisp implementation
1415
- the size of its inputs
1516

1617
The lattermost being a unique problem with regards to shatree as it is the first operator that parses trees, so utmost care must be taken when assigning cost.
@@ -21,7 +22,7 @@ One final consideration while costing is that we required it to tally the cost d
2122

2223
The `BASE_COST` was set to equal the base cost of `sha256`.
2324

24-
The `COST_PER_BYTES32` was designed as the sha256 operation operates on 32byte chunks. We set the Cost to be on parity with the Cost of `sha256` although sha256 costs `per byte` and `per arg`.
25+
The `COST_PER_BYTES32` was designed as the sha256 operation operates on 32byte chunks. We set the Cost to be on parity with the Cost of `sha256` although sha256 costs `per byte` and `per arg`.
2526
We can ignore `per arg` as `sha256tree` only takes a single argument, and we benchmarked the `cost-per-bytes32` so that it matches `sha256`'s `cost-per-byte`.
2627

2728
The calculations for this can be seen in the file `benchmark-clvm-cost.rs`.
@@ -34,24 +35,25 @@ The calculations for this can be seen in the file `sha256tree-benching.rs`.
3435
## Costing Results
3536

3637
`MacOS M1`
38+
3739
```
38-
Costs based on an increasing atom per bytes32 chunks:
40+
Costs based on an increasing atom per bytes32 chunks:
3941
Native time per bytes32 (ns): 95.1425
4042
CLVM time per bytes32 (ns): 94.9895
4143
Native implementation takes 100.1611% of the time.
4244
Native cost per bytes32 : 64.0000
4345
CLVM cost per bytes32 : 64.0000
4446
100.1611% of the CLVM cost is: : 64.1031
4547
46-
Costs based on growing a balanced binary tree:
48+
Costs based on growing a balanced binary tree:
4749
Native time per node (ns): 203.8718
4850
CLVM time per node (ns): 517.8038
4951
Native implementation takes 39.3724% of the time.
5052
Native cost per node : 564.0000
5153
CLVM cost per node : 1463.0000
5254
39.3724% of the CLVM cost is: : 576.0185
5355
54-
Costs based on growing a list:
56+
Costs based on growing a list:
5557
Native time per node (ns): 115.0891
5658
CLVM time per node (ns): 397.1927
5759
Native implementation takes 28.9756% of the time.
@@ -61,6 +63,7 @@ CLVM cost per node : 1399.0000
6163
```
6264

6365
`Windows`
66+
6467
```
6568
Costs based on an increasing atom per bytes32 chunks:
6669
Native time per bytes32 (ns): 10.4049
@@ -87,7 +90,6 @@ CLVM cost per node : 1399.0000
8790
10.0416% of the CLVM cost is: : 140.4821
8891
```
8992

90-
9193
## Costing Graphs
9294

9395
Below are the generated benchmarking graphs (PNG) from running `sha256tree-benching.rs` on Macbook M1.
@@ -103,5 +105,3 @@ Below are the generated benchmarking graphs (PNG) from running `sha256tree-bench
103105
![Tree - Time per Node](graphs/tree_bench.png)
104106

105107
![Tree - Cost per Node](graphs/tree_cost.png)
106-
107-

0 commit comments

Comments
 (0)