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

Store Benchmark Results in Dedicated CI Branch #1172

Merged
merged 2 commits into from
Feb 28, 2025
Merged

Conversation

chacha912
Copy link
Contributor

@chacha912 chacha912 commented Feb 28, 2025

What this PR does / why we need it:

This PR changes how we store and retrieve benchmark results in our CI pipeline. Instead of using GitHub Actions cache, we now store benchmark results in a yorkie-ci-benchmark branch.

Which issue(s) this PR fixes:

Fixes #1171

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Addressed and resolved all CodeRabbit review comments
  • Didn't break anything

Summary by CodeRabbit

  • Chores
    • Revamped the CI workflow to streamline benchmark processing.
    • Enhanced the process for managing and storing benchmark results for improved reliability.
    • Refined automated testing steps to ensure more consistent performance tracking in release cycles.
    • Introduced new steps for checking out the benchmark branch and executing benchmarks in a dedicated directory.

@chacha912 chacha912 requested a review from hackerwins February 28, 2025 06:56
Copy link

coderabbitai bot commented Feb 28, 2025

Walkthrough

The CI workflow in .github/workflows/ci.yml has undergone a significant restructuring. The step for checking out the main repository has been renamed to specify a custom path. A new step has been added to check out the benchmark branch (yorkie-ci-benchmark) into a separate directory (benchmark-repo). Existing steps for building and executing benchmarks have been replaced with commands that include a directory change, and the handling of benchmark results has been revised to incorporate Git commands for committing and pushing results.

Changes

File Change Summary
.github/workflows/ci.yml - Renamed "Check out code" to "Checkout current repository" with an explicit path.
- Added "Checkout benchmark branch" to check out the yorkie-ci-benchmark branch in the benchmark-repo directory.
- Replaced previous build and benchmark steps with a directory change to repo before benchmark execution.
- Updated file reading logic and restructured the storage of benchmark results using Git.

Sequence Diagram(s)

sequenceDiagram
    participant CI as CI Workflow
    participant Main as Main Repository
    participant BM as Benchmark Repository

    CI->>Main: Checkout current repository (path: repo)
    CI->>BM: Checkout benchmark branch (branch: yorkie-ci-benchmark, path: benchmark-repo)
    CI->>CI: Change directory to repo
    CI->>CI: Execute benchmark command
    CI->>BM: Read benchmark result files from benchmark-repo
    CI->>BM: Create/update repository, add, commit, and push benchmark results
Loading

Possibly related PRs

  • Add Benchmarks for VersionVector Performance Analysis #1150: The changes in the main PR, which focus on restructuring the CI workflow for benchmarking, are related to the retrieved PR that introduces benchmark tests for the Version Vector implementation, as both involve modifications to the benchmarking process and its configuration.
  • Enhance Benchmark Results with n8n #1162: The changes in the main PR focus on restructuring the CI workflow for benchmarks, while the retrieved PR modifies the handling of benchmark results and introduces caching and webhook notifications, indicating that they are related through their shared focus on CI workflow improvements for benchmarks.

Suggested labels

enhancement 🌟

Suggested reviewers

  • hackerwins

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6065f14 and e6fb642.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (6)
.github/workflows/ci.yml (6)

112-116: Custom Checkout for Repository Directory
The "Checkout current repository" step now explicitly checks out into the repo directory. This is well aligned with subsequent steps that reference files inside the repository. Please verify that all later path references correctly point to repo now.


117-123: Benchmark Branch Checkout with Continue-on-Error
The new "Checkout benchmark branch" step checks out the yorkie-ci-benchmark branch into the benchmark-repo directory. Using continue-on-error: true allows the workflow to proceed even if this branch isn’t available. However, if the benchmark branch is expected to exist under normal circumstances, consider whether silently continuing on failure might mask issues. If the branch is intentionally optional, this setup is acceptable.


131-138: Reading Previous Benchmark Results
This conditional block safely checks for the existence of the benchmark results file and commit hash file in the benchmark-repo directory. The use of jq -R -s . ensures that any content is properly encapsulated. Just ensure that the generated JSON string is compatible with later processing.


140-142: Updated Docker Compose Stack Command
The "Stack" step now references the compose file located at repo/build/docker/docker-compose.yml, reflecting the new repository checkout path. This update appears correct, assuming the repository structure hasn’t changed elsewhere.


