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

v3: Add Benchmarks for Rewrite Middleware #3092

Merged
merged 1 commit into from
Jul 26, 2024
Merged

Conversation

gaby
Copy link
Member

@gaby gaby commented Jul 26, 2024

Description

  • Added Benchmarks for Rewrite Middleware
  • Added Parallel Benchmarks for Rewrite Middleware
  • Improvements to Middleware will be done in a separate PR.

Related to #3048

Changes introduced

  • Benchmarks: Describe any performance benchmarks and improvements related to the changes.

Type of change

  • Code consistency (non-breaking change which improves code reliability and robustness)

@gaby gaby added this to the v3 milestone Jul 26, 2024
@gaby gaby requested a review from a team as a code owner July 26, 2024 13:50
@gaby gaby requested review from sixcolors, ReneWerner87 and efectn and removed request for a team July 26, 2024 13:50
Copy link
Contributor

coderabbitai bot commented Jul 26, 2024

Walkthrough

The recent enhancements to the middleware's testing framework introduce comprehensive benchmarking capabilities. New benchmark functions assess the rewrite middleware's performance under various scenarios, including different return values from the Next function and the handling of rewrite rules. Additionally, parallel benchmarks simulate high-concurrency environments, allowing for a thorough evaluation of the middleware's behavior under load.

Changes

File Change Summary
middleware/rewrite/rewrite_test.go Added Benchmark_Rewrite and Benchmark_Rewrite_Parallel functions to evaluate middleware performance across various scenarios and under concurrent load.

Poem

In the land of code where rabbits dwell,
New benchmarks rise, oh what a swell!
With rewrites tested, both fast and slow,
We hop through scenarios, putting on a show.
Parallel paths in concurrency's dance,
Celebrating changes, we take our chance! 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.67%. Comparing base (0592e01) to head (b19f607).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3092   +/-   ##
=======================================
  Coverage   83.67%   83.67%           
=======================================
  Files         115      115           
  Lines        8344     8344           
=======================================
  Hits         6982     6982           
  Misses       1039     1039           
  Partials      323      323           
Flag Coverage Δ
unittests 83.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0592e01 and b19f607.

Files selected for processing (1)
  • middleware/rewrite/rewrite_test.go (2 hunks)
Additional comments not posted (12)
middleware/rewrite/rewrite_test.go (12)

175-181: Helper function createApp: Ensure proper error handling.

The helper function createApp initializes a new Fiber app with the rewrite middleware. Ensure that the function handles any potential errors during initialization.


183-201: Benchmark Case: Next always true

The benchmark case evaluates the performance when the Next function always returns true. Ensure that the benchmark accurately measures the performance and reports allocations.


203-221: Benchmark Case: Next always false

The benchmark case evaluates the performance when the Next function always returns false. Ensure that the benchmark accurately measures the performance and reports allocations.


223-238: Benchmark Case: Rewrite with tokens

The benchmark case evaluates the performance when the rewrite rules include tokens. Ensure that the benchmark accurately measures the performance and reports allocations.


240-258: Benchmark Case: Non-matching request with default route

The benchmark case evaluates the performance when a non-matching request is handled by a default route. Ensure that the benchmark accurately measures the performance and reports allocations.


260-275: Benchmark Case: Non-matching request without default route

The benchmark case evaluates the performance when a non-matching request is not handled by a default route. Ensure that the benchmark accurately measures the performance and reports allocations.


278-284: Helper function createApp: Ensure proper error handling.

The helper function createApp initializes a new Fiber app with the rewrite middleware. Ensure that the function handles any potential errors during initialization.


286-304: Parallel Benchmark Case: Next always true

The parallel benchmark case evaluates the performance when the Next function always returns true. Ensure that the benchmark accurately measures the performance and handles parallel execution correctly.


306-324: Parallel Benchmark Case: Next always false

The parallel benchmark case evaluates the performance when the Next function always returns false. Ensure that the benchmark accurately measures the performance and handles parallel execution correctly.


326-341: Parallel Benchmark Case: Rewrite with tokens

The parallel benchmark case evaluates the performance when the rewrite rules include tokens. Ensure that the benchmark accurately measures the performance and handles parallel execution correctly.


343-361: Parallel Benchmark Case: Non-matching request with default route

The parallel benchmark case evaluates the performance when a non-matching request is handled by a default route. Ensure that the benchmark accurately measures the performance and handles parallel execution correctly.


363-379: Parallel Benchmark Case: Non-matching request without default route

The parallel benchmark case evaluates the performance when a non-matching request is not handled by a default route. Ensure that the benchmark accurately measures the performance and handles parallel execution correctly.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0592e01 and b19f607.

Files selected for processing (1)
  • middleware/rewrite/rewrite_test.go (2 hunks)
Additional comments not posted (2)
middleware/rewrite/rewrite_test.go (2)

278-379: LGTM! Ensure the function usage is correct.

The code changes are approved.

However, ensure that the parallel benchmark function names are correctly used in the codebase.

Verification successful

Function usage is correct.

The Benchmark_Rewrite_Parallel function is correctly defined and not referenced elsewhere in the codebase, which is expected for a benchmark function.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the function usage in the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the correct function names.
rg --type go -A 5 $'Benchmark_Rewrite_Parallel'

Length of output: 478


175-276: LGTM! Ensure the function usage is correct.

The code changes are approved.

However, ensure that the benchmark function names are correctly used in the codebase.

Verification successful

Benchmark functions are correctly defined and used.

The benchmark functions Benchmark_Rewrite and Benchmark_Rewrite_Parallel are correctly defined and used within the middleware/rewrite/rewrite_test.go file. No issues were found regarding their usage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the function usage in the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the correct function names.
rg --type go -A 5 $'Benchmark_Rewrite'

Length of output: 895


Script:

#!/bin/bash
# Description: Verify the function usage in the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the correct function names.
rg --type go -A 5 $'Benchmark_Rewrite_Parallel'

Length of output: 478

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: b19f607 Previous: 0592e01 Ratio
Benchmark_Compress_Levels/Brotli_LevelBestCompression - B/op 7 B/op 0 B/op +∞
Benchmark_Compress_Levels/Zstd_LevelDefault - B/op 1 B/op 0 B/op +∞
Benchmark_Compress_Levels/Zstd_LevelBestCompression - B/op 1 B/op 0 B/op +∞

This comment was automatically generated by workflow using github-action-benchmark.

@ReneWerner87 ReneWerner87 merged commit 99173cc into main Jul 26, 2024
16 of 17 checks passed
@efectn efectn deleted the rewrite-benchmarks branch September 1, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants