10000 feat: Add an impl for ProfileData and add it as an option to ApplyState by willemneal · Pull Request #3730 · near/nearcore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Add an impl for ProfileData and add it as an option to ApplyState #3730

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

Merged
merged 67 commits into from
Jan 14, 2021

Conversation

willemneal
Copy link
Contributor

This change will allow the simulator to pass a profile data reference via ApplyState to get the break down of how gas was spent.

Currently this means only function calls are profiled, not view calls because the ViewApplyState is in the primitives crate, while ProfileData and ApplyState are in the near-vm-logic crate. A future PR that reorganizes these core types will allow adding the profile data to ViewApplyState.

Willem Wyndham added 30 commits October 28, 2020 10:17
CLion betrayed me
Also updated profile data to include all of the gas so that it can be used to print debug info
was having difficulty in other projects not seeing clone method on type alias.
@@ -27,8 +27,10 @@ pub fn run<'a>(
promise_results: &'a [PromiseResult],
current_protocol_version: ProtocolVersion,
cache: Option<&'a dyn CompiledContractCache>,
#[allow(unused_variables)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this variable not guarded by the feature flag?

) -> (Option<VMOutcome>, Option<VMError>) {
#[cfg(feature = "costs_counting")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we do this why do we not put the function argument behind a feature flag so that we don't have to do something like #[allow(unused_variables)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the caller always passes the parameter since it's in ApplyState and by default is None, but we only use it when the feature is on.

Making the parameter be behind the feature would require moving each call behind a feature flag too. Is this what you want?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It sounds like a good idea. For example on-disk compilation cache introduced a few unwanted changes. Hiding a feature behind a flag makes it safer for non-prod changes.

@@ -457,6 +457,7 @@ impl NightshadeRuntime {
cache: Some(Arc::new(StoreCompiledContractCache { store: self.store.clone() })),
#[cfg(feature = "protocol_feature_evm")]
evm_chain_id: self.evm_chain_id(),
profile: None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's wrap profile field in the ApplyState as well with a feature.

@willemneal willemneal merged commit e2e6bd6 into master Jan 14, 2021
@willemneal willemneal deleted the feat_add_profile branch January 14, 2021 17:12
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.

5 participants
0