Skip to content

[gas profiler] various improments#18589

Merged
vgao1996 merged 5 commits intomainfrom
victor/gas-profiler-summary-and-separation
Feb 10, 2026
Merged

[gas profiler] various improments#18589
vgao1996 merged 5 commits intomainfrom
victor/gas-profiler-summary-and-separation

Conversation

@vgao1996
Copy link
Contributor

@vgao1996 vgao1996 commented Feb 3, 2026

Gas Profiler Report Improvements

This PR makes various improvements to the gas profile, making the generated gas report more aligned with the on-chain FeeStatement and easier to understand.

Summary Section

  • Added a new Summary section at the top of the report that directly corresponds to the FeeStatement event (execution gas, IO gas, storage fee, storage refund)
Screenshot 2026-02-03 145138

Cost Categorization

  • Separated Execution and IO costs into distinct sections in the Cost Break-down
  • Percentages are now calculated against per-category totals (execution % against execution total, IO % against IO total)
  • Fixed method tables to only include actual function calls

CLI: --fold-unique-stack flag for gas profiling

Added a new --fold-unique-stack flag that can be used with --profile-gas to aggregate identical call paths in the gas report. This helps reduce the size of large reports by folding repeated function calls into single entries with combined costs.

Other

  • Various formatting fixes, code cleanup, and a new e2e test for gas profiling

Note

Medium Risk
Touches gas profiler accounting/reporting and CLI simulation flow; main risk is incorrect categorization/percentages or regression in report generation/output formatting, but changes are localized and covered by a new e2e test.

Overview
Improves the gas profiler’s HTML report to better match on-chain FeeStatement by splitting execution vs IO gas, adding a top-level Summary (execution gas, IO gas, storage fee, storage refund), and recalculating breakdown percentages against the appropriate category totals (execution, IO, storage).

Tightens aggregation output by filtering method tables to only include entries that look like function calls, refactors flamegraph generation into shared helpers, and updates internal accounting to store execution_gas and io_gas separately (with total() computed).

Adds a new CLI flag --fold-unique-stack (requires --profile-gas) to fold identical call paths before report generation, and introduces an e2e Move test package + Rust test to generate a report and sanity-check the new summary and sections.

Written by Cursor Bugbot for commit 66e2a83. This will update automatically on new commits. Configure here.

@vgao1996 vgao1996 changed the title [gas profiler] add summary section + execution & io as separate sections [gas profiler] add summary section + execution & io as separate sections + add test Feb 3, 2026
@vgao1996 vgao1996 changed the title [gas profiler] add summary section + execution & io as separate sections + add test [gas profiler] various improments Feb 3, 2026
@vgao1996 vgao1996 requested review from a team and igor-aptos and removed request for georgemitenkov February 3, 2026 22:46
@vgao1996 vgao1996 force-pushed the victor/gas-profiler-summary-and-separation branch from e06f62f to 5a88159 Compare February 3, 2026 22:53
@vgao1996 vgao1996 marked this pull request as ready for review February 3, 2026 23:02
let re = regex::Regex::new("([1-9][0-9]*(,[0-9]+)*) samples")
.expect("should be able to build regex successfully");
let graph_content = re.replace_all(&graph_content, |caps: &Captures| {
generate_flamegraph(self.to_folded_stack_lines(), title, |caps| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does to_folded_stack_lines do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting the data into the format the flamegraph generator understands. Folded stack lines look like this:

funcA;funcB 10
funcA;funcB;funcC 50

@vgao1996 vgao1996 force-pushed the victor/gas-profiler-summary-and-separation branch from 692f710 to 66e2a83 Compare February 10, 2026 02:15
@vgao1996 vgao1996 enabled auto-merge (squash) February 10, 2026 02:16
@vgao1996 vgao1996 disabled auto-merge February 10, 2026 02:16
@vgao1996 vgao1996 enabled auto-merge (squash) February 10, 2026 02:16
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

✅ Forge suite compat success on e111ecb21fc45ebd6dbf127f650ca125291bcbd2 ==> 66e2a83be14fef2895574020730edd5b00f89149

Compatibility test results for e111ecb21fc45ebd6dbf127f650ca125291bcbd2 ==> 66e2a83be14fef2895574020730edd5b00f89149 (PR)
1. Check liveness of validators at old version: e111ecb21fc45ebd6dbf127f650ca125291bcbd2
compatibility::simple-validator-upgrade::liveness-check : committed: 13696.92 txn/s, latency: 2543.79 ms, (p50: 2700 ms, p70: 2800, p90: 3100 ms, p99: 3600 ms), latency samples: 448240
2. Upgrading first Validator to new version: 66e2a83be14fef2895574020730edd5b00f89149
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 5739.19 txn/s, latency: 5894.10 ms, (p50: 6500 ms, p70: 6600, p90: 6800 ms, p99: 6900 ms), latency samples: 198180
3. Upgrading rest of first batch to new version: 66e2a83be14fef2895574020730edd5b00f89149
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 5890.03 txn/s, latency: 5734.57 ms, (p50: 6300 ms, p70: 6500, p90: 6600 ms, p99: 6700 ms), latency samples: 203880
4. upgrading second batch to new version: 66e2a83be14fef2895574020730edd5b00f89149
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 9956.51 txn/s, latency: 3269.20 ms, (p50: 3100 ms, p70: 3800, p90: 4400 ms, p99: 5000 ms), latency samples: 330080
5. check swarm health
Compatibility test for e111ecb21fc45ebd6dbf127f650ca125291bcbd2 ==> 66e2a83be14fef2895574020730edd5b00f89149 passed
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite realistic_env_max_load success on 66e2a83be14fef2895574020730edd5b00f89149

Forge report malformed: Expecting ',' delimiter: line 1 column 6 (char 5)
'[2026-02-10T02:52:28Z INFO  aptos_forge::report] Test Ok\n{\n  "metrics": [\n    {\n      "test_name": "two traffics test: inner traffic",\n      "metric": "submitted_txn",\n      "value": 5078260.0\n    },\n    {\n      "test_name": "two traffics test: inner traffic",\n      "metric": "expired_txn",\n      "value": 0.0\n    },\n    {\n      "test_name": "two traffics test: inner traffic",\n      "metric": "avg_tps",\n      "value": 13636.916914562193\n    },\n    {\n      "test_name": "two traffics test: inner traffic",\n      "metric": "avg_latency",\n      "value": 2763.512740978209\n    },\n    {\n      "test_name": "two traffics test: inner traffic",\n      "metric": "p50_latency",\n      "value": 2700.0\n    },\n    {\n      "test_name": "two traffics test: inner traffic",\n      "metric": "p90_latency",\n      "value": 3000.0\n    },\n    {\n      "test_name": "two traffics test: inner traffic",\n      "metric": "p99_latency",\n      "value": 3600.0\n    },\n    {\n      "test_name": "two traffics test",\n      "metric": "submitted_txn",\n      "value": 42680.0\n    },\n    {\n      "test_name": "two traffics test",\n      "metric": "expired_txn",\n      "value": 0.0\n    },\n    {\n      "test_name": "two traffics test",\n      "metric": "avg_tps",\n      "value": 100.00644189644372\n    },\n    {\n      "test_name": "two traffics test",\n      "metric": "avg_latency",\n      "value": 743.7392857142858\n    },\n    {\n      "test_name": "two traffics test",\n      "metric": "p50_latency",\n      "value": 700.0\n    },\n    {\n      "test_name": "two traffics test",\n      "metric": "p90_latency",\n      "value": 800.0\n    },\n    {\n      "test_name": "two traffics test",\n      "metric": "p99_latency",\n      "value": 1200.0\n    }\n  ],\n  "text": "two traffics test: inner traffic : committed: 13636.92 txn/s, latency: 2763.51 ms, (p50: 2700 ms, p70: 2900, p90: 3000 ms, p99: 3600 ms), latency samples: 5078260\\ntwo traffics test : committed: 100.01 txn/s, latency: 743.74 ms, (p50: 700 ms, p70: 800, p90: 800 ms, p99: 1200 ms), latency samples: 1680\\nLatency breakdown for phase 0: [\\"MempoolToBlockCreation: max: 2.225, avg: 2.169\\", \\"ConsensusProposalToOrdered: max: 0.168, avg: 0.165\\", \\"ConsensusOrderedToCommit: max: 0.052, avg: 0.046\\", \\"ConsensusProposalToCommit: max: 0.220, avg: 0.211\\"]\\nMax non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.54s no progress at version 2820496 (avg 0.07s) [limit 15].\\nMax epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.30s no progress at version 2373952 (avg 0.30s) [limit 16].\\nTest Ok"\n}'
Trailing Log Lines:
networkchaos.chaos-mesh.org "4-gcp--as-southeast1-to-3-gcp--us-east4-netem" deleted
test CompositeNetworkTest ... ok
Test Statistics: 
two traffics test: inner traffic : committed: 13636.92 txn/s, latency: 2763.51 ms, (p50: 2700 ms, p70: 2900, p90: 3000 ms, p99: 3600 ms), latency samples: 5078260
two traffics test : committed: 100.01 txn/s, latency: 743.74 ms, (p50: 700 ms, p70: 800, p90: 800 ms, p99: 1200 ms), latency samples: 1680
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 2.225, avg: 2.169", "ConsensusProposalToOrdered: max: 0.168, avg: 0.165", "ConsensusOrderedToCommit: max: 0.052, avg: 0.046", "ConsensusProposalToCommit: max: 0.220, avg: 0.211"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.54s no progress at version 2820496 (avg 0.07s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.30s no progress at version 2373952 (avg 0.30s) [limit 16].
Test Ok

=== BEGIN JUNIT ===
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="forge" tests="1" failures="0" errors="0" uuid="4a09ee7b-627b-46c7-9b64-ff48ee24c738">
    <testsuite name="local" tests="1" disabled="0" errors="0" failures="0">
        <testcase name="CompositeNetworkTest(network:multi-region-network-emulation(two traffics test)) with ">
        </testcase>
    </testsuite>
</testsuites>
=== END JUNIT ===
[2026-02-10T02:52:28Z INFO  aptos_forge::backend::k8s::cluster_helper] Deleting namespace forge-e2e-pr-18589: Some(NamespaceStatus { conditions: None, phase: Some("Terminating") })
[2026-02-10T02:52:28Z INFO  aptos_forge::backend::k8s::cluster_helper] aptos-node resources for Forge removed in namespace: forge-e2e-pr-18589

test result: ok. 1 passed; 0 soft failed; 0 hard failed; 0 filtered out

Debugging output:
NAME                                         READY   STATUS      RESTARTS   AGE
aptos-node-0-fullnode-eforgee6dce1fe-0       1/1     Running     0          12m
aptos-node-0-validator-0                     1/1     Running     0          12m
aptos-node-1-fullnode-eforgee6dce1fe-0       1/1     Running     0          12m
aptos-node-1-validator-0                     1/1     Running     0          12m
aptos-node-2-fullnode-eforgee6dce1fe-0       1/1     Running     0          12m
aptos-node-2-validator-0                     1/1     Running     0          12m
aptos-node-3-fullnode-eforgee6dce1fe-0       1/1     Running     0          12m
aptos-node-3-validator-0                     1/1     Running     0          12m
aptos-node-4-fullnode-eforgee6dce1fe-0       1/1     Running     0          12m
aptos-node-4-validator-0                     1/1     Running     0          12m
aptos-node-5-validator-0                     1/1     Running     0          12m
aptos-node-6-validator-0                     1/1     Running     0          12m
forge-testnet-deployer-5dtlh                 0/1     Completed   0          13m
genesis-aptos-genesis-eforgee6dce1fe-pkgqt   0/1     Completed   0          12m

@github-actions
Copy link
Contributor

✅ Forge suite framework_upgrade success on e111ecb21fc45ebd6dbf127f650ca125291bcbd2 ==> 66e2a83be14fef2895574020730edd5b00f89149

Compatibility test results for e111ecb21fc45ebd6dbf127f650ca125291bcbd2 ==> 66e2a83be14fef2895574020730edd5b00f89149 (PR)
Upgrade the nodes to version: 66e2a83be14fef2895574020730edd5b00f89149
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2233.09 txn/s, submitted: 2241.04 txn/s, failed submission: 7.95 txn/s, expired: 7.95 txn/s, latency: 1306.09 ms, (p50: 1200 ms, p70: 1500, p90: 1500 ms, p99: 2400 ms), latency samples: 202160
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2070.23 txn/s, submitted: 2076.24 txn/s, failed submission: 6.01 txn/s, expired: 6.01 txn/s, latency: 1809.17 ms, (p50: 1200 ms, p70: 1500, p90: 1800 ms, p99: 12400 ms), latency samples: 179180
5. check swarm health
Compatibility test for e111ecb21fc45ebd6dbf127f650ca125291bcbd2 ==> 66e2a83be14fef2895574020730edd5b00f89149 passed
Upgrade the remaining nodes to version: 66e2a83be14fef2895574020730edd5b00f89149
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 2037.58 txn/s, submitted: 2044.31 txn/s, failed submission: 6.72 txn/s, expired: 6.72 txn/s, latency: 1817.04 ms, (p50: 1200 ms, p70: 1500, p90: 1800 ms, p99: 11800 ms), latency samples: 175741
Test Ok

@vgao1996 vgao1996 merged commit 70fd91f into main Feb 10, 2026
115 of 136 checks passed
@vgao1996 vgao1996 deleted the victor/gas-profiler-summary-and-separation branch February 10, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants