Skip to content

Add gzip middleware support for gpx, +xml #227

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

Merged
merged 1 commit into from
Apr 22, 2025
Merged

Add gzip middleware support for gpx, +xml #227

merged 1 commit into from
Apr 22, 2025

Conversation

vearutop
Copy link
Member

No description provided.

Copy link

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 115 9035 (+2) 6527 (+1) 673 1835 (+1) 1074 (+1) 220.5K (+60B)

Copy link

Go API Changes

# summary
Inferred base version: v0.2.73
Suggested version: v0.2.74

Copy link

Unit Test Coverage

total: (statements) 80.6%
changed lines: (statements) 0.0%, coverage is less than 90.0%, consider testing the changes more thoroughly

Coverage of changed lines
File Function Coverage
Total 0.0%
response/gzip/middleware.go 0.0%
response/gzip/middleware.go:155 writeHeader 0.0%
_examples/advanced-generic-openapi31/raw_body.go no coverage
Coverage diff with base branch

No changes in coverage.

Copy link

@llamapreview llamapreview bot left a comment

Choose a reason for hiding this comment

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

Auto Pull Request Review from LlamaPReview

1. Overview

1.1 Core Changes

  • Primary purpose and scope: The PR aims to enhance the existing gzip response middleware in the swaggest/rest library to include support for compressing responses with application/gpx+xml and generally any content type ending in +xml. This is intended to improve performance by reducing bandwidth usage for XML-based responses.
  • Key components modified: The primary file modified is response/gzip/middleware.go, which contains the logic for determining which content types are compressed by default. Additionally, a cosmetic change was made in _examples/advanced-generic-openapi31/raw_body.go.
  • Cross-component impacts: The change is localized within the gzip middleware component and does not introduce new architectural patterns or significant dependencies. It interacts with standard Go net/http interfaces.
  • Business value alignment: The PR directly implements the requirement stated in the title: adding gzip support for gpx and +xml. This change is expected to improve performance by reducing bandwidth usage for XML-based responses, which can be beneficial for both server costs and user experience.

1.2 Technical Architecture

  • System design modifications: The change modifies the behavior of an existing middleware layer. It does not introduce new architectural patterns or significant dependencies.
  • Component interaction changes: The middleware intercepts the response writer. Based on the Content-Type header set by the downstream handler and the Accept-Encoding header from the request, it decides whether to wrap the original writer with a gzip writer.
  • Integration points impact: The change is localized within the gzip middleware component and does not affect other integration points.
  • Dependency changes and implications: No new dependencies are introduced. The change relies on the strings package for content type checks.

2. Critical Findings

2.1 Must Fix (P0🔴)

No critical issues identified.

2.2 Should Fix (P1🟡)

Issue: Lack of specific test coverage for +xml content types.

  • Analysis Confidence: High
  • Impact: The PR changes default behavior for a new category of content types, but no tests are added to verify this new behavior (compression applied correctly for +xml, not applied when the client doesn't support it, etc.). This increases the risk of regressions or unexpected interactions.
  • Suggested Solution: Add test cases to response/gzip/middleware_test.go to verify that responses with application/gpx+xml or other +xml types are correctly compressed when the client accepts gzip, and not compressed otherwise.

Issue: Documentation update needed for the change in default behavior regarding +xml.

  • Analysis Confidence: High
  • Impact: Users of the middleware need to be aware that +xml responses will now be compressed by default. This should be clearly documented to inform users of the change.
  • Suggested Solution: Update the documentation for the gzip middleware to explicitly mention that +json and +xml content types are compressed by default unless otherwise configured or disabled by the handler.

2.3 Consider (P2🟢)

Area: Content type parameter handling in the explicit switch statement.

  • Analysis Confidence: Medium
  • Improvement Opportunity: The switch statement checks the full content type string, including parameters like ; charset=utf-8. This can lead to slight inconsistency and potential bugs if an explicit type is used with parameters. A more robust approach would be to check only the MIME type part before any parameters.

Area: Compression threshold.

  • Analysis Confidence: Low
  • Improvement Opportunity: Compressing very small responses can sometimes result in a slightly larger output or add unnecessary CPU overhead. A common optimization in gzip middleware is to only compress responses above a certain minimum size (e.g., 1KB). This could be considered for the middleware overall.

Area: Explicitness vs. suffix rule.

  • Analysis Confidence: Low
  • Improvement Opportunity: The PR adds application/gpx+xml explicitly and adds the +xml suffix rule. The suffix rule covers application/gpx+xml anyway. While adding it explicitly doesn't hurt, it's slightly redundant. The choice between listing common types explicitly vs. relying solely on the suffix rule is a design decision.

2.4 Summary of Action Items

  1. Must Fix (P0🔴): None
  2. Should Fix (P1🟡):
    • Add specific test cases for +xml content types.
    • Update documentation to reflect the change in default behavior for +xml content types.
  3. Consider (P2🟢):
    • Refactor content type check to handle parameters more robustly.
    • Consider adding a compression threshold.
    • Review the explicitness vs. suffix rule for content types.

3. Technical Analysis

3.1 Code Logic Analysis

📁 response/gzip/middleware.go - ServeHTTP

  • Submitted PR Code:
    switch ct {
        // ... existing explicit types ...
        "application/gpx+xml":
        "application/geo+json":
    default:
        if !strings.HasSuffix(ct, "+json") && !strings.HasSuffix(ct, "+xml") {
            rw.disableCompression = true
        }
    }
  • Analysis:
    • Current logic and potential issues: The code snippet is part of the middleware's ServeHTTP method, executed after the downstream handler has written headers but before it writes the body. The switch statement checks if ct matches a list of explicitly defined compressible types. The default case is reached if ct is not in the explicit list. Inside the default case, compression is disabled if the content type does not end with +json AND +xml. This means compression is enabled by default for explicit types and for any type ending in +json or +xml that isn't explicitly listed.
    • Edge cases and error handling: The change itself doesn't introduce new error handling paths. The existing middleware should handle potential gzip writing errors. Edge cases like missing Content-Type are handled reasonably by the existing default logic (compression disabled).
    • Cross-component impact: The change is localized within the gzip middleware component and does not affect other components.
    • Business logic considerations: The logic correctly identifies the target content types for compression based on the title's requirement.
  • LlamaPReview Suggested Improvements:
    // Inside ServeHTTP, before the switch
    ctWithoutParams := ct
    if idx := strings.Index(ct, ";"); idx != -1 {
        ctWithoutParams = ct[:idx]
    }

    // Use ctWithoutParams in the switch
    switch ctWithoutParams {
        // ... existing explicit types ...
        "application/gpx+xml": // This will now match "application/gpx+xml; charset=utf-8"
        "application/geo+json":
    default:
        // The suffix check still works correctly on the original ct string
        if !strings.HasSuffix(ct, "+json") && !strings.HasSuffix(ct, "+xml") {
            rw.disableCompression = true
        }
    }
  • Improvement rationale:
    • Technical benefits: Makes the explicit content type matching more robust and aligned with standard MIME type handling.
    • Business value: Increased reliability of the middleware.
    • Risk assessment: Low risk, as it refactors existing logic to handle a pre-existing potential issue.

3.2 Key Quality Aspects

  • System scalability considerations: The middleware adds a per-request processing overhead (compression). This scales linearly with request volume and the proportion of compressible +xml responses. It does not introduce inherent bottlenecks.
  • Performance bottlenecks and optimizations: The change is expected to improve performance by reducing bandwidth usage for XML-based responses. However, it may slightly increase server CPU load due to compression.
  • Testing strategy and coverage: The PR does not include new tests specifically for +xml content types. This is a gap in coverage for the new behavior.
  • Documentation needs: The change in default behavior for +xml content types is not documented. This should be clearly documented to inform users of the change.

4. Overall Evaluation

  • Technical assessment: The core logic change is correct and aligns with the PR title. It enhances the middleware's utility by covering common XML formats.
  • Business impact: The change is expected to improve performance by reducing bandwidth usage for XML-based responses, which can be beneficial for both server costs and user experience.
  • Risk evaluation: The main risk is the lack of specific test coverage for the new behavior. This should be addressed before merging.
  • Notable positive aspects and good practices: The PR is a small, focused change that directly addresses the requirement stated in the title.
  • Implementation quality: The code change is minimal and directly addresses the requirement. The logic is clear and follows the existing pattern.
  • Final recommendation: Request Changes. The PR should be merged once specific tests for +xml compression are added and the documentation is updated.

💡 LlamaPReview Community
Have feedback on this AI Code review tool? Join our GitHub Discussions to share your thoughts and help shape the future of LlamaPReview.

Copy link

Benchmark Result

Benchmark diff with base branch
name                                    old time/op    new time/op    delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4    1.15µs ± 3%    1.14µs ± 0%    ~     (p=0.571 n=5+5)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                           600ns ± 4%     590ns ± 0%  -1.64%  (p=0.032 n=5+4)
DecoderFunc_Decode-4                      1.69µs ± 3%    1.66µs ± 0%    ~     (p=0.460 n=5+5)
Decoder_Decode_json-4                     18.6µs ± 1%    18.8µs ± 1%    ~     (p=0.222 n=5+5)
Decoder_Decode_queryObject-4              4.04µs ± 2%    4.05µs ± 1%    ~     (p=0.381 n=5+5)
Decoder_Decode_jsonParam-4                1.54µs ± 1%    1.54µs ± 1%    ~     (p=0.683 n=5+5)
DecoderFactory_SetDecoderFunc-4           1.34µs ± 0%    1.34µs ± 0%  +0.34%  (p=0.032 n=5+5)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                              8.67µs ± 2%    8.64µs ± 4%    ~     (p=0.310 n=5+5)
Middleware_control-4                      2.80µs ± 1%    2.71µs ± 1%  -3.05%  (p=0.008 n=5+5)

name                                    old alloc/op   new alloc/op   delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4    2.46kB ± 0%    2.46kB ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                            440B ± 0%      440B ± 0%    ~     (all equal)
DecoderFunc_Decode-4                      1.53kB ± 0%    1.53kB ± 0%    ~     (all equal)
Decoder_Decode_json-4                     12.4kB ± 0%    12.4kB ± 0%    ~     (all equal)
Decoder_Decode_queryObject-4              2.01kB ± 0%    2.01kB ± 0%    ~     (p=1.000 n=5+5)
Decoder_Decode_jsonParam-4                  736B ± 0%      736B ± 0%    ~     (all equal)
DecoderFactory_SetDecoderFunc-4           1.02kB ± 0%    1.02kB ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                              1.19kB ± 3%    1.18kB ± 3%    ~     (p=0.500 n=5+5)
Middleware_control-4                      11.1kB ± 0%    11.1kB ± 0%    ~     (all equal)

name                                    old allocs/op  new allocs/op  delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4      8.00 ± 0%      8.00 ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                            4.00 ± 0%      4.00 ± 0%    ~     (all equal)
DecoderFunc_Decode-4                        12.0 ± 0%      12.0 ± 0%    ~     (all equal)
Decoder_Decode_json-4                        177 ± 0%       177 ± 0%    ~     (all equal)
Decoder_Decode_queryObject-4                38.0 ± 0%      38.0 ± 0%    ~     (all equal)
Decoder_Decode_jsonParam-4                  12.0 ± 0%      12.0 ± 0%    ~     (all equal)
DecoderFactory_SetDecoderFunc-4             16.0 ± 0%      16.0 ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                                11.0 ± 0%      11.0 ± 0%    ~     (all equal)
Middleware_control-4                        8.00 ± 0%      8.00 ± 0%    ~     (all equal)
Benchmark result
name                                    time/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4  1.14µs ± 0%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                         590ns ± 0%
DecoderFunc_Decode-4                    1.66µs ± 0%
Decoder_Decode_json-4                   18.8µs ± 1%
Decoder_Decode_queryObject-4            4.05µs ± 1%
Decoder_Decode_jsonParam-4              1.54µs ± 1%
DecoderFactory_SetDecoderFunc-4         1.34µs ± 0%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                            8.64µs ± 4%
Middleware_control-4                    2.71µs ± 1%

name                                    alloc/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4  2.46kB ± 0%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                          440B ± 0%
DecoderFunc_Decode-4                    1.53kB ± 0%
Decoder_Decode_json-4                   12.4kB ± 0%
Decoder_Decode_queryObject-4            2.01kB ± 0%
Decoder_Decode_jsonParam-4                736B ± 0%
DecoderFactory_SetDecoderFunc-4         1.02kB ± 0%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                            1.18kB ± 3%
Middleware_control-4                    11.1kB ± 0%

name                                    allocs/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4    8.00 ± 0%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                          4.00 ± 0%
DecoderFunc_Decode-4                      12.0 ± 0%
Decoder_Decode_json-4                      177 ± 0%
Decoder_Decode_queryObject-4              38.0 ± 0%
Decoder_Decode_jsonParam-4                12.0 ± 0%
DecoderFactory_SetDecoderFunc-4           16.0 ± 0%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                              11.0 ± 0%
Middleware_control-4                      8.00 ± 0%

@vearutop vearutop merged commit 9aeecc2 into master Apr 22, 2025
9 checks passed
@vearutop vearutop deleted the gzip-xml branch April 22, 2025 15:30
Copy link

Examples Benchmark Result

Benchmark diff with base branch
name                       old time/op    new time/op    delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                17.6µs ± 9%    17.4µs ± 9%     ~     (p=0.841 n=5+5)
_directGzipHead-4            17.1µs ± 3%    16.8µs ± 1%     ~     (p=0.222 n=5+5)
_noDirectGzip-4               107µs ± 1%     106µs ± 1%   -1.56%  (p=0.008 n=5+5)
_directGzip_decode-4          339µs ± 2%     333µs ± 1%     ~     (p=0.056 n=5+5)
_noDirectGzip_decode-4        107µs ± 2%     107µs ± 2%     ~     (p=0.310 n=5+5)
_jsonBody-4                  36.8µs ± 5%    36.0µs ± 1%   -2.21%  (p=0.032 n=5+5)
_jsonBodyValidation-4        40.2µs ± 1%    40.7µs ± 2%     ~     (p=0.056 n=5+5)
_outputHeaders-4             16.9µs ± 2%    17.1µs ± 1%     ~     (p=0.056 n=5+5)
_requestResponseMapping-4    34.1µs ± 1%    34.5µs ± 2%     ~     (p=0.310 n=5+5)
_validation-4                37.0µs ± 2%    37.3µs ± 2%     ~     (p=0.421 n=5+5)
_noValidation-4              26.1µs ± 1%    26.5µs ± 1%     ~     (p=0.056 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4           20.1µs ± 2%    20.9µs ±10%     ~     (p=0.056 n=5+5)
_formOrJSON/json-4           23.5µs ± 8%    23.5µs ± 1%     ~     (p=0.310 n=5+5)
_directGzip-4                17.0µs ± 1%    17.3µs ± 2%   +1.98%  (p=0.008 n=5+5)
_directGzipHead-4            17.2µs ± 4%    18.0µs ± 4%     ~     (p=0.151 n=5+5)
_noDirectGzip-4              95.3µs ± 1%    95.9µs ± 1%     ~     (p=0.151 n=5+5)
_htmlResponse-4              31.3µs ± 2%    30.7µs ± 1%     ~     (p=0.056 n=5+5)
_jsonBodyManual-4            21.9µs ± 1%    22.0µs ± 1%     ~     (p=0.690 n=5+5)
_jsonBody-4                  33.0µs ± 2%    32.9µs ± 2%     ~     (p=0.310 n=5+5)
_jsonBodyValidation-4        41.7µs ± 1%    41.6µs ± 1%     ~     (p=0.690 n=5+5)
_outputHeaders-4             30.0µs ± 1%    30.4µs ± 1%     ~     (p=0.056 n=5+5)
_requestResponseMapping-4    34.9µs ± 1%    35.2µs ± 1%     ~     (p=0.056 n=5+5)
_validation-4                37.8µs ± 1%    38.0µs ± 2%     ~     (p=0.222 n=5+5)
_noValidation-4              27.1µs ± 2%    27.1µs ± 1%     ~     (p=0.421 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4               19.9µs ± 0%    19.8µs ± 0%     ~     (p=0.056 n=5+5)
_ok-4                        20.0µs ± 5%    19.8µs ± 1%     ~     (p=1.000 n=5+5)
_invalidBody-4               28.7µs ± 4%    28.8µs ± 4%     ~     (p=0.690 n=5+5)

name                       old 50%:ms     new 50%:ms     delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  0.75 ± 5%      0.75 ± 4%     ~     (p=0.841 n=5+5)
_directGzipHead-4              0.75 ± 4%      0.74 ± 0%     ~     (p=0.905 n=5+4)
_noDirectGzip-4                4.73 ± 2%      4.74 ± 3%     ~     (p=1.000 n=5+5)
_directGzip_decode-4           11.6 ± 6%      11.0 ± 6%     ~     (p=0.310 n=5+5)
_noDirectGzip_decode-4         4.75 ± 3%      5.01 ± 8%     ~     (p=0.151 n=5+5)
_jsonBody-4                    1.54 ± 3%      1.53 ± 6%     ~     (p=1.000 n=5+5)
_jsonBodyValidation-4          1.65 ± 1%      1.68 ± 5%     ~     (p=0.690 n=5+5)
_outputHeaders-4               0.74 ± 8%      0.74 ± 4%     ~     (p=0.690 n=5+5)
_requestResponseMapping-4      1.42 ± 4%      1.39 ± 6%     ~     (p=0.571 n=5+5)
_validation-4                  1.54 ± 4%      1.59 ± 6%     ~     (p=0.222 n=5+5)
_noValidation-4                1.10 ± 6%      1.12 ± 6%     ~     (p=0.548 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             0.90 ± 4%      0.87 ± 6%     ~     (p=0.690 n=5+5)
_formOrJSON/json-4             0.99 ± 3%      0.97 ± 4%     ~     (p=0.460 n=5+5)
_directGzip-4                  0.73 ± 5%      0.76 ± 5%     ~     (p=0.222 n=5+5)
_directGzipHead-4              0.75 ± 8%      0.77 ± 8%     ~     (p=0.690 n=5+5)
_noDirectGzip-4                4.31 ± 8%      4.34 ± 3%     ~     (p=0.730 n=5+5)
_htmlResponse-4                1.31 ± 5%      1.32 ± 2%     ~     (p=1.000 n=5+5)
_jsonBodyManual-4              0.96 ± 8%      0.96 ± 5%     ~     (p=0.841 n=5+5)
_jsonBody-4                    1.40 ± 4%      1.38 ± 3%     ~     (p=0.397 n=5+5)
_jsonBodyValidation-4          1.77 ± 2%      1.80 ± 7%     ~     (p=1.000 n=5+5)
_outputHeaders-4               1.19 ± 6%      1.25 ± 5%     ~     (p=0.095 n=5+5)
_requestResponseMapping-4      1.45 ± 6%      1.49 ± 7%     ~     (p=0.421 n=5+5)
_validation-4                  1.56 ± 5%      1.55 ± 4%     ~     (p=0.952 n=5+5)
_noValidation-4                1.13 ± 6%      1.14 ± 7%     ~     (p=0.952 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 0.85 ± 3%      0.87 ± 5%     ~     (p=0.548 n=5+5)
_ok-4                          0.87 ±10%      0.87 ± 6%     ~     (p=1.000 n=5+5)
_invalidBody-4                 1.20 ± 3%      1.17 ± 7%     ~     (p=0.222 n=5+5)

name                       old 90%:ms     new 90%:ms     delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  1.59 ±13%      1.55 ± 5%     ~     (p=1.000 n=5+5)
_directGzipHead-4              1.54 ± 4%      1.50 ± 3%     ~     (p=0.421 n=5+5)
_noDirectGzip-4                10.3 ± 2%      10.3 ± 3%     ~     (p=0.968 n=5+5)
_directGzip_decode-4           34.0 ± 1%      32.3 ± 9%     ~     (p=0.151 n=5+5)
_noDirectGzip_decode-4         10.1 ± 3%      10.1 ± 4%     ~     (p=0.841 n=5+5)
_jsonBody-4                    3.38 ± 6%      3.27 ± 3%     ~     (p=0.381 n=5+5)
_jsonBodyValidation-4          3.60 ± 3%      3.69 ± 4%     ~     (p=0.095 n=5+5)
_outputHeaders-4               1.53 ± 5%      1.56 ± 7%     ~     (p=0.421 n=5+5)
_requestResponseMapping-4      3.10 ± 4%      3.03 ± 2%     ~     (p=0.151 n=5+5)
_validation-4                  3.33 ± 2%      3.51 ± 3%   +5.64%  (p=0.008 n=5+5)
_noValidation-4                2.44 ± 6%      2.49 ± 9%     ~     (p=0.690 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             1.86 ± 5%      1.87 ± 1%     ~     (p=0.905 n=5+4)
_formOrJSON/json-4             2.19 ±11%      2.16 ± 2%     ~     (p=0.690 n=5+5)
_directGzip-4                  1.51 ± 4%      1.57 ± 4%   +3.72%  (p=0.032 n=5+5)
_directGzipHead-4              1.58 ± 9%      1.62 ± 5%     ~     (p=0.841 n=5+5)
_noDirectGzip-4                8.92 ± 4%      9.00 ± 3%     ~     (p=0.690 n=5+5)
_htmlResponse-4                2.92 ± 6%      2.85 ± 4%     ~     (p=0.222 n=5+5)
_jsonBodyManual-4              2.04 ± 4%      2.01 ± 6%     ~     (p=0.841 n=5+5)
_jsonBody-4                    3.13 ± 5%      3.06 ± 3%     ~     (p=0.548 n=5+5)
_jsonBodyValidation-4          3.87 ± 2%      3.83 ± 3%     ~     (p=0.460 n=5+5)
_outputHeaders-4               2.81 ± 3%      2.94 ± 6%     ~     (p=0.095 n=5+5)
_requestResponseMapping-4      3.22 ± 4%      3.26 ± 5%     ~     (p=0.730 n=5+5)
_validation-4                  3.47 ± 3%      3.57 ± 7%     ~     (p=0.222 n=5+5)
_noValidation-4                2.53 ± 6%      2.55 ± 6%     ~     (p=0.841 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 1.82 ± 6%      1.79 ± 2%     ~     (p=0.548 n=5+5)
_ok-4                          1.83 ± 8%      1.78 ± 4%     ~     (p=0.548 n=5+5)
_invalidBody-4                 2.77 ±12%      2.78 ± 7%     ~     (p=0.690 n=5+5)

name                       old 99%:ms     new 99%:ms     delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  2.92 ±49%      2.49 ± 3%     ~     (p=0.905 n=5+4)
_directGzipHead-4              2.68 ± 8%      2.49 ± 4%     ~     (p=0.095 n=5+5)
_noDirectGzip-4                16.4 ± 5%      16.3 ± 4%     ~     (p=1.000 n=5+5)
_directGzip_decode-4           66.3 ± 9%      58.9 ± 6%  -11.12%  (p=0.032 n=5+5)
_noDirectGzip_decode-4         15.6 ± 3%      15.9 ± 9%     ~     (p=1.000 n=5+5)
_jsonBody-4                    5.32 ±23%      5.14 ± 6%     ~     (p=0.841 n=5+5)
_jsonBodyValidation-4          6.02 ± 9%      6.08 ± 6%     ~     (p=1.000 n=5+5)
_outputHeaders-4               2.58 ± 5%      2.70 ± 6%     ~     (p=0.056 n=5+5)
_requestResponseMapping-4      4.93 ± 6%      4.84 ± 6%     ~     (p=0.548 n=5+5)
_validation-4                  5.19 ± 3%      5.43 ± 6%     ~     (p=0.056 n=5+5)
_noValidation-4                4.08 ± 6%      4.08 ± 6%     ~     (p=1.000 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             2.95 ± 9%      2.94 ± 4%     ~     (p=0.794 n=5+4)
_formOrJSON/json-4             3.35 ± 3%      3.47 ± 3%     ~     (p=0.063 n=4+5)
_directGzip-4                  2.59 ± 6%      2.64 ± 9%     ~     (p=0.841 n=5+5)
_directGzipHead-4              2.56 ± 5%      2.82 ± 5%   +9.94%  (p=0.016 n=5+5)
_noDirectGzip-4                14.1 ± 7%      14.2 ± 6%     ~     (p=0.690 n=5+5)
_htmlResponse-4                4.72 ± 4%      4.53 ± 5%     ~     (p=0.151 n=5+5)
_jsonBodyManual-4              3.43 ± 9%      3.30 ± 2%     ~     (p=0.381 n=5+5)
_jsonBody-4                    4.94 ± 4%      4.97 ± 3%     ~     (p=1.000 n=5+5)
_jsonBodyValidation-4          5.92 ± 1%      6.00 ± 6%     ~     (p=1.000 n=5+5)
_outputHeaders-4               4.57 ± 5%      4.47 ± 2%     ~     (p=0.310 n=5+5)
_requestResponseMapping-4      4.95 ± 6%      4.98 ± 5%     ~     (p=0.746 n=5+5)
_validation-4                  5.34 ± 9%      5.43 ± 3%     ~     (p=0.421 n=5+5)
_noValidation-4                4.26 ± 4%      4.15 ± 5%     ~     (p=0.151 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 2.82 ± 3%      2.75 ± 6%     ~     (p=0.310 n=5+5)
_ok-4                          2.97 ±25%      2.89 ± 6%     ~     (p=0.690 n=5+5)
_invalidBody-4                 4.64 ± 3%      4.80 ± 4%     ~     (p=0.056 n=5+5)

name                       old 99.9%:ms   new 99.9%:ms   delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  4.74 ±34%      4.46 ±56%     ~     (p=0.421 n=5+5)
_directGzipHead-4              4.62 ±22%      3.96 ±12%     ~     (p=0.095 n=5+5)
_noDirectGzip-4                21.0 ± 7%      21.2 ±10%     ~     (p=1.000 n=5+5)
_directGzip_decode-4           91.2 ±10%      78.8 ±14%  -13.53%  (p=0.032 n=5+5)
_noDirectGzip_decode-4         20.3 ± 7%      20.9 ±18%     ~     (p=1.000 n=5+5)
_jsonBody-4                    8.03 ±34%      7.31 ±12%     ~     (p=0.421 n=5+5)
_jsonBodyValidation-4          8.39 ± 9%      8.49 ±17%     ~     (p=0.841 n=5+5)
_outputHeaders-4               4.07 ±23%      4.09 ±17%     ~     (p=0.690 n=5+5)
_requestResponseMapping-4      7.17 ± 7%      7.16 ± 3%     ~     (p=1.000 n=5+5)
_validation-4                  7.61 ± 5%      7.84 ±12%     ~     (p=0.690 n=5+5)
_noValidation-4                5.60 ±10%      6.05 ± 3%     ~     (p=0.095 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             4.04 ± 9%      4.74 ±46%     ~     (p=0.310 n=5+5)
_formOrJSON/json-4             5.23 ±36%      4.65 ± 6%     ~     (p=0.310 n=5+5)
_directGzip-4                  4.30 ± 9%      4.31 ±15%     ~     (p=1.000 n=5+5)
_directGzipHead-4              3.97 ± 8%      4.63 ±25%     ~     (p=0.056 n=5+5)
_noDirectGzip-4                19.3 ±11%      19.2 ± 8%     ~     (p=0.937 n=5+5)
_htmlResponse-4                6.52 ±15%      6.71 ±11%     ~     (p=0.421 n=5+5)
_jsonBodyManual-4              4.83 ± 9%      4.74 ±13%     ~     (p=1.000 n=5+5)
_jsonBody-4                    7.13 ±30%      6.99 ± 7%     ~     (p=0.310 n=5+5)
_jsonBodyValidation-4          8.27 ± 4%      8.46 ±14%     ~     (p=0.841 n=5+5)
_outputHeaders-4               6.38 ± 9%      6.16 ± 5%     ~     (p=0.841 n=5+5)
_requestResponseMapping-4      7.18 ± 6%      7.13 ±17%     ~     (p=0.421 n=5+5)
_validation-4                  7.64 ± 5%      7.45 ± 7%     ~     (p=0.690 n=5+5)
_noValidation-4                6.38 ± 8%      5.84 ± 7%     ~     (p=0.095 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 3.80 ± 7%      3.92 ± 4%     ~     (p=0.310 n=5+5)
_ok-4                          4.23 ±30%      3.93 ± 3%     ~     (p=0.841 n=5+5)
_invalidBody-4                 6.92 ±17%      6.58 ±13%     ~     (p=0.421 n=5+5)

name                       old B:rcvd/op  new B:rcvd/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                   630 ± 0%       630 ± 0%     ~     (all equal)
_directGzipHead-4               174 ± 0%       174 ± 0%     ~     (all equal)
_noDirectGzip-4               1.03k ± 0%     1.03k ± 0%     ~     (all equal)
_directGzip_decode-4            630 ± 0%       630 ± 0%     ~     (all equal)
_noDirectGzip_decode-4        1.03k ± 0%     1.03k ± 0%     ~     (all equal)
_jsonBody-4                     199 ± 0%       199 ± 0%     ~     (all equal)
_jsonBodyValidation-4           185 ± 0%       185 ± 0%     ~     (all equal)
_outputHeaders-4                146 ± 0%       146 ± 0%     ~     (all equal)
_requestResponseMapping-4      94.0 ± 0%      94.0 ± 0%     ~     (all equal)
_validation-4                   168 ± 0%       168 ± 0%     ~     (all equal)
_noValidation-4                 168 ± 0%       168 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4              155 ± 0%       155 ± 0%     ~     (all equal)
_formOrJSON/json-4              156 ± 0%       156 ± 0%     ~     (all equal)
_directGzip-4                   638 ± 0%       638 ± 0%     ~     (all equal)
_directGzipHead-4               182 ± 0%       182 ± 0%     ~     (all equal)
_noDirectGzip-4               1.04k ± 0%     1.04k ± 0%     ~     (all equal)
_htmlResponse-4                 355 ± 0%       355 ± 0%     ~     (all equal)
_jsonBodyManual-4               207 ± 0%       207 ± 0%     ~     (all equal)
_jsonBody-4                     207 ± 0%       207 ± 0%     ~     (all equal)
_jsonBodyValidation-4           193 ± 0%       193 ± 0%     ~     (all equal)
_outputHeaders-4                214 ± 0%       214 ± 0%     ~     (all equal)
_requestResponseMapping-4       108 ± 0%       108 ± 0%     ~     (all equal)
_validation-4                   176 ± 0%       176 ± 0%     ~     (all equal)
_noValidation-4                 176 ± 0%       176 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                  322 ± 0%       322 ± 0%     ~     (all equal)
_ok-4                           344 ± 0%       344 ± 0%     ~     (all equal)
_invalidBody-4                  420 ± 0%       420 ± 0%     ~     (all equal)

name                       old B:sent/op  new B:sent/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                   103 ± 0%       103 ± 0%     ~     (all equal)
_directGzipHead-4               104 ± 0%       104 ± 0%     ~     (all equal)
_noDirectGzip-4                 117 ± 0%       117 ± 0%     ~     (all equal)
_directGzip_decode-4            116 ± 0%       116 ± 0%     ~     (all equal)
_noDirectGzip_decode-4          130 ± 0%       130 ± 0%     ~     (all equal)
_jsonBody-4                     188 ± 0%       188 ± 0%     ~     (all equal)
_jsonBodyValidation-4           192 ± 0%       192 ± 0%     ~     (all equal)
_outputHeaders-4               77.0 ± 0%      77.0 ± 0%     ~     (all equal)
_requestResponseMapping-4       169 ± 0%       169 ± 0%     ~     (all equal)
_validation-4                   170 ± 0%       170 ± 0%     ~     (all equal)
_noValidation-4                 173 ± 0%       173 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4              170 ± 0%       170 ± 0%     ~     (all equal)
_formOrJSON/json-4              162 ± 0%       162 ± 0%     ~     (all equal)
_directGzip-4                   103 ± 0%       103 ± 0%     ~     (all equal)
_directGzipHead-4               104 ± 0%       104 ± 0%     ~     (all equal)
_noDirectGzip-4                 117 ± 0%       117 ± 0%     ~     (all equal)
_htmlResponse-4                 108 ± 0%       108 ± 0%     ~     (all equal)
_jsonBodyManual-4               195 ± 0%       195 ± 0%     ~     (all equal)
_jsonBody-4                     188 ± 0%       188 ± 0%     ~     (all equal)
_jsonBodyValidation-4           192 ± 0%       192 ± 0%     ~     (all equal)
_outputHeaders-4               88.0 ± 0%      88.0 ± 0%     ~     (all equal)
_requestResponseMapping-4       169 ± 0%       169 ± 0%     ~     (all equal)
_validation-4                   170 ± 0%       170 ± 0%     ~     (all equal)
_noValidation-4                 173 ± 0%       173 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 74.0 ± 0%      74.0 ± 0%     ~     (all equal)
_ok-4                          74.0 ± 0%      74.0 ± 0%     ~     (all equal)
_invalidBody-4                  137 ± 0%       137 ± 0%     ~     (all equal)

name                       old rps        new rps        delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                 56.9k ± 9%     57.6k ± 9%     ~     (p=0.841 n=5+5)
_directGzipHead-4             58.6k ± 3%     59.4k ± 1%     ~     (p=0.222 n=5+5)
_noDirectGzip-4               9.31k ± 1%     9.46k ± 1%   +1.58%  (p=0.008 n=5+5)
_directGzip_decode-4          2.95k ± 2%     3.01k ± 1%   +1.91%  (p=0.040 n=5+5)
_noDirectGzip_decode-4        9.39k ± 2%     9.36k ± 2%     ~     (p=0.310 n=5+5)
_jsonBody-4                   27.2k ± 5%     27.8k ± 1%   +2.21%  (p=0.032 n=5+5)
_jsonBodyValidation-4         24.9k ± 1%     24.5k ± 2%     ~     (p=0.056 n=5+5)
_outputHeaders-4              59.2k ± 2%     58.4k ± 1%     ~     (p=0.056 n=5+5)
_requestResponseMapping-4     29.4k ± 1%     29.0k ± 2%     ~     (p=0.310 n=5+5)
_validation-4                 27.0k ± 2%     26.8k ± 2%     ~     (p=0.421 n=5+5)
_noValidation-4               38.3k ± 1%     37.8k ± 1%     ~     (p=0.056 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4            49.7k ± 2%     48.1k ± 9%     ~     (p=0.056 n=5+5)
_formOrJSON/json-4            42.6k ± 7%     42.6k ± 1%     ~     (p=0.310 n=5+5)
_directGzip-4                 58.9k ± 1%     57.8k ± 2%   -1.94%  (p=0.008 n=5+5)
_directGzipHead-4             58.3k ± 4%     55.6k ± 4%     ~     (p=0.151 n=5+5)
_noDirectGzip-4               10.5k ± 1%     10.4k ± 1%     ~     (p=0.151 n=5+5)
_htmlResponse-4               31.9k ± 2%     32.6k ± 1%     ~     (p=0.056 n=5+5)
_jsonBodyManual-4             45.6k ± 1%     45.5k ± 1%     ~     (p=0.690 n=5+5)
_jsonBody-4                   30.3k ± 2%     30.4k ± 2%     ~     (p=0.310 n=5+5)
_jsonBodyValidation-4         24.0k ± 1%     24.0k ± 1%     ~     (p=0.690 n=5+5)
_outputHeaders-4              33.4k ± 1%     32.9k ± 1%     ~     (p=0.056 n=5+5)
_requestResponseMapping-4     28.7k ± 1%     28.4k ± 1%     ~     (p=0.056 n=5+5)
_validation-4                 26.5k ± 1%     26.3k ± 2%     ~     (p=0.222 n=5+5)
_noValidation-4               36.9k ± 2%     36.9k ± 1%     ~     (p=0.421 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                50.3k ± 0%     50.5k ± 0%     ~     (p=0.056 n=5+5)
_ok-4                         49.9k ± 5%     50.4k ± 1%     ~     (p=0.841 n=5+5)
_invalidBody-4                34.9k ± 4%     34.7k ± 4%     ~     (p=0.690 n=5+5)

name                       old alloc/op   new alloc/op   delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                4.04kB ± 0%    4.04kB ± 0%     ~     (p=0.421 n=5+5)
_directGzipHead-4            4.04kB ± 0%    4.04kB ± 0%     ~     (p=0.762 n=5+5)
_noDirectGzip-4              7.35kB ±26%    7.35kB ±18%     ~     (p=0.841 n=5+5)
_directGzip_decode-4          398kB ± 0%     399kB ± 0%     ~     (p=1.000 n=5+5)
_noDirectGzip_decode-4       6.27kB ± 7%    6.93kB ± 8%     ~     (p=0.095 n=5+5)
_jsonBody-4                  13.7kB ± 0%    13.7kB ± 0%     ~     (p=0.381 n=5+5)
_jsonBodyValidation-4        19.3kB ± 0%    19.3kB ± 0%     ~     (p=0.214 n=5+5)
_outputHeaders-4             3.71kB ± 0%    3.70kB ± 0%     ~     (p=0.294 n=5+5)
_requestResponseMapping-4    16.7kB ± 0%    16.7kB ± 0%     ~     (p=0.698 n=5+4)
_validation-4                16.6kB ± 0%    16.6kB ± 0%     ~     (p=0.508 n=5+5)
_noValidation-4              7.92kB ± 0%    7.92kB ± 0%   +0.09%  (p=0.008 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4           6.24kB ± 0%    6.25kB ± 0%     ~     (p=0.444 n=5+5)
_formOrJSON/json-4           6.64kB ± 0%    6.64kB ± 0%     ~     (p=0.675 n=5+5)
_directGzip-4                4.06kB ± 0%    4.05kB ± 0%     ~     (p=0.657 n=4+4)
_directGzipHead-4            4.05kB ± 0%    4.05kB ± 0%   +0.06%  (p=0.048 n=5+5)
_noDirectGzip-4              8.06kB ±18%    7.70kB ±19%     ~     (p=0.690 n=5+5)
_htmlResponse-4              8.61kB ± 0%    8.61kB ± 0%     ~     (p=1.000 n=5+5)
_jsonBodyManual-4            4.99kB ± 0%    4.99kB ± 0%     ~     (p=0.484 n=5+5)
_jsonBody-4                  10.7kB ± 0%    10.8kB ± 0%     ~     (p=0.794 n=5+5)
_jsonBodyValidation-4        19.3kB ± 0%    19.3kB ± 0%     ~     (p=0.349 n=5+5)
_outputHeaders-4             10.4kB ± 0%    10.4kB ± 0%     ~     (p=1.000 n=5+5)
_requestResponseMapping-4    16.7kB ± 0%    16.7kB ± 0%     ~     (p=0.421 n=5+5)
_validation-4                16.6kB ± 0%    16.6kB ± 0%     ~     (p=0.246 n=5+5)
_noValidation-4              7.96kB ± 0%    7.96kB ± 0%     ~     (p=0.730 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4               5.31kB ± 0%    5.31kB ± 0%     ~     (p=0.238 n=5+4)
_ok-4                        5.22kB ± 0%    5.22kB ± 0%     ~     (p=0.143 n=4+4)
_invalidBody-4               8.92kB ± 0%    8.93kB ± 0%     ~     (p=0.886 n=4+4)

name                       old allocs/op  new allocs/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  43.0 ± 0%      43.0 ± 0%     ~     (all equal)
_directGzipHead-4              43.0 ± 0%      43.0 ± 0%     ~     (all equal)
_noDirectGzip-4                50.2 ± 4%      50.2 ± 4%     ~     (p=1.000 n=5+5)
_directGzip_decode-4            487 ± 0%       487 ± 0%     ~     (p=0.714 n=5+5)
_noDirectGzip_decode-4         51.0 ± 0%      51.0 ± 0%     ~     (all equal)
_jsonBody-4                     131 ± 0%       131 ± 0%     ~     (all equal)
_jsonBodyValidation-4           184 ± 0%       184 ± 0%     ~     (all equal)
_outputHeaders-4               36.0 ± 0%      36.0 ± 0%     ~     (all equal)
_requestResponseMapping-4       122 ± 0%       122 ± 0%     ~     (all equal)
_validation-4                   153 ± 0%       153 ± 0%     ~     (all equal)
_noValidation-4                91.0 ± 0%      91.0 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             60.0 ± 0%      60.0 ± 0%     ~     (all equal)
_formOrJSON/json-4             66.0 ± 0%      66.0 ± 0%     ~     (all equal)
_directGzip-4                  44.0 ± 0%      44.0 ± 0%     ~     (all equal)
_directGzipHead-4              44.0 ± 0%      44.0 ± 0%     ~     (all equal)
_noDirectGzip-4                51.2 ± 4%      51.2 ± 4%     ~     (p=1.000 n=5+5)
_htmlResponse-4                 143 ± 0%       143 ± 0%     ~     (all equal)
_jsonBodyManual-4              50.0 ± 0%      50.0 ± 0%     ~     (all equal)
_jsonBody-4                     101 ± 0%       101 ± 0%     ~     (all equal)
_jsonBodyValidation-4           185 ± 0%       185 ± 0%     ~     (all equal)
_outputHeaders-4                110 ± 0%       110 ± 0%     ~     (all equal)
_requestResponseMapping-4       123 ± 0%       123 ± 0%     ~     (all equal)
_validation-4                   154 ± 0%       153 ± 0%     ~     (p=0.095 n=4+5)
_noValidation-4                92.0 ± 0%      92.0 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 54.0 ± 0%      54.0 ± 0%     ~     (all equal)
_ok-4                          50.0 ± 0%      50.0 ± 0%     ~     (all equal)
_invalidBody-4                 98.0 ± 0%      98.0 ± 0%     ~     (all equal)

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