143-150: Bench Step Execution from Repository Subdirectory
The "Bench" step correctly changes the working directory to repo and executes make bench. Capturing the output from output.txt and formatting it with jq is a sound approach. Please ensure that make bench generates the output file at the expected location and that any errors during execution are handled if necessary.


172-195: Storing Benchmark Results into Dedicated Branch
The "Store benchmark result" step is comprehensively restructured. It:

  • Creates or ensures the existence of the benchmark-repo directory.
  • Copies the output.txt from the repository to bench_result.txt.
  • Stores the current commit SHA in commit_hash.txt.
  • Configures Git (initializing the repository if necessary and setting the remote) before adding, committing (only if there are staged changes), and force pushing to the yorkie-ci-benchmark branch.

This approach provides a clear record of benchmark results over time. Be aware that using git push -f forces updates to the branch, which is acceptable if this branch is solely managed by the CI. Consider adding additional error handling or logging if any of the Git commands fail.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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: 0

🧹 Nitpick comments (2)
.github/workflows/ci.yml (2)

131-139: Robust Previous Benchmark Retrieval & Minor Formatting
The steps to read the previous benchmark result (by checking for benchmark-repo/bench_result.txt and commit_hash.txt) are implemented correctly. A small note: line 134 appears to have trailing spaces as flagged by static analysis. Please remove these trailing spaces to meet linting standards.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 134-134: trailing spaces

(trailing-spaces)


173-197: Storing Benchmark Results with Git Integration
The "Store benchmark result" step is well structured: it creates or reuses the benchmark-repo directory, copies over the benchmark output and commit hash, and commits these changes to the appropriate branch.

A couple of suggestions:

  • Local vs Global Git Config: Instead of using git config --global, consider configuring Git locally (i.e., without the --global flag) to avoid side effects in concurrent jobs.
  • Error Handling: While the script assumes smooth execution, adding error checks after critical Git commands (e.g., after git commit and git push) could improve robustness.

For example, you might consider a diff like below to adjust the Git configuration locally:

-          git config --global user.name "GitHub Actions"
-          git config --global user.email "[email protected]"
+          git config user.name "GitHub Actions"
+          git config user.email "[email protected]"

Overall, the approach to store benchmark results in a dedicated branch is solid.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d40b3b8 and 6065f14.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (3 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/ci.yml

[error] 134-134: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (4)
.github/workflows/ci.yml (4)

112-115: Clarify Checkout Path Usage
The "Checkout current repository" step sets a custom checkout path (repo), which is clear and helps isolate the workspace. Please ensure that all subsequent steps correctly reference files relative to this new path.


117-123: Benchmark Branch Checkout & Error Handling
The new "Checkout benchmark branch" step correctly checks out the yorkie-ci-benchmark branch into the benchmark-repo directory. The use of continue-on-error: true indicates that failures here are tolerated (e.g., if the branch does not yet exist). Verify that the later steps gracefully handle a missing or incomplete checkout.


141-144: Updated Stack Command with Custom Repository Path
The "Stack" step now runs the Docker Compose command using the repo directory (i.e., repo/build/docker/docker-compose.yml). This change is consistent with the new checkout path, but please double-check that any dependencies or file references in the Docker Compose file are updated accordingly.


144-151: Bench Step Execution in Isolated Directory
The "Bench" step changes into the repo directory, executes the benchmark via make bench, and processes the output file correctly. Ensure that the command generates output.txt in the expected location and that using jq to capture the result works reliably in all environments.

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 38.28%. Comparing base (d40b3b8) to head (e6fb642).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1172   +/-   ##
=======================================
  Coverage   38.28%   38.28%           
=======================================
  Files         171      171           
  Lines       25775    25775           
=======================================
  Hits         9867     9867           
  Misses      15075    15075           
  Partials      833      833           

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

@hackerwins hackerwins changed the title Store benchmark results in branch Store Benchmark Results in Dedicated CI Branch Feb 28, 2025
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

@hackerwins hackerwins merged commit c7797cf into main Feb 28, 2025
5 checks passed
@hackerwins hackerwins deleted the fix-bench-result branch February 28, 2025 09:00
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.

Benchmark cache not updating in CI
2 participants