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

Use consistent naming for compute unit limit #25229

Merged
merged 2 commits into from
May 18, 2022

Conversation

jstarry
Copy link
Member

@jstarry jstarry commented May 15, 2022

Problem

  • Compute units are often just referred to as "units" which is too vague (the RequestUnits ix for example)
  • ComputeBudget::max_units is confusingly named because it's only the max units for a particular tx, not the whole runtime

Summary of Changes

  • Use consistent naming when talking about compute units and the compute unit limit for a tx

Fixes #

@jstarry jstarry force-pushed the rename-compute-unit-limit branch from 9dbf4d7 to 5782a52 Compare May 16, 2022 04:12
@jstarry jstarry marked this pull request as ready for review May 16, 2022 11:21
@jstarry jstarry requested review from jackcmay and tao-stones May 16, 2022 17:14
@jstarry jstarry added the v1.10 label May 16, 2022
tao-stones
tao-stones previously approved these changes May 16, 2022
Copy link
Contributor

@tao-stones tao-stones left a comment

Choose a reason for hiding this comment

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

lgtm

}

/// average cost of all recorded programs
pub fn get_global_average_units(&self) -> u64 {
pub fn get_global_average_program_cost(&self) -> u64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

just a side note, early it was changed from cost to units for clarity, terms are more consistent since then, program_cost might be more intuitive now. Thanks for making change.

@@ -369,12 +369,13 @@ fn main() {
.help("deactivate this feature in genesis.")
)
.arg(
Arg::with_name("max_compute_units")
.long("max-compute-units")
Arg::with_name("max_compute_unit_limit")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why keep the "max"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought this was overriding the max compute unit limit (1.4M) that a program could use. Felt like max was appropriate here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a limit that isn't max?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think max_units turned into max_compute_units so that its use here was clear. If we take the new naming we should just keep it as compute_unit_limit

/// Number of compute units that a transaction or individual instruction is
/// allowed to consume. Compute units are consumed by program execution,
/// resources they use, etc...
pub compute_unit_limit: u64,
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't see the clarity this brings, ComputeBudget::max_units seems pretty clear, ComputeBudget::compute_unit_limit doesn't add much, at least not worth the churn it creates.

Copy link
Member Author

Choose a reason for hiding this comment

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

I feel that ComputeBudget::max_units is confusingly named because it's only the max units for a particular tx, not the whole runtime. What churn are you concerned about? Just this PR itself?

Copy link
Contributor

Choose a reason for hiding this comment

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

the budget is applied per tx.

Yeah, I was thinking about historic naming and doc churn. Don't feel too strongly opposed to the changes.

@mergify mergify bot dismissed tao-stones’s stale review May 17, 2022 17:01

Pull request has been modified.

@jstarry jstarry added the automerge Merge this Pull Request automatically once CI passes label May 17, 2022
@mergify
Copy link
Contributor

mergify bot commented May 17, 2022

automerge label removed due to a CI failure

@mergify mergify bot removed the automerge Merge this Pull Request automatically once CI passes label May 17, 2022
@jstarry jstarry merged commit a1522d0 into solana-labs:master May 18, 2022
mergify bot pushed a commit that referenced this pull request May 18, 2022
* Use consistent naming for compute unit limit

* feedback

(cherry picked from commit a1522d0)

# Conflicts:
#	runtime/src/cost_model.rs
#	runtime/src/execute_cost_table.rs
#	test-validator/src/lib.rs
#	validator/src/bin/solana-test-validator.rs
@jstarry jstarry deleted the rename-compute-unit-limit branch May 18, 2022 06:37
jstarry added a commit that referenced this pull request May 18, 2022
* Use consistent naming for compute unit limit (#25229)

* Use consistent naming for compute unit limit

* feedback

(cherry picked from commit a1522d0)

# Conflicts:
#	runtime/src/cost_model.rs
#	runtime/src/execute_cost_table.rs
#	test-validator/src/lib.rs
#	validator/src/bin/solana-test-validator.rs

* fix conflicts

Co-authored-by: Justin Starry <[email protected]>
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Jun 29, 2022
* Use consistent naming for compute unit limit

* feedback
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Jun 29, 2022
* Use consistent naming for compute unit limit

* feedback
/// default program cost, set to ComputeBudget::DEFAULT_UNITS
pub fn get_default_units(&self) -> u64 {
DEFAULT_UNITS as u64
/// default program cost, set to ComputeBudget::DEFAULT_COMPUTE_UNIT_LIMIT
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

i think this is typo. correct one would be DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT

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.

4 participants