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

bench(katana): class compilation #3010

Merged
merged 2 commits into from
Feb 11, 2025
Merged

bench(katana): class compilation #3010

merged 2 commits into from
Feb 11, 2025

Conversation

kariy
Copy link
Member

@kariy kariy commented Feb 11, 2025

Bench class compilation for the default class. This doesn't really give us a good representation of what the average compilation time for contract classes, as it depends on the size of the class itself. But it can give us a rough idea of how long it takes for an ~average size class to be compiled.

Summary by CodeRabbit

  • New Features
    • Introduced advanced benchmarking and profiling tools to enhance performance analysis.
    • Added new routines for comprehensive performance evaluation, enabling deeper insights into key process efficiencies.

Copy link

coderabbitai bot commented Feb 11, 2025

Ohayo, sensei!

Walkthrough

The changes incorporate two new dependencies, criterion and pprof, into the package configuration with the workspace flag enabled. A new benchmark configuration section has been added to the configuration file, and a benchmark module has been introduced to measure the performance of contract class compilation. This module uses the Criterion library to set up and run benchmarks, including group registration and a main entry point for benchmark execution.

Changes

File/Path Change Summary
crates/.../Cargo.toml Added criterion and pprof dependencies with workspace configuration; introduced a new benchmark section for the "class" benchmark with harness = false.
crates/.../class.rs Added a new benchmark module that uses Criterion to benchmark the ContractClass compilation; includes benchmark function, group registration, and main entry setup.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as Criterion Runner
    participant Group as Benchmark Group
    participant Func as class_compilation()
    participant FS as File System

    Runner->>Group: Start benchmark execution
    Group->>Func: Invoke class_compilation benchmark
    Func->>FS: Read contract JSON file
    FS-->>Func: Return JSON data
    Func->>Func: Parse JSON and compile ContractClass
    Func-->>Group: Return benchmark timing data
    Group-->>Runner: Report benchmark results
Loading

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6307eee and 692bd56.

📒 Files selected for processing (1)
  • crates/katana/primitives/benches/class.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/katana/primitives/benches/class.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: fmt

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/katana/primitives/benches/class.rs (1)

7-16: Nice benchmark implementation, sensei!

The benchmark setup looks good with proper use of iter_with_large_drop to prevent GC interference. However, consider adding more test cases with different class sizes to get a better performance profile.

Would you like me to help create additional benchmark cases with different contract sizes?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da76156 and 6307eee.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/katana/primitives/Cargo.toml (2 hunks)
  • crates/katana/primitives/benches/class.rs (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: ci
crates/katana/primitives/benches/class.rs

[warning] 1-1: Code formatting issue: Import statements should be on separate lines.

🔇 Additional comments (3)
crates/katana/primitives/benches/class.rs (1)

18-22: Excellent profiler configuration, sensei!

The criterion group configuration with flamegraph output will be very helpful for performance analysis. The 200ms warm-up time is a reasonable default.

crates/katana/primitives/Cargo.toml (2)

41-42: Ohayo! Nice choice of dependencies, sensei!

The addition of criterion and pprof with workspace inheritance is perfect for benchmarking needs.


57-59: Clean benchmark configuration!

The bench configuration is properly set up with harness = false as required for criterion benchmarks.

Comment on lines 1 to 6
use std::{str::FromStr, time::Duration};

use criterion::{criterion_group, criterion_main, Criterion};
use katana_primitives::class::ContractClass;
use pprof::criterion::{Output, PProfProfiler};

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ohayo sensei! Let's fix the import formatting.

The pipeline is warning about imports being on one line. Let's split them for better readability:

-use std::{str::FromStr, time::Duration};
+use std::str::FromStr;
+use std::time::Duration;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use std::{str::FromStr, time::Duration};
use criterion::{criterion_group, criterion_main, Criterion};
use katana_primitives::class::ContractClass;
use pprof::criterion::{Output, PProfProfiler};
use std::str::FromStr;
use std::time::Duration;
use criterion::{criterion_group, criterion_main, Criterion};
use katana_primitives::class::ContractClass;
use pprof::criterion::{Output, PProfProfiler};
🧰 Tools
🪛 GitHub Actions: ci

[warning] 1-1: Code formatting issue: Import statements should be on separate lines.

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.40%. Comparing base (da76156) to head (692bd56).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3010   +/-   ##
=======================================
  Coverage   56.40%   56.40%           
=======================================
  Files         431      431           
  Lines       57162    57162           
=======================================
  Hits        32242    32242           
  Misses      24920    24920           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kariy kariy merged commit 8792912 into main Feb 11, 2025
15 checks passed
@kariy kariy deleted the katana/compiled-class-bench branch February 11, 2025 20:44
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.

1 participant