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

fix tsr with mixed static and wildcard paths #2924

Merged
merged 1 commit into from
Nov 1, 2021
Merged

fix tsr with mixed static and wildcard paths #2924

merged 1 commit into from
Nov 1, 2021

Conversation

ibraheemdev
Copy link
Contributor

Resolves #2918

@appleboy
Copy link
Member

Please also add benchmark report like #2847 (comment)

@appleboy appleboy added the bug label Oct 29, 2021
@appleboy appleboy added this to the v1.7.5 milestone Oct 29, 2021
@ibraheemdev
Copy link
Contributor Author

Performance difference should be negligible as the only change is merging two if statements, and delaying backtracking until after the cheap tsr check. How do I run the benchmarks?

@appleboy
Copy link
Member

@ibraheemdev See the comment #2847 (review)

@codecov
Copy link

codecov bot commented Oct 29, 2021

Codecov Report

Merging #2924 (6cbbca5) into master (1c2aa59) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2924   +/-   ##
=======================================
  Coverage   98.73%   98.73%           
=======================================
  Files          41       41           
  Lines        3080     3080           
=======================================
  Hits         3041     3041           
  Misses         27       27           
  Partials       12       12           
Flag Coverage Δ
go-1.13 98.73% <100.00%> (ø)
go-1.14 98.57% <100.00%> (ø)
go-1.15 98.57% <100.00%> (ø)
go-1.16 98.57% <100.00%> (ø)
go-1.17 98.47% <100.00%> (ø)
macos-latest 98.73% <100.00%> (ø)
nomsgpack 98.71% <100.00%> (ø)
ubuntu-latest 98.73% <100.00%> (ø)

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

Impacted Files Coverage Δ
tree.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c2aa59...6cbbca5. Read the comment docs.

@appleboy
Copy link
Member

@ibraheemdev Any updates?

@ibraheemdev
Copy link
Contributor Author

I ran the tests locally because I don't have travis setup:

name              old time/op    new time/op    delta
Gin_Param           51.8ns ± 0%    51.6ns ± 0%   ~     (p=1.000 n=1+1)
Gin_Param5          98.5ns ± 0%    98.3ns ± 0%   ~     (p=1.000 n=1+1)
Gin_Param20          248ns ± 0%     246ns ± 0%   ~     (p=1.000 n=1+1)
Gin_ParamWrite      93.1ns ± 0%    91.6ns ± 0%   ~     (p=1.000 n=1+1)
Gin_GithubStatic    61.7ns ± 0%    60.5ns ± 0%   ~     (p=1.000 n=1+1)
Gin_GithubParam      111ns ± 0%     110ns ± 0%   ~     (p=1.000 n=1+1)
Gin_GithubAll       21.5µs ± 0%    21.6µs ± 0%   ~     (p=1.000 n=1+1)
Gin_GPlusStatic     48.5ns ± 0%    49.6ns ± 0%   ~     (p=1.000 n=1+1)
Gin_GPlusParam      69.3ns ± 0%    70.0ns ± 0%   ~     (p=1.000 n=1+1)
Gin_GPlus2Params    96.2ns ± 0%    96.5ns ± 0%   ~     (p=1.000 n=1+1)
Gin_GPlusAll        1.06µs ± 0%    1.04µs ± 0%   ~     (p=1.000 n=1+1)
Gin_ParseStatic     47.8ns ± 0%    49.6ns ± 0%   ~     (p=1.000 n=1+1)
Gin_ParseParam      56.4ns ± 0%    56.6ns ± 0%   ~     (p=1.000 n=1+1)
Gin_Parse2Params    72.1ns ± 0%    73.2ns ± 0%   ~     (p=1.000 n=1+1)
Gin_ParseAll        1.82µs ± 0%    1.85µs ± 0%   ~     (p=1.000 n=1+1)
Gin_StaticAll       13.8µs ± 0%    14.0µs ± 0%   ~     (p=1.000 n=1+1)

Results is almost exactly the same because this case is probably never hit in the benchmark. Even if it was the difference would be a couple of slice comparisons.

@appleboy
Copy link
Member

@ibraheemdev Please help to try the -count flag

go test -timeout=4h -bench="Gin" -benchtime=3s -count=10

@ibraheemdev
Copy link
Contributor Author

Gin_Param           52.1ns ± 1%    51.9ns ± 1%  -0.52%  (p=0.035 n=10+9)
Gin_Param5          99.0ns ± 1%    99.9ns ± 0%  +0.95%  (p=0.007 n=10+10)
Gin_Param20          247ns ± 2%     247ns ± 1%    ~     (p=0.986 n=10+10)
Gin_ParamWrite      93.0ns ± 1%    92.7ns ± 1%    ~     (p=0.138 n=10+10)
Gin_GithubStatic    60.5ns ± 1%    60.9ns ± 1%  +0.65%  (p=0.018 n=10+10)
Gin_GithubParam      111ns ± 1%     113ns ± 2%  +1.34%  (p=0.001 n=10+9)
Gin_GithubAll       21.6µs ± 0%    21.8µs ± 1%  +1.27%  (p=0.000 n=10+10)
Gin_GPlusStatic     47.2ns ± 1%    47.3ns ± 2%    ~     (p=0.782 n=10+10)
Gin_GPlusParam      69.7ns ± 2%    69.8ns ± 1%    ~     (p=0.894 n=10+10)
Gin_GPlus2Params    97.4ns ± 3%    96.4ns ± 2%    ~     (p=0.063 n=10+10)
Gin_GPlusAll        1.03µs ± 1%    1.04µs ± 1%  +0.78%  (p=0.004 n=8+9)
Gin_ParseStatic     48.3ns ± 2%    48.7ns ± 1%  +0.78%  (p=0.037 n=9+8)
Gin_ParseParam      56.0ns ± 1%    56.2ns ± 2%    ~     (p=0.509 n=10+9)
Gin_Parse2Params    73.5ns ± 1%    72.7ns ± 1%  -1.08%  (p=0.002 n=10+9)
Gin_ParseAll        1.82µs ± 1%    1.84µs ± 1%  +0.75%  (p=0.003 n=10+9)
Gin_StaticAll       14.1µs ± 1%    14.1µs ± 2%    ~     (p=0.280 n=10+10)

Copy link
Member

@thinkerou thinkerou left a comment

Choose a reason for hiding this comment

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

lgtm

@appleboy appleboy merged commit cbdd47a into gin-gonic:master Nov 1, 2021
Bisstocuz pushed a commit to Bisstocuz/gin that referenced this pull request Nov 22, 2021
Bisstocuz pushed a commit to Bisstocuz/gin that referenced this pull request Nov 22, 2021
Bisstocuz pushed a commit to Bisstocuz/gin that referenced this pull request Nov 22, 2021
Bisstocuz pushed a commit to Bisstocuz/gin that referenced this pull request Nov 23, 2021
daheige pushed a commit to daheige/gin that referenced this pull request Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect TSR with mixed static and wildcard paths
3 participants