Skip to content

Zero log becomes slow with file-writer #723

@raj-prince

Description

@raj-prince

Tried comparing zerolog, zaplog and slog with log destination as file. Although with io.Discard, zerolog is blazing fast, but when we pass a file-writer then zerolog starts performing worst in comparison with zaplog and slog.

Do we know why? Am I missing something?

Here, is the benchmarking number:

// goos: linux
// goarch: amd64
// pkg: go-core/experiment
// cpu: INTEL(R) XEON(R) PLATINUM 8581C CPU @ 2.30GHz
// BenchmarkSlog-192             	  317107	      3560 ns/op	     375 B/op	       9 allocs/op
// BenchmarkSlogAsync-192        	  370838	      2987 ns/op	     722 B/op	      11 allocs/op
// BenchmarkZerolog-192          	  306411	      3858 ns/op	      81 B/op	       3 allocs/op
// BenchmarkZerologAsync-192     	  597055	      2221 ns/op	     369 B/op	       5 allocs/op
// BenchmarkZap-192              	  233199	      4719 ns/op	     477 B/op	       5 allocs/op
// BenchmarkZapAsync-192         	  484533	      2331 ns/op	     756 B/op	       7 allocs/op
// PASS
// ok  	go-core/experiment	8.660s

The complete benchmarking script: https://github.com/raj-prince/go-core/blob/0b96e8124c11d04b0b08f9ef93ec012cb87556c3/experiment/logging_benchmark_test.go#L278

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions