-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
🧹 chore: Improve RemoveEscapeChar performance #3496
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
Conversation
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3496 +/- ##
=======================================
Coverage 90.97% 90.97%
=======================================
Files 110 110
Lines 11064 11072 +8
=======================================
+ Hits 10065 10073 +8
Misses 745 745
Partials 254 254
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
New vs Old: ubuntu@ubuntu:~/Desktop/git/v3-fiber/fiber$ go test -benchmem -run=^$ -bench ^Benchmark_Utils_RemoveEscapeChar_Extended$ github.com/gofiber/fiber/v3 -count=4
goos: linux
goarch: amd64
pkg: github.com/gofiber/fiber/v3
cpu: AMD Ryzen 7 7800X3D 8-Core Processor
Benchmark_Utils_RemoveEscapeChar_Extended/simple-4 56217482 20.90 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/simple-4 53135635 20.92 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/simple-4 57235556 20.98 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/simple-4 61021663 20.90 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/no_escape-4 349460665 3.415 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/no_escape-4 357582379 3.343 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/no_escape-4 359267046 3.331 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/no_escape-4 358141676 3.348 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/multiple_escapes-4 45769770 23.66 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/multiple_escapes-4 49362645 23.47 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/multiple_escapes-4 51237378 23.55 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/multiple_escapes-4 50928654 23.22 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/leading_escape-4 62444232 18.88 ns/op 8 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/leading_escape-4 57102145 18.98 ns/op 8 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/leading_escape-4 57521332 19.12 ns/op 8 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/leading_escape-4 63135105 19.02 ns/op 8 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/trailing_escape-4 59377788 19.66 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/trailing_escape-4 58263765 19.67 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/trailing_escape-4 61408718 19.86 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/trailing_escape-4 61223427 19.84 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/only_escape_char-4 168337048 7.092 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/only_escape_char-4 172812284 6.985 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/only_escape_char-4 170908411 6.982 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/only_escape_char-4 171351502 6.976 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/gofiber/fiber/v3 28.308s
ubuntu@ubuntu:~/Desktop/git/v3-fiber/fiber$ go test -benchmem -run=^$ -bench ^Benchmark_Utils_RemoveEscapeChar_Extended$ github.com/gofiber/fiber/v3 -count=4
goos: linux
goarch: amd64
pkg: github.com/gofiber/fiber/v3
cpu: AMD Ryzen 7 7800X3D 8-Core Processor
Benchmark_Utils_RemoveEscapeChar_Extended/simple-4 51089068 22.03 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/simple-4 52090060 22.09 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/simple-4 57271838 22.04 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/simple-4 56910784 22.08 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/no_escape-4 51142645 22.20 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/no_escape-4 50447330 22.15 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/no_escape-4 54730243 21.97 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/no_escape-4 56707700 22.13 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/multiple_escapes-4 49996170 22.90 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/multiple_escapes-4 49015768 23.15 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/multiple_escapes-4 55445076 23.18 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/multiple_escapes-4 50457178 22.93 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/leading_escape-4 70829822 17.15 ns/op 8 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/leading_escape-4 68588857 16.97 ns/op 8 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/leading_escape-4 71230917 16.98 ns/op 8 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/leading_escape-4 73361605 17.04 ns/op 8 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/trailing_escape-4 55574439 22.00 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/trailing_escape-4 51498166 21.95 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/trailing_escape-4 56275039 21.89 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/trailing_escape-4 53727992 22.05 ns/op 16 B/op 1 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/only_escape_char-4 210210759 5.713 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/only_escape_char-4 215446750 5.567 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/only_escape_char-4 215944836 5.555 ns/op 0 B/op 0 allocs/op
Benchmark_Utils_RemoveEscapeChar_Extended/only_escape_char-4 216903548 5.549 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/gofiber/fiber/v3 28.664s |
@gaby what happend to "Benchmark_Utils_RemoveEscapeChar_Extended/no_escape" ? its from 3 to 22ns |
There was a problem hiding this 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: 2a1d0a5 | Previous: e9e0367 | Ratio |
---|---|---|---|
BenchmarkAppendMsgitem-4_middleware_csrf |
0.623 ns/op 1605.26 MB/s 0 B/op 0 allocs/op |
0.3121 ns/op 3203.98 MB/s 0 B/op 0 allocs/op |
2.00 |
BenchmarkAppendMsgitem-4_middleware_csrf - ns/op |
0.623 ns/op |
0.3121 ns/op |
2.00 |
BenchmarkAppendMsgstorageManager - MB/s |
3203 MB/s |
1588.2 MB/s |
2.02 |
BenchmarkAppendMsgdata - MB/s |
3205.31 MB/s |
1603.21 MB/s |
2.00 |
This comment was automatically generated by workflow using github-action-benchmark.
Will address this later. Branch changed are out of sync |
Summary
RemoveEscapeChar
.RemoveEscapeCharBytes()
Note:
RemoveEscapeCharBytes()
resulted in slower performance