{"id":19205058,"url":"https://github.com/ggwpez/substrate-weight-compare","last_synced_at":"2025-08-08T02:20:16.685Z","repository":{"id":38443499,"uuid":"484848197","full_name":"ggwpez/substrate-weight-compare","owner":"ggwpez","description":"Compares Substrate Weight Files","archived":false,"fork":false,"pushed_at":"2025-06-17T12:06:28.000Z","size":822,"stargazers_count":29,"open_issues_count":19,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-17T18:47:59.783Z","etag":null,"topics":["blockchain","polkadot","rust","substrate"],"latest_commit_sha":null,"homepage":"https://weights.tasty.limo/compare-mr","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ggwpez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-23T20:18:55.000Z","updated_at":"2025-02-24T16:41:56.000Z","dependencies_parsed_at":"2024-11-09T13:11:06.177Z","dependency_job_id":"cdbf273a-b41c-4152-a533-234b58ed370f","html_url":"https://github.com/ggwpez/substrate-weight-compare","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/ggwpez/substrate-weight-compare","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggwpez%2Fsubstrate-weight-compare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggwpez%2Fsubstrate-weight-compare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggwpez%2Fsubstrate-weight-compare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggwpez%2Fsubstrate-weight-compare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ggwpez","download_url":"https://codeload.github.com/ggwpez/substrate-weight-compare/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggwpez%2Fsubstrate-weight-compare/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269352122,"owners_count":24402730,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","polkadot","rust","substrate"],"created_at":"2024-11-09T13:11:03.178Z","updated_at":"2025-08-08T02:20:16.619Z","avatar_url":"https://github.com/ggwpez.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\u003cbr\u003e\n    Subweight\n\u003cbr\u003e\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eCompares Weight files that where generated by \u003ca href=\"https://github.com/paritytech/substrate\"\u003eSubstrate\u003c/a\u003e.\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.gnu.org/licenses/gpl-3.0\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-GPL%20v3-blue.svg\" alt=\"License: GPL v3\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://weights.tasty.limo/\"\u003e\n    \u003cimg src=\"https://weights.tasty.limo/version/badge\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/ggwpez/substrate-weight-compare/actions/workflows/ci.yml\"\u003e\n    \u003cimg src=\"https://github.com/ggwpez/substrate-weight-compare/actions/workflows/ci.yml/badge.svg\"/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nThis project parses and compares Substrate Weight files. It helps tremendously with the review process of large Weight diffs. The results can be displayed conveniently in the CLI or browser.\n\n# Abstract\n\nManually comparing Substrate Weight files is a task where humans falter and computers excel.  \nWhen you want to know what I am talking about; take a look at [this diff](https://github.com/paritytech/polkadot/pull/5098/files).  \nNow tell me which lines are problematic and which are fine 😈? Does not look appealing, does it? \n\nThis is where *Subweight* comes to the rescue: It takes the old and the new version and compares all extrinsics.  \nThe human-friendly output looks like this:  \n\n![](.assets/compare%20mr%20output.png)\n\nThis automatically sorts the worst offenders to the top and allows humans to see at a glance what is going on – without loosing details! Links to the diff are all there, and sharing results is as easy as copying a link to the line. Compatible with most Substrate chains. Enjoy!\n\nYou can play around with the following public endpoints that are exposed by `subweight-web`:  \n- [Compare Merge Requests](https://weights.tasty.limo/compare-mr)\n- [Compare Commits](https://weights.tasty.limo/compare-commit)\n\nThe *dev* branch is deployed at \u003chttps://weights.tasty.limo:8443/\u003e.\n\n# Install\n\nInstall both binaries:\n\n```sh\ncargo install subweight subweight-web\n\nsubweight --version\nsubweight-web --version\n```\n\n# Compilation\n\nThe [rust-toolchain.toml](./rust-toolchain.toml) defines the exact Rust version that the code was tested with.  \nThe formatting rules are defined in [rustfmt.toml](./rustfmt.toml).\n\n```sh\ngit clone https://github.com/ggwpez/substrate-weight-compare\n\ncd substrate-weight-compare/\ncargo build --profile production\n```\n# Example: Web Interface\n\nAssuming you have a Substrate compatible repository checked out in the parent directory:\n\n```sh\nsubweight-web --root ../ --repos polkadot substrate cumulus\n```\n\nthen open your browser and try the following:\n- [http://localhost:8080/](http://localhost:8080/)\n\n# Example: Compare weight files\n\nSuppose you have some weight files in:\n- `OLD=repos/polkadot/` and\n- `NEW=my_other_repos/polkadot`   \nThe base command looks like this:\n\n```sh\nsubweight compare files --old $OLD/* --new $NEW/* --method asymptotic\n```\n\nIf you want to compare the weights of the Kusama to the Polkadot runtime, the command becomes a bit more longer:\n```sh\nsubweight compare files --old ../polkadot/runtime/kusama/**/weights/*.rs --new ../polkadot/runtime/polkadot/*/weights/*.rs --method asymptotic --ignore-errors --change changed unchanged --unit time --threshold 10\n```\n\n```sh\n+-----------------------------------------+-----------------------------+----------+----------+---------------+\n| File                                    | Extrinsic                   | Old      | New      | Change [%]    |\n+=============================================================================================================+\n| pallet_election_provider_multi_phase.rs | feasibility_check           | 1.23ms   | 812.80us | -33.90 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| frame_benchmarking_baseline.rs          | addition                    | 162.00ns | 112.00ns | -30.86 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| runtime_parachains_hrmp.rs              | hrmp_cancel_open_request    | 27.90us  | 39.02us  | +39.86 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| pallet_tips.rs                          | slash_tip                   | 15.86us  | 22.61us  | +42.56 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| runtime_parachains_initializer.rs       | force_approve               | 3.12us   | 4.53us   | +45.02 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| runtime_parachains_hrmp.rs              | clean_open_channel_requests | 366.82us | 590.73us | +61.04 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| runtime_parachains_hrmp.rs              | hrmp_accept_open_channel    | 29.81us  | 48.54us  | +62.81 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| runtime_parachains_hrmp.rs              | hrmp_close_channel          | 27.58us  | 44.92us  | +62.89 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| runtime_parachains_hrmp.rs              | force_process_hrmp_open     | 2.17ms   | 3.64ms   | +67.28 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| runtime_parachains_hrmp.rs              | hrmp_init_open_channel      | 32.67us  | 55.70us  | +70.49 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| runtime_parachains_hrmp.rs              | force_process_hrmp_close    | 1.21ms   | 2.11ms   | +74.25 |\n|-----------------------------------------+-----------------------------+----------+----------+---------------|\n| runtime_parachains_hrmp.rs              | force_clean_hrmp            | 1.82ms   | 3.27ms   | +80.04 |\n+-----------------------------------------+-----------------------------+----------+----------+---------------+\n```\nCou can use the `--print-terms` flag to print the terms. This example omits them since the rows get really long.\n\n\n# Example: Compare Polkadot Commits\n\nCompare arbitrary Polkadot commits assuming you run this in the Polkadot directory:\n\n```sh\nsubweight --verbose compare commits HEAD HEAD~100 --threshold 10 --method asymptotic --path-pattern \"runtime/*/src/weights/**/*.rs,bridges/modules/*/src/weights.rs\"\n\n+------------------------------------------------------------------+-------------------------+--------+---------+----------------+\n| File                                                             | Extrinsic               | Old    | New     | Change [%]     |\n+================================================================================================================================+\n| runtime/rococo/src/weights/runtime_parachains_paras_inherent.rs  | enter_variable_disputes | -      | -       | ERROR          |\n|------------------------------------------------------------------+-------------------------+--------+---------+----------------|\n| runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs | set_topic               | 2.59us | 10.01us | +286.67 |\n|------------------------------------------------------------------+-------------------------+--------+---------+----------------|\n| runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs | clear_transact_status   | 2.65us | 9.96us  | +276.24 |\n|------------------------------------------------------------------+-------------------------+--------+---------+----------------|\n| runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs | clear_topic             | 2.59us | 8.29us  | +220.04 |\n+------------------------------------------------------------------+-------------------------+--------+---------+----------------+\n\n```\nIt prints first the ones that decreased (good) and then the ones that increased (bad) sorted by ascending absolute value.\n\n# Config options\n\n## Repository\n\nSelects the project to use. *Subweight* has the goal of being compatible with:\n- [Substrate]\n- [Polkadot]\n- [Cumulus]\n\nOther projects which are currently compatible, but not a hard requirement:\n- [Acala]\n- [Astar]\n- [Moonbeam]\n- [Composable Finance]\n- [Noodle]\n\nNote: Not all repositories are deployed to the *Subweight* web service.\n\n## Path Pattern\n\nUses the [glob](https://docs.rs/glob/latest/glob/) crate to match files in the repository path with the given pattern.  \nHere are some examples that the web interface uses. These do not catch *all* files, which is a bug:  \n- Substrate: `frame/*/src/weights.rs`\n- Polkadot: `runtime/*/src/weights/**/*.rs,bridges/modules/*/src/weights.rs`\n- Cumulus: `**/weights/*.rs,**/weights/xcm/*.rs,**/src/weights.rs`\n\n`weights/**/*.rs` is preferred to `weights/*.rs` to include possible sub-folders like XCM.  \nThe `mod.rs` file is automatically excluded.  \n\n## Pallet\n\nFilter by the pallets to include by using a [Regex].  \nExamples:\n- `.*` would be *any* pallet.\n- `system|assets` would be the `system` and the `assets` pallet.\n\n## Extrinsic\n\nAnalogous to the [Pallet](#pallet) filter this filters by the extrinsics using a [Regex].  \nExamples:\n- `.*` would be *any* extrinsic.\n- `mint|burn` would be the `mint` and the `burn` extrinsics.\n\n## Evaluation Method\n\nThe evaluation method defines how the weight equation is evaluate (=calculated).  \nThis is a deciding factor when making a decision whether or not a weight got worse.\n\n- *Base*: Only consider the constant factor of the weight plus storage operations.\n- *Exact Worst*: Assumes both equations to be hyper-planes and finds their greatest relative increase by evaluating all corners. The runtime for `n` components is `2^n` which is hard-limited to 16 components.   \nThis requires your weight files to support [component range annotations](https://github.com/paritytech/substrate/issues/11397). One way to check that is to search for the string `\"The range of component\"` in your weight.rs files.\n- *Guess Worst*: Tries to apply *Exact Worst* but assumes all components to have a maximum of 100, if no maximum was found. This is a best-effort approach in case your weight files do not have component range annotations.\n- *Exact Asymptotic*: Set all components to their maximum value. Can be used to get a feeling for the asymptotic change of the formula.\n- *Asymptotic*: Same as *Exact Asymptotic* but fallback to best-effort ranges if no compatible ones could be found.\n\nNOTE: The storage weights are currently set to RocksDB Substrate default.  \n\n## Rel Threshold\n\nFilters the changes results by an absolute percentual threshold.  \nThe percentages values are calculated as increase or decrease.  \nEg: from 100 to 150 would be +50% and would be included by any threshold \u003e=50.\n\n## Abs Threshold\n\nFilters the changes results by an absolute threshold.\n\n## Dimension\n\nThe weight in Substrate is chromatic (two dimensional). Its dimensions are *Reference Time* and *PoV size*. The dimension can therefore be set to either *Time* or *Proof*. A good unit will then automatically be selected, for example `µs` for *Time* or `KiB` for *Proof*; depending on the size of the concrete scalars.\n- *Time*: The execution time that the call consumed on reference hardware.\n- *Proof*: The size of the Proof-of-validity (PoV) that the call produced.\n\nThe relevant MR is [substrate#11637](https://github.com/paritytech/substrate/pull/11637) which requires integration the weight template for your project to emit chromatic weights.\n\n## Ignore Errors\n\nSilently ignore parse errors. This is useful when using inclusive path patterns. You can see all the errors when clicking on the red error box.\n\n## Git Pull\n\nPull the branch before comparing anything. This ensures that you are on the last commit.  \nThis does not override the *Cache*. It can therefore take up to 10 minutes for a new change to show up.\n\n## Cache\n\nThe web UI caches success responses for 10 minutes. Currently there is no flag to disable it.  \nUse commit hashes instead of branches if you want to ensure that you are not being served cached results.\n\n# Possible Errors and Warnings\n\n## Web Interface\n\n### `No range for component …`\n\nThis means that the weights of that call were not updated to expose the exact range of that component. Re-run them with a newer version of Substrate if you want this.\n\n### `… has different ranges in the old and new version`\n\nThis means that the range of a component changed between the old and the new version. This is not a mistake of a problem, but it makes it impossible to accurately compare the terms - therefore the error. When using one of the `Guess-*` comparison methods, it does not try to do an accurate comparison, therefore the error disappears.\n\n# Running the Tests\n\nThere exist *unit* and *integration* tests. Most of them are guarded behind feature flags. The explanation below covers both in one.  \nYou can run the sanity checks just with `cargo test`.\n\n## Integration tests\n\nIntegration tests are written in a macro fashion to allow for easy extension (see [integration.rs]). They have hard-coded expected results and a specific commit hash on which they are run.  \nThe CI does this and additionally for Polkadot also on the master commit.\n\n```sh\ngit clone https://github.com/ggwpez/substrate-weight-compare\ncd substrate-weight-compare\n\n# Clone all the test-able repos\nmkdir -p repos\ngit clone https://github.com/paritytech/polkadot/ repos/polkadot\ngit clone https://github.com/paritytech/substrate/ repos/substrate\ngit clone https://github.com/paritytech/cumulus/ repos/cumulus\ngit clone https://github.com/AcalaNetwork/acala/ repos/acala\ngit clone https://github.com/AstarNetwork/astar/ repos/astar\ngit clone https://github.com/PureStake/moonbeam/ repos/moonbeam\ngit clone https://github.com/ComposableFi/composable/ repos/composable\ngit clone https://github.com/NodleCode/chain/ repos/chain\n\n# Run ALL the tests\ncargo test --release --all-targets --all-features\n```\n\n\u003c!-- LINKS --\u003e\n[Substrate]: https://github.com/paritytech/substrate\n[Polkadot]: https://github.com/paritytech/polkadot\n[Cumulus]: https://github.com/paritytech/cumulus\n\n[Acala]: https://github.com/AcalaNetwork/acala\n[Astar]: https://github.com/AstarNetwork/astar\n[Moonbeam]: https://github.com/PureStake/moonbeam\n[Composable Finance]: https://github.com/ComposableFi/composable\n[Noodle]: https://github.com/NodleCode/chain\n\n[Regex]: https://github.com/fancy-regex/fancy-regex\n[integration.rs]: https://github.com/ggwpez/substrate-weight-compare/blob/master/core/src/test/parse/integration.rs\n\n# License\n\nGPLv3 only, see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fggwpez%2Fsubstrate-weight-compare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fggwpez%2Fsubstrate-weight-compare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fggwpez%2Fsubstrate-weight-compare/lists"}