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

Improve log perfomance #359

Merged
merged 5 commits into from
Aug 15, 2023
Merged

Improve log perfomance #359

merged 5 commits into from
Aug 15, 2023

Conversation

komuw
Copy link
Owner

@komuw komuw commented Aug 15, 2023

The performance for the average case seems to be 7% slower compared to v0.0.73.
But for the best case, it is about 45% faster.

go test -timeout 7m -count=10 -run=XXXX -bench=BenchmarkAverageCase/ong github.com/komuw/ong/log > old.txt
go test -timeout 7m -count=10 -run=XXXX -bench=BenchmarkAverageCase/ong github.com/komuw/ong/log > new.txt
benchstat old.txt new.txt

pkg: github.com/komuw/ong/log
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
                  │   old.txt   │              new.txt               │
                  │   sec/op    │   sec/op     vs base               │
AverageCase/ong-8   5.287µ ± 4%   5.678µ ± 6%  +7.41% (p=0.000 n=10)

                  │   old.txt    │               new.txt               │
                  │     B/op     │     B/op      vs base               │
AverageCase/ong-8   1.475Ki ± 0%   1.567Ki ± 0%  +6.29% (p=0.000 n=10)

                  │  old.txt   │              new.txt              │
                  │ allocs/op  │ allocs/op   vs base               │
AverageCase/ong-8   27.00 ± 0%   26.00 ± 0%  -3.70% (p=0.000 n=10)


go test -timeout 7m -count=10 -run=XXXX -bench=BenchmarkBestCase/ong github.com/komuw/ong/log > old.txt
go test -timeout 7m -count=10 -run=XXXX -bench=BenchmarkBestCase/ong github.com/komuw/ong/log > new.txt
benchstat old.txt new.txt

pkg: github.com/komuw/ong/log
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
               │   old.txt   │               new.txt               │
               │   sec/op    │   sec/op     vs base                │
BestCase/ong-8   2.315µ ± 2%   1.253µ ± 7%  -45.90% (p=0.000 n=10)

               │   old.txt   │              new.txt               │
               │    B/op     │    B/op     vs base                │
BestCase/ong-8   1024.0 ± 0%   864.0 ± 0%  -15.62% (p=0.000 n=10)

               │   old.txt   │              new.txt               │
               │  allocs/op  │ allocs/op   vs base                │
BestCase/ong-8   19.000 ± 0%   2.000 ± 0%  -89.47% (p=0.000 n=10)

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2023

Codecov Report

Patch coverage: 88.00% and project coverage change: -0.04% ⚠️

Comparison is base (0185295) 75.39% compared to head (267a954) 75.35%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #359      +/-   ##
==========================================
- Coverage   75.39%   75.35%   -0.04%     
==========================================
  Files          44       44              
  Lines        5104     5109       +5     
==========================================
+ Hits         3848     3850       +2     
- Misses        997      999       +2     
- Partials      259      260       +1     
Files Changed Coverage Δ
log/slogtest.go 76.66% <ø> (ø)
log/log.go 94.33% <88.00%> (-1.77%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@komuw komuw changed the title Log/optimize Improve log perfomance Aug 15, 2023
@komuw komuw marked this pull request as ready for review August 15, 2023 07:14
komuw added 2 commits August 15, 2023 10:55
Defer processing log records until such a time when an error occurs.
@komuw komuw merged commit fa95a8f into main Aug 15, 2023
@komuw komuw deleted the log/optimize branch August 15, 2023 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants