Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Add subcommand "compute-slot-cost" to ledger tool #17181

Merged

Conversation

tao-stones
Copy link
Contributor

@tao-stones tao-stones commented May 12, 2021

Problem

Want a way to run banking-stage's cost-model over the block of given slot(s), to compute how expensive each block was, which is used as input for tuning the cost_model that banking_stage uses to feeds its banks.

Summary of Changes

  • Add positional compute-slot-cost subcommand to ledger tool, it runs on all slot if no slots given on command line;
  • It runs each slot's block through cost_model, if a block breaches the cost_model limit, a message will be printed; otherwise each block's cost metrics are printed.

Fixes #

@tao-stones tao-stones requested a review from mvines May 12, 2021 04:27
@codecov
Copy link

codecov bot commented May 12, 2021

Codecov Report

Merging #17181 (0d91203) into master (597373f) will increase coverage by 0.0%.
The diff coverage is 91.8%.

❗ Current head 0d91203 differs from pull request most recent head 41b19d4. Consider uploading reports for the commit 41b19d4 to get more accurate results

@@           Coverage Diff            @@
##           master   #17181    +/-   ##
========================================
  Coverage    82.7%    82.7%            
========================================
  Files         421      419     -2     
  Lines      117926   118112   +186     
========================================
+ Hits        97574    97776   +202     
+ Misses      20352    20336    -16     

@tao-stones tao-stones force-pushed the add-compute-cost-to-ledger-tool branch from 0d91203 to afb1fe4 Compare May 12, 2021 21:09
@tao-stones
Copy link
Contributor Author

Using this branch and ledger downloaded from mainnet, ran $cargo run --bin solana-ledger-tool -- -l mainnet-beta/validator-ledger compute-cost --all to compute costs for all slots' blocks. Results are at google spreadsheet: https://docs.google.com/spreadsheets/d/1bMdUyTFiNEcbTkxS500VNFh7yL0z5c0irqGQK7dmVLs/edit?usp=sharing
Where a vote instruction is considered a unit of cost.

two things are interesting (from the spreadsheet):

  1. The block of slot 76927422 has largest cost (log snippet below), where almost all costs are for one writable account (can filter by slot to see the details on spreadsheet). This is the classic case in which cost_model would spread transactions on same account to multiple blocks.
% cargo run --bin solana-ledger-tool -- -l mainnet-beta/validator-ledger compute-cost --slots 76927422
... ...
Slot: 76927422, Entries: 925, Transactions: 989, Programs 1118, CostModelStats { total_cost: **575687**, number_of_accounts: 823, costliest_account: 9UJ1AYv6rko5xu4Z7DnA5hLaNZFxDu9BxqKp1LULivqC, costliest_account_cost: **559000** }
  Programs: {11111111111111111111111111111111: 120, 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8: 10, 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin: 141, BPFLoaderUpgradeab1e11111111111111111111111: 559, EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q: 1, Vote111111111111111111111111111111111111111: 287}
  1. the account agsWhfJ5PPGjmzMieWY8BR5o1XRVszUBQ5uFz4CtDiJ appeared far more frequently than any other accounts to be the costliest account - meaning the account most instructions/programs wants to write in same block. In other words, this account blocks lots of transactions from being executed in parallel.

To improve cluster throughput efficiency with cost_model, my thought is to set block cost limit to the the max value in spreadsheet (and round up for growth) to 1,000,000 (equivalent to 1M Vote instructions), and to limit the account cost limit to something below average (say equivalent 10,000 vote instructions) to promote parallelizable transactions in a block.

@sakridge @mvines what are your thoughts?

@tao-stones tao-stones marked this pull request as ready for review May 12, 2021 23:17
Copy link
Contributor

@mvines mvines left a comment

Choose a reason for hiding this comment

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

lgtm overall, just some minor nits. Note that I'm only reviewing the ledger-tool/ changes in this PR, since the rest of this code is from another PR

@@ -35,6 +35,7 @@ solana-storage-bigtable = { path = "../storage-bigtable", version = "=1.7.0" }
solana-transaction-status = { path = "../transaction-status", version = "=1.7.0" }
solana-version = { path = "../version", version = "=1.7.0" }
solana-vote-program = { path = "../programs/vote", version = "=1.7.0" }
solana-core = { path = "../core", version = "=1.7.0" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh, it hurts to see this dependency come into ledger-tool. Oh well, we need to refactor core/ more at some point anyway I guess

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, see your point, core should be internal and unexposed. Maybe make sense to move cost model from core to other better suited crates, I am not sure where though, maybe sdk or runtime?

@tao-stones tao-stones force-pushed the add-compute-cost-to-ledger-tool branch from 41b19d4 to 44c0038 Compare June 1, 2021 15:33
@tao-stones tao-stones changed the title Add subcommand "compute-cost" to ledger tool Add subcommand "compute-slot-cost" to ledger tool Jun 1, 2021
@tao-stones tao-stones requested a review from mvines June 1, 2021 18:02
@tao-stones
Copy link
Contributor Author

@mvines cost_model PR has been merged to master, rebased this PR, it's ready for review.

Copy link
Contributor

@mvines mvines left a comment

Choose a reason for hiding this comment

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

looks good

@tao-stones tao-stones merged commit 3a12f92 into solana-labs:master Jun 2, 2021
behzadnouri added a commit to behzadnouri/solana that referenced this pull request Jun 13, 2021
behzadnouri added a commit to behzadnouri/solana that referenced this pull request Jun 13, 2021
mergify bot pushed a commit that referenced this pull request Jul 15, 2021
* include cost_model and cost_tracker from banking stage

* add positional subcommand, compute-slot-cost, to ledger-tool to run cost-model on slots in ledger

Co-authored-by: Michael Vines <[email protected]>

Co-authored-by: Michael Vines <[email protected]>
(cherry picked from commit 3a12f92)

# Conflicts:
#	ledger-tool/Cargo.toml
@tao-stones tao-stones removed the v1.7 label Jul 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants