Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples on how to import storage types to the book #6051

Merged
merged 3 commits into from
May 27, 2024

Conversation

bitzoic
Copy link
Member

@bitzoic bitzoic commented May 23, 2024

Description

A recent issue on the forum demonstrated the lack of examples on how to import storage types to the book. Specifically, they require the glob operator to be used properly. A note on this has been added.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@bitzoic bitzoic added the The Sway Book Everything to do with the Sway Book label May 23, 2024
@bitzoic bitzoic requested review from a team May 23, 2024 08:32
@bitzoic bitzoic self-assigned this May 23, 2024
@bitzoic bitzoic enabled auto-merge (squash) May 24, 2024 14:02
@bitzoic bitzoic merged commit 5389aa8 into master May 27, 2024
41 checks passed
@bitzoic bitzoic deleted the bitzoic-storagevec-glob-operator branch May 27, 2024 04:04
xunilrj added a commit that referenced this pull request May 30, 2024
## Description

This PR introduces a script that compiles a sway project across multiple
commits, and generates an HTML report to help analysis of compilation
time and binary size.

The report is 100% autonomous, only depending on CDN scripts, and can be
served as it is by any HTTP server. There are two main features worthy
of being noted: a pivot table, and the data table.

The pivot table is configured by default to show the average compilation
time across multiple commits, like the example below.


![image](https://github.com/FuelLabs/sway/assets/83425/7abc2242-ad2b-4310-93de-08f01955b93b)

Below it, one finds the data table used, with links to Github issues and
commits.


![image](https://github.com/FuelLabs/sway/assets/83425/47b9671f-468c-481b-bfa8-aa470d49565c)

The script help can be printed by invoking it without any arguments

```
> test/bench.sh

 -n|--qty          how many commits will be used
 -b|--branch       which branch will be used. Defaults to "master"
 -p|--path         path to sway project to use
 -c|--clean        what to clean. Options:
     "results" - will clean all csv, txt files
     "exe"     - will clean all compiled executables
     "all"     - all the above
 -o|--open         open the final report using the default browser
```

A good first invocation example is:

```
> test/bench.sh -n 2 -p test/src/e2e_vm_tests/test_programs/should_pass/language/main_args/main_args_empty/ -o
master d93b "fix: fund default signer account in ci (#6055)" [compiling] [benchmark] [bin size] ok
master 5389 "Add examples on how to import storage types to the book (#6051)" [compiling] [benchmark] [bin size] ok
Warning: Cache at "/home/xunilrj/.cache/sway-bench" is using 108M of your disk space
Opening in existing browser session.
```

The script tries to be gentle on printing to the terminal, so details
are redirected to `$HOME/.cache/sway-bench/log.txt`, which can be `tail
-f` if needed.

So the only feedback is that for each commit, it prints:
- which branch is being used;
- its hash;
- its message;
- and which step is running: compiling `forc`, running the benchmark and
calculating the binary size.

The script runs incrementally. So it never redo a step if its results
exist in the cache. A second consecutive run should not do anything.
This is particularly important when compiling all the multiple versions
of `forc`, which can take quite a long time!

The option `-o` will open the browser pointing to the report after
everything is finished.

An important detail is disk usage. At the end of the script, it reminds
you how much space is being used. Each `forc` version is consuming more
than 50MB. One can easily clean this with `--clean`. It asks permission
before deleting anything, but it is always important to double-check if
it is not doing something crazy.

```
> test/bench.sh --clean all
```

If you have a specific branch you want to test, you can try 

```
> test/bench.sh -n 1 -p test/src/e2e_vm_tests/test_programs/should_pass/language/main_args/main_args_empty/ --branch xunilrj/configurables-faster-access
```

Suggestions and improvements are welcomed.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
The Sway Book Everything to do with the Sway Book
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants