Giter Site home page Giter Site logo

Collaboration with Onelog? about zerolog HOT 9 CLOSED

rs avatar rs commented on July 28, 2024
Collaboration with Onelog?

from zerolog.

Comments (9)

rs avatar rs commented on July 28, 2024

I’m discovering OneLog too. The APIs are not compatible, so I don’t see how we could merge the two projects. It’s fine to have different projects with different ideas. If you prefer a different API, you should use it.

I chose this chaining API for zerolog because it is the only way (I know) to avoid allocations. Passing a lambda should create an allocation for the lambda itself. I’m curious to see how OneLog achieve better performance with this construct. I might steal some ideas ;)

from zerolog.

bruth avatar bruth commented on July 28, 2024

from zerolog.

rs avatar rs commented on July 28, 2024

I tried to reproduce the benchmarks with the types supported by both libraries, and I can't reproduce the result shown on onelog's README. Here is the bench I run: https://gist.github.com/rs/988efc55268b7d4df5ffb01a293c4bdc

Perhaps @francoispqt can provide the code of his bench so I can understand what happens. If it is based on zap's benchmark, the current implementation of onelog does not support most of the field types required by the test. If unsupported types were removed, it could explain the difference but the result would be biased.

from zerolog.

francoispqt avatar francoispqt commented on July 28, 2024

Hi Olivier,

Sorry for late answer, I live in Hong Kong, was sleeping.

Here are the benchmarks: https://github.com/francoispqt/zap/tree/onelog-bench/benchmarks

Onelog does cover all types, but results for zerolog seemed really weird. So after reading your messages in this thread, I inspected Zap's benchmark suite for zerolog. And they don't implement MarshalZerologObject nor MarshalZerologArray interface on their structures or slices (I actually didn't know there was such interfaces in zerolog until I see your gist), and were calling Interface() for these types, which is clearly unfair as Zap does it for his own benchmark and has Strings and Ints methods.

For onelog I implemented the right interfaces, so I did the same for zerolog and used the correct types when logging, you can find it here https://github.com/francoispqt/zap/tree/zerolog-bench/benchmarks.

The results from a single run are giving zerolog more credits:

BenchmarkAddingFields/Zap-8         	 1000000	      1894 ns/op	     770 B/op	       5 allocs/op
BenchmarkAddingFields/francoispqt/onelog-8       	 1000000	      1005 ns/op	     128 B/op	       4 allocs/op
BenchmarkAddingFields/rs/zerolog-8               	 1000000	      1210 ns/op	     129 B/op	       4 allocs/op
BenchmarkAddingFields/rs/zerolog.Check-8         	 1000000	      1218 ns/op	     129 B/op	       4 allocs/op

So apologies @rs for the wrong results presented in onelog's README, I will update it.

Zerolog is an amazing package, best logger out there in terms of performance and usability IMHO. Actually the case where onelog is faster (other than disabled logs) rarely happens in real environment. Still I will try to improve onelog, I'm already working on having a chaining syntax (almost done), adding built in methods and obviously improving the underlying JSON encoder.

from zerolog.

rs avatar rs commented on July 28, 2024

It’s not your fault, zap refused to merge my fixed benchmark with the right implementation.

I’m fan of gojay. I might use it at some point. If you manage to beat zerolog, please tell me, I’m always interested to learn new tricks :)

from zerolog.

francoispqt avatar francoispqt commented on July 28, 2024

Glad you like gojay, it's getting closer v1.0.0 soon and I believe there's still room for optimisation.
If you use it I'd be happy to have your feedbacks.

Beating zerolog will be really hard, will try to get closer at least ;)

from zerolog.

bruth avatar bruth commented on July 28, 2024

🙌 I love this conversation. Respect.

from zerolog.

rs avatar rs commented on July 28, 2024

I started to work on a benchmark tool to ease the benchmarking of log libraries. You can find the code here: https://github.com/rs/logbench. I will automate the running/publication of the results in an easy to read format.

Let's close this issue as the initial request is addressed.

from zerolog.

Globegitter avatar Globegitter commented on July 28, 2024

It would be quite interesting to include onelog into logbench as well to have a fair comparison between the two.

from zerolog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.