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

feature: Get compute usage from profile #8783

Merged
merged 1 commit into from
Mar 24, 2023

Conversation

aborg-dev
Copy link
Contributor

@aborg-dev aborg-dev commented Mar 23, 2023

This seemed like the simplest approach that introduced minimal runtime overhead and code changes (as opposed to introducing a dedicated field in the GasCounter). Happy to consider the alternatives though.

Part of #8032

Some follow-up work is planned in #8795

@aborg-dev aborg-dev added the A-contract-runtime Area: contract compilation and execution, virtual machines, etc label Mar 23, 2023
@aborg-dev aborg-dev requested a review from jakmeier March 23, 2023 11:36
@aborg-dev aborg-dev requested a review from a team as a code owner March 23, 2023 11:36
@aborg-dev aborg-dev force-pushed the compute_costs_counter branch from a3c3937 to f98b98c Compare March 23, 2023 11:40
Copy link
Contributor

@jakmeier jakmeier 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. Going through gas profiles seems like the best way to me, too. For actions, we will either have to make profiles more general, or perhaps add the compute cost counter for it (on the receipt level) after all.

Just one question, is there a way we can ensure the values in the gas profile are always the same as in the gas counter? Because today profiles are a mere debug tool and we wouldn't necessarily know it it is slightly wrong in some cases. But once compute cost limits are fully implemented, this makes it part of the protocol specification. Any bugs we would find later would require a protocol update to fix.

core/primitives-core/src/profile.rs Outdated Show resolved Hide resolved
core/primitives-core/src/profile.rs Show resolved Hide resolved
@aborg-dev aborg-dev force-pushed the compute_costs_counter branch from f98b98c to fb40310 Compare March 24, 2023 12:44
@aborg-dev
Copy link
Contributor Author

aborg-dev commented Mar 24, 2023

Just one question, is there a way we can ensure the values in the gas profile are always the same as in the gas counter? Because today profiles are a mere debug tool and we wouldn't necessarily know it it is slightly wrong in some cases. But once compute cost limits are fully implemented, this makes it part of the protocol specification. Any bugs we would find later would require a protocol update to fix.

I've added a test in gas_counter.rs that verifies that the compute usage in Profile agrees with the burnt gas in the counter. Another way to achieve this would be to track the counters in the gas counter itself and them export them to Profile and to Compute Usage calculation. That probably is a cleaner solution in the long-run, though requires more work. I'll see if I can reuse/replace EXT_COSTS_COUNTER while doing this.

Will file an Issue to track this work.
UPD: I've filed an issue for this #8795.

This seemed like the simplest approach that introduces minimal overhead
and code changes (as opposed to introducing a dedicated field in the
GasCounter).

Some follow-up work is planned in near#8795
@aborg-dev aborg-dev force-pushed the compute_costs_counter branch from 1e846b1 to 7e2610d Compare March 24, 2023 13:27
@near-bulldozer near-bulldozer bot merged commit b2f617f into near:master Mar 24, 2023
nikurt pushed a commit to nikurt/nearcore that referenced this pull request Apr 5, 2023
This seemed like the simplest approach that introduced minimal runtime overhead and code changes (as opposed to introducing a dedicated field in the GasCounter). Happy to consider the alternatives though.

Part of near#8032

Some follow-up work is planned in near#8795
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contract-runtime Area: contract compilation and execution, virtual machines, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants