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

Comprehensive fees proposal #16984

Closed

Conversation

jackcmay
Copy link
Contributor

Problem

The current fee structure lacks a comprehensive account of the work required by
a validator to process a transaction

Summary of Changes

Initial thoughts on how to improve the fee structure, feedback please

Fixes #

@jackcmay
Copy link
Contributor Author

@sakridge Can you take a look at this?

@jackcmay jackcmay force-pushed the comprehensive-compute-fees branch from a7c7936 to ba9935f Compare May 3, 2021 17:11
@sakridge
Copy link
Member

sakridge commented May 3, 2021

@sakridge Can you take a look at this?

Nice. I think this makes a lot of sense.

The per-byte account loading fee would be good, but I do also see the downside of it being more difficult to compute the fee.

@sakridge
Copy link
Member

sakridge commented May 3, 2021

cc @taozhu-chicago who is working on the transaction cost model which relates to this.

@stale
Copy link

stale bot commented Jun 2, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Jun 2, 2021
@stale stale bot removed the stale [bot only] Added to stale content; results in auto-close after a week. label Jun 7, 2021
@stale
Copy link

stale bot commented Jun 16, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Jun 16, 2021
@stale stale bot removed the stale [bot only] Added to stale content; results in auto-close after a week. label Jun 18, 2021
@jackcmay jackcmay mentioned this pull request Jun 21, 2021
@jackcmay
Copy link
Contributor Author

jackcmay commented Jun 22, 2021

I took a look a program execution metrics on mainnet beta, you can find some of my observations here: https://drive.google.com/drive/folders/1nE4850wtqD9VZAHCU9XxBg8UqvenwmKU?usp=sharing
One goal was to establish what we should set for a proposed transaction-wide compute unit cap. Looks like except Radium v3 all the programs I saw running in a 5 minute window on mainnet were well under the current 200k max instruction-wide cap. I’m thinking we should initially set the transaction-wide cap to 200k units.
Another goal was to establish a target compute unit/us rate we can use to calibrate the cost of new program operations. Our current rate varies quite a bit which to me means that current cost rates vary from operation to operation. The current measured rate is also very low, and if all programs maxed out their compute budget we could see around 125 tps. We constantly face pressure to allow programs to do more computation, we have the challenge to reconcile this with our high tps goals. For example, cybercore has proposed an ecrecover syscall that they’ve measured at ~248us and proposed a cost of 25k compute units. That results in a ~100 unit/us rate which at the current cap of 200k instructions results in a max of ~500 tps. That’s a big discrepancy between where we want to be and where we are.

@stale
Copy link

stale bot commented Jul 2, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Jul 2, 2021
@stale
Copy link

stale bot commented Jul 11, 2021

This stale pull request has been automatically closed. Thank you for your contributions.

@stale stale bot closed this Jul 11, 2021
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 29, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 29, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 29, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 29, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 29, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 29, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 29, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 29, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 29, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 30, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Sep 30, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit to tao-stones/solana that referenced this pull request Oct 6, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit that referenced this pull request Oct 6, 2021
* Cost Model to limit transactions which are not parallelizeable (#16694)

* * Add following to banking_stage:
  1. CostModel as immutable ref shared between threads, to provide estimated cost for transactions.
  2. CostTracker which is shared between threads, tracks transaction costs for each block.

* replace hard coded program ID with id() calls

* Add Account Access Cost as part of TransactionCost. Account Access cost are weighted differently between read and write, signed and non-signed.

* Establish instruction_execution_cost_table, add function to update or insert instruction cost, unit tested. It is read-only for now; it allows Replay to insert realtime instruction execution costs to the table.

* add test for cost_tracker atomically try_add operation, serves as safety guard for future changes

* check cost against local copy of cost_tracker, return transactions that would exceed limit as unprocessed transaction to be buffered; only apply bank processed transactions cost to tracker;

* bencher to new banking_stage with max cost limit to allow cost model being hit consistently during bench iterations

* replay stage feed back program cost (#17731)

* replay stage feeds back realtime per-program execution cost to cost model;

* program cost execution table is initialized into empty table, no longer populated with hardcoded numbers;

* changed cost unit to microsecond, using value collected from mainnet;

* add ExecuteCostTable with fixed capacity for security concern, when its limit is reached, programs with old age AND less occurrence will be pushed out to make room for new programs.

* investigate system performance test degradation  (#17919)

* Add stats and counter around cost model ops, mainly:
- calculate transaction cost
- check transaction can fit in a block
- update block cost tracker after transactions are added to block
- replay_stage to update/insert execution cost to table

* Change mutex on cost_tracker to RwLock

* removed cloning cost_tracker for local use, as the metrics show clone is very expensive.

* acquire and hold locks for block of TXs, instead of acquire and release per transaction;

* remove redundant would_fit check from cost_tracker update execution path

* refactor cost checking with less frequent lock acquiring

* avoid many Transaction_cost heap allocation when calculate cost, which
is in the hot path - executed per transaction.

* create hashmap with new_capacity to reduce runtime heap realloc.

* code review changes: categorize stats, replace explicit drop calls, concisely initiate to default

* address potential deadlock by acquiring locks one at time

* Persist cost table to blockstore (#18123)

* Add `ProgramCosts` Column Family to blockstore, implement LedgerColumn; add `delete_cf` to Rocks
* Add ProgramCosts to compaction excluding list alone side with TransactionStatusIndex in one place: `excludes_from_compaction()`

* Write cost table to blockstore after `replay_stage` replayed active banks; add stats to measure persist time
* Deletes program from `ProgramCosts` in blockstore when they are removed from cost_table in memory
* Only try to persist to blockstore when cost_table is changed.
* Restore cost table during validator startup

* Offload `cost_model` related operations from replay main thread to dedicated service thread, add channel to send execute_timings between these threads;
* Move `cost_update_service` to its own module; replay_stage is now decoupled from cost_model.

* log warning when channel send fails (#18391)

* Aggregate cost_model into cost_tracker (#18374)

* * aggregate cost_model into cost_tracker, decouple it from banking_stage to prevent accidental deadlock. * Simplified code, removed unused functions

* review fixes

* update ledger tool to restore cost table from blockstore (#18489)

* update ledger tool to restore cost model from blockstore when compute-slot-cost

* Move initialize_cost_table into cost_model, so the function can be tested and shared between validator and ledger-tool

* refactor and simplify a test

* manually fix merge conflicts

* Per-program id timings (#17554)

* more manual fixing

* solve a merge conflict

* featurize cost model

* more merge fix

* cost model uses compute_unit to replace microsecond as cost unit
(#18934)

* Reject blocks for costs above the max block cost (#18994)

* Update block max cost limit to fix performance regession (#19276)

* replace function with const var for better readability (#19285)

* Add few more metrics data points (#19624)

* periodically report sigverify_stage stats (#19674)

* manual merge

* cost model nits (#18528)

* Accumulate consumed units (#18714)

* tx wide compute budget (#18631)

* more manual merge

* ignore zerorize drop security

* - update const cost values with data collected by #19627
- update cost calculation to closely proposed fee schedule #16984

* add transaction cost histogram metrics (#20350)

* rebase to 1.7.15

* add tx count and thread id to stats (#20451)
each stat reports and resets when slot changes

* remove cost_model feature_set

* ignore vote transactions from cost model

Co-authored-by: sakridge <sakridge@gmail.com>
Co-authored-by: Jeff Biseda <jbiseda@gmail.com>
Co-authored-by: Jack May <jack@solana.com>
t-nelson pushed a commit that referenced this pull request Oct 6, 2021
* Cost Model to limit transactions which are not parallelizeable (#16694)

* * Add following to banking_stage:
  1. CostModel as immutable ref shared between threads, to provide estimated cost for transactions.
  2. CostTracker which is shared between threads, tracks transaction costs for each block.

* replace hard coded program ID with id() calls

* Add Account Access Cost as part of TransactionCost. Account Access cost are weighted differently between read and write, signed and non-signed.

* Establish instruction_execution_cost_table, add function to update or insert instruction cost, unit tested. It is read-only for now; it allows Replay to insert realtime instruction execution costs to the table.

* add test for cost_tracker atomically try_add operation, serves as safety guard for future changes

* check cost against local copy of cost_tracker, return transactions that would exceed limit as unprocessed transaction to be buffered; only apply bank processed transactions cost to tracker;

* bencher to new banking_stage with max cost limit to allow cost model being hit consistently during bench iterations

* replay stage feed back program cost (#17731)

* replay stage feeds back realtime per-program execution cost to cost model;

* program cost execution table is initialized into empty table, no longer populated with hardcoded numbers;

* changed cost unit to microsecond, using value collected from mainnet;

* add ExecuteCostTable with fixed capacity for security concern, when its limit is reached, programs with old age AND less occurrence will be pushed out to make room for new programs.

* investigate system performance test degradation  (#17919)

* Add stats and counter around cost model ops, mainly:
- calculate transaction cost
- check transaction can fit in a block
- update block cost tracker after transactions are added to block
- replay_stage to update/insert execution cost to table

* Change mutex on cost_tracker to RwLock

* removed cloning cost_tracker for local use, as the metrics show clone is very expensive.

* acquire and hold locks for block of TXs, instead of acquire and release per transaction;

* remove redundant would_fit check from cost_tracker update execution path

* refactor cost checking with less frequent lock acquiring

* avoid many Transaction_cost heap allocation when calculate cost, which
is in the hot path - executed per transaction.

* create hashmap with new_capacity to reduce runtime heap realloc.

* code review changes: categorize stats, replace explicit drop calls, concisely initiate to default

* address potential deadlock by acquiring locks one at time

* Persist cost table to blockstore (#18123)

* Add `ProgramCosts` Column Family to blockstore, implement LedgerColumn; add `delete_cf` to Rocks
* Add ProgramCosts to compaction excluding list alone side with TransactionStatusIndex in one place: `excludes_from_compaction()`

* Write cost table to blockstore after `replay_stage` replayed active banks; add stats to measure persist time
* Deletes program from `ProgramCosts` in blockstore when they are removed from cost_table in memory
* Only try to persist to blockstore when cost_table is changed.
* Restore cost table during validator startup

* Offload `cost_model` related operations from replay main thread to dedicated service thread, add channel to send execute_timings between these threads;
* Move `cost_update_service` to its own module; replay_stage is now decoupled from cost_model.

* log warning when channel send fails (#18391)

* Aggregate cost_model into cost_tracker (#18374)

* * aggregate cost_model into cost_tracker, decouple it from banking_stage to prevent accidental deadlock. * Simplified code, removed unused functions

* review fixes

* update ledger tool to restore cost table from blockstore (#18489)

* update ledger tool to restore cost model from blockstore when compute-slot-cost

* Move initialize_cost_table into cost_model, so the function can be tested and shared between validator and ledger-tool

* refactor and simplify a test

* manually fix merge conflicts

* Per-program id timings (#17554)

* more manual fixing

* solve a merge conflict

* featurize cost model

* more merge fix

* cost model uses compute_unit to replace microsecond as cost unit
(#18934)

* Reject blocks for costs above the max block cost (#18994)

* Update block max cost limit to fix performance regession (#19276)

* replace function with const var for better readability (#19285)

* Add few more metrics data points (#19624)

* periodically report sigverify_stage stats (#19674)

* manual merge

* cost model nits (#18528)

* Accumulate consumed units (#18714)

* tx wide compute budget (#18631)

* more manual merge

* ignore zerorize drop security

* - update const cost values with data collected by #19627
- update cost calculation to closely proposed fee schedule #16984

* add transaction cost histogram metrics (#20350)

* rebase to 1.7.15

* add tx count and thread id to stats (#20451)
each stat reports and resets when slot changes

* remove cost_model feature_set

* ignore vote transactions from cost model

Co-authored-by: sakridge <sakridge@gmail.com>
Co-authored-by: Jeff Biseda <jbiseda@gmail.com>
Co-authored-by: Jack May <jack@solana.com>
tao-stones added a commit to tao-stones/solana that referenced this pull request Oct 7, 2021
- update cost calculation to closely proposed fee schedule solana-labs#16984
tao-stones added a commit that referenced this pull request Oct 8, 2021
- update cost calculation to closely proposed fee schedule #16984
dankelleher pushed a commit to identity-com/solana that referenced this pull request Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale [bot only] Added to stale content; results in auto-close after a week.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants