Hacker News new | past | comments | ask | show | jobs | submit login
Made the fastest Golang JSON logger thanks to a pooling optimisation (github.com/francoispqt)
2 points by francoisllm on May 9, 2018 | hide | past | favorite | 1 comment



Hey guys, wanted to share my experience.

I just updated onelog, my zero alloc JSON logger, and made it the fastest JSON logger out there by far, thanks to a simple `pooling optimisation` in gojay (the underlying JSON encoder).

Previously, I was using buffered channel in Gojay to pool encoders in memory. My logger was fast already, but zerolog or zap was a bit faster in some cases. I noticed through profiling, that sometime, it took time to acquire from channels and increasing the buffer size didnt chang.

Then I disabled pooling and noticed a good performance increase but more allocations. so I tried with sync.Pool, made a safe usage of it and performance of the logger have jumped 2x to 3x.

It is now by far the fastest JSON logger out there.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: