Logger is slow in OFF level
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 596
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
I set the log's level to OFF and I thought that log function should be fast. However it seemed to be slower than of noop function. I have tested like this:
func BenchmarkEchoLog(b *testing.B) {
e := echo.New()
e.Logger.SetLevel(log.Lvl(log.OFF))
c := e.NewContext(nil, nil)
for i := 0; i < b.N; i++ {
c.Logger().Debug("a")
}
}
func BenchmarkNoop(b *testing.B) {
noop := func(args ...interface{}) {}
for i := 0; i < b.N; i++ {
noop("a")
}
}
BenchmarkEchoLog-4 1000000 1778 ns/op
BenchmarkNoop-4 30000000 40.8 ns/op
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reported BenchmarkEchoLog and BenchmarkNoop benchmarks and then trace the logger path used by c.Logger().Debug when the level is OFF. Done means the OFF-level debug call is substantially faster while retaining the expected disabled-logging behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100