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

Enhance Benchmark Results with n8n #1162

Merged
merged 1 commit into from
Feb 20, 2025
Merged

Enhance Benchmark Results with n8n #1162

merged 1 commit into from
Feb 20, 2025

Conversation

chacha912
Copy link
Contributor

@chacha912 chacha912 commented Feb 20, 2025

What this PR does / why we need it:

This PR improves the readability of benchmark test results to help developers easily understand performance metrics and make more efficient development decisions.

Before(github-action-benchmark) After(n8n workflow)
image image
image image

The workflow now sends benchmark results from GitHub Actions to N8n, where the data is processed/analyzed before adding comments to the PR in GitHub.

n8n workflow
image

Key improvements:

  • Separated tables by test categories
  • Highlighted significant changes in performance (> 20% differences)
  • Converted units to more readable formats:
    • Time: converted ns to ms, s where appropriate
    • Memory: converted B to KB, MB, GB
  • Added comparative analysis with Lamport version performance when VV benchmark performance differs significantly

Which issue(s) this PR fixes:

Fixes #1151

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

Summary by CodeRabbit

  • Chores
    • Enhanced management of performance benchmark data through caching for more reliable and consistent metric reporting.
    • Introduced proactive webhook notifications for benchmark updates, including improved error handling for smoother performance tracking.

@chacha912 chacha912 requested a review from hackerwins February 20, 2025 04:56
Copy link

coderabbitai bot commented Feb 20, 2025

Walkthrough

This pull request updates the CI workflow by modifying the bench job. It replaces the previous benchmark data download step with a cache setup step, removes the old benchmark result storing step, and adds a new step to read benchmark results from the cache by checking for necessary files. Additionally, it introduces a webhook trigger to n8n with error handling for sending both current and previous benchmark data along with repository and pull request details. Finally, it adds a step to store the benchmark result to the cache when running on the main branch.

Changes

File Change Summary
.github/workflows/ci.yml Updated the bench job: replaced the benchmark download step with cache setup, removed the storing step, added a step to read previous benchmark results using file existence checks, introduced a webhook trigger to n8n with error handling, and added a step to store benchmark results to cache on main.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as CI Runner
    participant Cache as Benchmark Cache
    participant Webhook as n8n Endpoint

    Runner->>Cache: Check for benchmark result & commit hash files
    Cache-->>Runner: Return file existence status
    Runner->>Runner: Set output variables based on cache
    Runner->>Webhook: Trigger webhook with current & previous benchmark data, repo, and PR info
    Webhook-->>Runner: Return acknowledgement/error
    alt Branch is `main`
        Runner->>Cache: Save benchmark result and commit hash files
    end
Loading

Possibly related PRs

  • Fine-tune CI Workflows in PR #964: The changes in the main PR focus on restructuring the bench job in the CI workflow, while the retrieved PR also modifies the bench job but introduces a new job for target checks and optimizes job execution based on file changes.
  • [Revised] Fine-tuned CI Workflows in PR #965: The changes in the main PR regarding the CI workflow's bench job and caching mechanisms are related to the modifications in the retrieved PR that also involve updates to the bench job's execution conditions based on the new ci-target-check job.

Suggested labels

enhancement 🌟

Suggested reviewers

  • hackerwins

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. (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.

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.

@chacha912 chacha912 marked this pull request as ready for review February 20, 2025 04:56
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 (4)
.github/workflows/ci.yml (4)

121-126: Caching Step Version Review
The "Set up cache" step uses actions/cache@v3, but a static analysis hint indicates that this runner version might be outdated. Please verify whether a newer version is available (or if this warning is a false positive) and update accordingly to ensure optimal compatibility with GitHub Actions.

🧰 Tools
🪛 actionlint (1.7.4)

122-122: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


127-144: Ensure Consistent Outputs in Cache Read Step
In the "Read previous benchmark result" step, when ./cache/bench_result.txt is missing, only the PREV_BENCH_RESULT output is set to "null". This leaves the PREV_COMMIT output undefined, which may cause issues in subsequent steps (for example, during webhook payload formation). Consider modifying the else block to also output PREV_COMMIT=null for consistency. For example:

-          else
-            echo "PREV_BENCH_RESULT=null" >> $GITHUB_OUTPUT
-          fi
+          else
+            echo "PREV_BENCH_RESULT=null" >> $GITHUB_OUTPUT
+            echo "PREV_COMMIT=null" >> $GITHUB_OUTPUT
+          fi

145-165: Webhook Trigger Robustness and Error Handling
The "Trigger n8n webhook" step gathers the current benchmark result from output.txt and posts the payload to the webhook URL. To enhance robustness, consider:

  • Adding a check to verify that output.txt exists before attempting to read it.
  • Logging the full response (or additional error details) from the curl command to aid in troubleshooting when the webhook fails. For example:
-          curr_bench=$(cat output.txt | jq -R -s .)
+          if [ -f output.txt ]; then
+            curr_bench=$(cat output.txt | jq -R -s .)
+          else
+            echo "::error::output.txt not found"
+            exit 1
+          fi

This addition will ensure that the step fails gracefully with clearer error messaging.


166-171: Cache Storage Step Commentary
The "Store benchmark result to cache" step correctly creates the cache directory and saves both the benchmark result and the commit hash when the branch is main. Consider reviewing whether any stale cache files need to be purged to prevent data accumulation over time.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 900dc45 and d7e451b.

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

122-122: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 38.56%. Comparing base (900dc45) to head (2884059).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1162   +/-   ##
=======================================
  Coverage   38.56%   38.56%           
=======================================
  Files         170      170           
  Lines       25441    25441           
=======================================
  Hits         9812     9812           
  Misses      14808    14808           
  Partials      821      821           

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

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 (4)
.github/workflows/ci.yml (4)

118-124: Benchmark Execution Step – Consider Enabling Strict Error Handling
The "Bench" step correctly runs make bench and processes the output from output.txt. To improve robustness, consider adding an explicit set -e (or error checking) at the start of the multi-line script so that any failure (for example, if output.txt is missing) causes the step to exit immediately.

Proposed diff:

-run: |
-  make bench
-  content=$(cat output.txt | jq -R -s .)
-  echo "BENCH_RESULT=$content" >> $GITHUB_OUTPUT
+run: |
+  set -e
+  make bench
+  if [ ! -f output.txt ]; then
+    echo "Error: output.txt not found" && exit 1
+  fi
+  content=$(cat output.txt | jq -R -s .)
+  echo "BENCH_RESULT=$content" >> $GITHUB_OUTPUT

125-130: Update Actions/Cache Version
The step "Set up cache" uses actions/cache@v3, but static analysis indicates that this version is outdated. Upgrading to a newer version (for example, actions/cache@v4 if available) may offer improved performance and compatibility with the latest GitHub Actions features.

Proposed diff:

-        uses: actions/cache@v3
+        uses: actions/cache@v4
🧰 Tools
🪛 actionlint (1.7.4)

126-126: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


131-147: Cache Reading Step – Remove Trailing Whitespace
The "Read previous benchmark result" step correctly checks for cached benchmark files and sets the appropriate output variables. Note that static analysis detected trailing spaces on line 141. Please remove these to adhere to YAML lint standards.

Proposed diff for line 141 (removing trailing spaces):

-            
+  
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 141-141: trailing spaces

(trailing-spaces)


148-168: Webhook Trigger Step – Enhance Debug Information
The "Trigger n8n webhook" step sends benchmark data to the webhook with basic error handling by checking for the "CURL_ERROR" string. While this approach is functionally acceptable, consider logging additional debug information (such as the HTTP status code or response body) when the webhook fails. This extra detail can be very helpful during troubleshooting.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d7e451b and 2884059.

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

126-126: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.35.1)
.github/workflows/ci.yml

[error] 141-141: trailing spaces

(trailing-spaces)

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

169-175: Benchmark Cache Storage Step – Looks Good
This step correctly caches the benchmark results and commit hash on the main branch. The implementation is straightforward and meets its intended purpose.

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 changed the title Update CI to store benchmark results in main and send to n8n from PR Enhance Benchmark Results with n8n Feb 20, 2025
@hackerwins hackerwins merged commit 30911b2 into main Feb 20, 2025
5 checks passed
@hackerwins hackerwins deleted the enhance-benchmark branch February 20, 2025 07:39
hackerwins pushed a commit that referenced this pull request Feb 20, 2025
Improves visibility of performance metrics by storing benchmark results
from main branch and forwarding PR comparisons to n8n. Added automated
unit conversion, categorized result tables, and performance difference
highlighting to facilitate data-driven development decisions.
hackerwins pushed a commit that referenced this pull request Feb 20, 2025
Improves visibility of performance metrics by storing benchmark results
from main branch and forwarding PR comparisons to n8n. Added automated
unit conversion, categorized result tables, and performance difference
highlighting to facilitate data-driven development decisions.
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.

Enhance Benchmark Test Result Visualization
2 participants