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

Bash script to help benchmark the compiler #6076

Merged
merged 1 commit into from
May 30, 2024
Merged

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented 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

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

image

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

  • 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.

@xunilrj xunilrj self-assigned this May 30, 2024
@xunilrj xunilrj requested a review from a team May 30, 2024 10:06
@JoshuaBatty JoshuaBatty added the performance Everything related to performance, speed wise or memory wise. label May 30, 2024
@IGI-111 IGI-111 requested a review from a team May 30, 2024 18:33
@xunilrj xunilrj merged commit 70cf8f6 into master May 30, 2024
37 checks passed
@xunilrj xunilrj deleted the xunilrj/bench-script branch May 30, 2024 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Everything related to performance, speed wise or memory wise.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants