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

Bugs/isatty hot path #51

Merged
merged 2 commits into from
Jul 9, 2023

Conversation

cedric-appdirect
Copy link
Contributor

Removing isatty call from the hot path significantly improve performance when using gin and zerolog via gin-contrig/logger.

The result from isatty is immutable during the run of the program and
is triggering a heavy system call that significantly slow down answering
request.

$ benchstat before.txt after.txt
goos: darwin
goarch: amd64
pkg: github.com/gin-contrib/logger
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
         │  before.txt   │              after.txt               │
         │    sec/op     │    sec/op     vs base                │
Logger      2.924µ ±  2%   1.617µ ± 12%  -44.70% (p=0.000 n=10)
Logger-2   1649.0n ±  2%   766.1n ±  1%  -53.54% (p=0.000 n=10)
Logger-4   1009.5n ± 11%   496.6n ± 12%  -50.80% (p=0.000 n=10)
Logger-8    853.4n ±  3%   396.4n ± 12%  -53.56% (p=0.000 n=10)
geomean     1.428µ         702.7n        -50.78%
@appleboy
Copy link
Member

appleboy commented Jul 9, 2023

@appleboy appleboy closed this Jul 9, 2023
@appleboy appleboy reopened this Jul 9, 2023
@appleboy appleboy added the bug Something isn't working label Jul 9, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2023

Codecov Report

Merging #51 (b7b9aca) into master (809ceee) will decrease coverage by 0.03%.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master      #51      +/-   ##
==========================================
- Coverage   97.52%   97.50%   -0.03%     
==========================================
  Files           2        2              
  Lines         121      120       -1     
==========================================
- Hits          118      117       -1     
  Misses          2        2              
  Partials        1        1              
Flag Coverage Δ
go- 97.50% <ø> (-0.03%) ⬇️
go-1.17 97.50% <ø> (-0.03%) ⬇️
go-1.18 97.50% <ø> (-0.03%) ⬇️
go-1.19 97.50% <ø> (-0.03%) ⬇️
go-1.20 97.50% <ø> (-0.03%) ⬇️
macos-latest 97.50% <ø> (-0.03%) ⬇️
ubuntu-latest 97.50% <ø> (-0.03%) ⬇️

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

Impacted Files Coverage Δ
logger.go 96.51% <ø> (-0.05%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@appleboy appleboy merged commit 75cf999 into gin-contrib:master Jul 9, 2023
7 of 8 checks passed
@cedric-appdirect cedric-appdirect deleted the bugs/isatty-hot-path branch July 10, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants