| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
Add `--perf` option to `test` to collect and diff performance data (#7459) ## Description This PR: - Adds `--perf` and `--perf-only` options to `test` to collect gas usages and bytecode sizes, and to run only the tests that actually produce those performance data, respectively. - Adds `[performance]` recipes to `justfile` that fully automate a workflow for collecting and comparing performance data of the compiler output. `--perf` flag instructs `test` to collect performance data from tests of categories `compile`, `run`, and `unit_tests_pass`. Collected gas usages and bytecode sizes are written to files named `<timestamp>-<category>-<build profile>-<branch>.csv`. E.g.: `1020165605-e2e-bytecode-sizes-release-master.csv`. When running tests in parallel (default option), performance data of each individual `test --exact <test_toml_path>` process is written to a piped stdout in JSON format. The main `test` process collects those JSON outputs from all spanned processes. The usual workflow of collecting and comparing performance data between the `master` and feature branch is supported by the following `just` recipes: ```console [performance] perf-e2e filter='' # collect gas usages and bytecode sizes from E2E tests [alias: pe2e] perf-in-lang filter='' # collect gas usages from in-language tests [alias: pil] perf-all filter='' # collect gas usages and bytecode sizes from all tests (E2E and in-language) [alias: pa] perf-diff before after format='md' # generate performance diff between two CSV files [alias: pd] perf-diff-latest format='md' # generate performance diffs between the latest two CSV files per testing category [alias: pdl] perf-snapshot-historical path open='' # collect historic gas usages from a snapshot test that has a `forc test` output [alias: psh] perf-list # list all performance files (*gas-usages-*.* and *bytecode-sizes-*.*) [alias: pl] perf-remove # remove all performance files (*gas-usages-*.* and *bytecode-sizes-*.*) [alias: pr] ``` To obtain the performance comparison it is enough to run: ```console just pa // `just perf-all`. On `master` to get the baseline. just pa // `just perf-all`. On the feature branch to get the improved data. just pdl // `just perf-diff-latest`. To get the diff of the last two collected performance data sets. ``` The `just` recipes should be executed from the root of the Sway repository. Aside from `--perf` writing to predefined files, all other parts of the workflow are `just` recipes and can potentially be tailored to any other workflow. Adding support for collecting gas usages and bytecode sizes from other tests like (snapshot, in-language, SDK harness) will be added in follow up PRs. ## Checklist - [ ] I have linked to any relevant issues. - [x] 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). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] 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. - [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. | 10 个月前 |
perf_out Folder
The perf_out folder contains temporary files with performance data collected from tests. E.g, *-gas-usages-*.csv or *-bytecode-sizes-*.cvs.
The performance data are .gitignored. To delete them locally after an analysis is done, call just pr. pr is an alias for perf-remove just recipe that removes all temporary files related to collected performance data.