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

caddyfile: Switch to slices.Equal for better performance #6061

Merged
merged 1 commit into from Jan 25, 2024

Conversation

bbaa-bbaa
Copy link
Contributor

Fixes #6058

Switch to strings.Builder for better performance.
Converting []rune to string seems to be inefficient.
Or we can simply use slices.Equal from "golang.org/x/exp/slices".

(pprof) top10
Showing nodes accounting for 17.37s, 94.30% of 18.42s total
Dropped 126 nodes (cum <= 0.09s)
Showing top 10 nodes out of 37
      flat  flat%   sum%        cum   cum%
    10.65s 57.82% 57.82%     15.62s 84.80%  runtime.slicerunetostring
     4.87s 26.44% 84.26%      4.87s 26.44%  runtime.encoderune
     0.56s  3.04% 87.30%      1.78s  9.66%  runtime.scanobject
     0.28s  1.52% 88.82%      0.29s  1.57%  runtime.spanOf (inline)
     0.23s  1.25% 90.07%      0.23s  1.25%  runtime.heapBits.nextFast (inline)
     0.22s  1.19% 91.26%      0.51s  2.77%  runtime.findObject
     0.17s  0.92% 92.18%      0.17s  0.92%  runtime.(*gcBits).bitp (inline)
     0.15s  0.81% 93.00%      0.15s  0.81%  runtime.heapBitsForAddr
     0.13s  0.71% 93.70%      2.45s 13.30%  runtime.gcDrain
     0.11s   0.6% 94.30%      0.11s   0.6%  runtime.futex
`

@francislavoie
Copy link
Member

Interesting 😅

Or we can simply use slices.Equal from "golang.org/x/exp/slices".

That would be fine too, if you prefer.

@bbaa-bbaa
Copy link
Contributor Author

bbaa-bbaa commented Jan 25, 2024

That would be fine too, if you prefer.

Switch to slices.Equal.

@bbaa-bbaa bbaa-bbaa changed the title caddyfile: Switch to strings.Builder for better performance caddyfile: Switch to slices.Equal for better performance Jan 25, 2024
Copy link
Member

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

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

Thanks!

@francislavoie francislavoie added the optimization 📉 Performance or cost improvements label Jan 25, 2024
@francislavoie francislavoie added this to the v2.8.0 milestone Jan 25, 2024
@francislavoie francislavoie enabled auto-merge (squash) January 25, 2024 14:44
@francislavoie francislavoie merged commit 7c48b5f into caddyserver:master Jan 25, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization 📉 Performance or cost improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fuzz-format: Timeout in fuzz-format
2 participants