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

metrics: metrify cache account reads #1914

Merged
merged 4 commits into from
Dec 12, 2024
Merged

Conversation

carneiro-cw
Copy link
Contributor

@carneiro-cw carneiro-cw commented Dec 12, 2024

PR Type

Enhancement


Description

  • Implemented metrics for cache account reads in the read_account function
  • Added timing measurement for the cache.get_account operation
  • Introduced debug logging when an account is found in the cache
  • These changes improve observability and performance tracking for cache operations

Changes walkthrough 📝

Relevant files
Enhancement
stratus_storage.rs
Enhance cache read account with metrics and logging           

src/eth/storage/stratus_storage.rs

  • Added metrics for cache account reads
  • Implemented timing for cache get_account operation
  • Added debug logging for when an account is found in cache
  • +4/-1     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @carneiro-cw carneiro-cw enabled auto-merge (squash) December 12, 2024 15:20
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Performance Concern
    The timed function is used to measure the duration of self.cache.get_account(address). This might introduce a small overhead. Ensure that this timing doesn't significantly impact performance, especially for frequently called operations.

    Logging Consistency
    A debug log is added when an account is found in the cache, but there's no corresponding log when it's not found. Consider adding a debug log for cache misses to maintain consistency and improve debugging capabilities.

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Prevent premature function return to ensure proper error handling

    The return statement inside the if let block will cause the function to return
    prematurely, bypassing the error handling. Consider breaking the label instead.

    src/eth/storage/stratus_storage.rs [155-160]

     if let Some(account) = timed(|| self.cache.get_account(address)).with(|m| {
         metrics::inc_storage_read_account(m.elapsed, label::CACHE, point_in_time, true);
     }) {
         tracing::debug!(storage = %label::CACHE, %address, ?account, "account found in cache");
    -    return Ok(account);
    +    break 'query account;
     };
    Suggestion importance[1-10]: 8

    Why: The suggestion correctly identifies a potential issue with error handling. Changing 'return Ok(account)' to 'break 'query account' ensures the function follows the intended control flow, allowing for proper error handling after the 'query label.

    8

    @carneiro-cw carneiro-cw disabled auto-merge December 12, 2024 15:24
    @carneiro-cw carneiro-cw enabled auto-merge (squash) December 12, 2024 15:25
    @carneiro-cw carneiro-cw changed the title Cache read account metric metrics: metrify cache account reads Dec 12, 2024
    @carneiro-cw carneiro-cw merged commit 445de14 into main Dec 12, 2024
    34 checks passed
    @carneiro-cw carneiro-cw deleted the cache_read_account_metric branch December 12, 2024 15:38
    @gabriel-aranha-cw
    Copy link
    Contributor

    Final benchmark:
    Run ID: bench-2313863306

    Git Info:

    Configuration:

    • Target Account Strategy: Default

    RPS Stats: Max: 1188.00, Min: 790.00, Avg: 955.49, StdDev: 59.98
    TPS Stats: Max: 1111.00, Min: 792.00, Avg: 925.67, StdDev: 64.90

    Plot: View Plot

    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.

    2 participants