-
Notifications
You must be signed in to change notification settings - Fork 659
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
feat: Add metrics to measure compiled-contract cache hits/misses for chunk production vs. chunk validation. #11178
Merged
Merged
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1f8cff8
Initial commit.
tayfunelmas 11e66e1
Connect pieces second commit.
tayfunelmas deccb30
Move reason to primitives and not use string.
tayfunelmas 162e583
Merge branch 'master' into compile-metric
tayfunelmas 005cde2
Change string to ApplyChunkReason in ApplyState
tayfunelmas eec1b28
Address clippy findings.
tayfunelmas 7436146
Merge branch 'master' into compile-metric
tayfunelmas c3e8ccd
Merge branch 'master' into compile-metric
tayfunelmas 4347216
Remove apply_reason from VContext and use exported Metrics structure …
tayfunelmas 9857410
fix clippy errors and format
tayfunelmas 15d66a9
Add one more cache hit record.
tayfunelmas b4dfbf1
Merge hit and miss functions and also move metrics.record to record o…
tayfunelmas 7beb96d
Address comments v1
tayfunelmas d975a96
Make reset and report operations static
tayfunelmas 292b613
Set the metric correctly to consider memory and disk cache
tayfunelmas 35f9ec9
Merge branch 'master' into compile-metric
tayfunelmas 565dd0c
Remove extra call to record_compiled_contract_cache_lookup
tayfunelmas a68c34e
Merge branch 'compile-metric' of https://github.com/tayfunelmas/nearc…
tayfunelmas e720ebd
Merge branch 'master' into compile-metric
tayfunelmas 60617ad
Merge branch 'master' into compile-metric
tayfunelmas 17f0a9b
Merge branch 'master' into compile-metric
tayfunelmas 21886bf
Merge branch 'master' into compile-metric
tayfunelmas 7d60706
Add instrumentation to enable record_compiled_contract_cache_lookup f…
tayfunelmas b129a73
Also add x86_64 annotation to skip MacOS tests (the codepath is not e…
tayfunelmas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::fmt::{Display, Formatter}; | ||
|
||
/// Indicates the phase of block production the apply-chunk operation is invoked. | ||
/// This is currently used to analyze and compare the metrics collected while applying the receipts | ||
/// for different purposes, eg. while updating state of a tracked shard vs. validating a chunk. | ||
/// TODO: Consider combining ApplyChunkReason, ApplyChunkBlockContext, and ApplyChunkBlockContext | ||
/// under a common wrapper struct such as ApplyChunkContext. | ||
#[derive(Clone, Debug)] | ||
pub enum ApplyChunkReason { | ||
/// Apply-chunk is invoked to update the state of a shards being tracked. | ||
UpdateTrackedShard, | ||
/// Apply-chunk is invoked to validate the state witness for a shard in the context of stateless validation. | ||
ValidateChunkStateWitness, | ||
} | ||
|
||
impl ApplyChunkReason { | ||
/// Returns a static, short string representation of the reason, to be used for metrics. | ||
pub fn as_str(&self) -> &'static str { | ||
match self { | ||
ApplyChunkReason::UpdateTrackedShard => "update_shard", | ||
ApplyChunkReason::ValidateChunkStateWitness => "validate_chunk", | ||
} | ||
} | ||
} | ||
|
||
impl Display for ApplyChunkReason { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { | ||
f.write_str(self.as_str()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use a
usize
that counts the count. It is less error prone this way (e.g. what happens if the code is adjusted to access the cache multiple times?)It might also solve your concerns with double counting if we make
fn report
operate on the value inside the TLS... So we would change the return value ofrun
back to only return an VMResult, and then changefn report
to be a static method or something that we would operate on the TLS value much like the increment functions do.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I like that. I changed
report
to a static function (renamed toreport_metrics
) and also renamedreset
toreset_metrics
. And callingreset_metrics
andreport_metrics
once in the VM runner (outside of VM.run). PTAL.