You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a user, I would like to get higher performance for logging.
Detailed Description
Try to substitute classic "encoding/json" marshalling/unmarshalling which uses reflection, with a faster json library (i.e. https://github.com/mailru/easyjson)
The text was updated successfully, but these errors were encountered:
@ilmanzo do you have any suggestions on this?
Do you think is possible to take advantage of other libs or the fact that we don't know the struct of the generic object to be logged prevents us from using a reflectionless library?
I'd suggest first to run profile ( https://blog.golang.org/pprof ) with a sample program that logs many different data structures at different loglevels, to identify the bottlenecks. When I'll find some spare time, I can prepare some benchmarks.
Also take a look at the approach from https://github.com/rs/zerolog (logger developed by Netflix Director of Engineering), because allocation impacts memory footprint and performance (due to pressure on Garbage Collector)
Maybe the user could "tag" the struct fields to decide when to log a field or not, in order to save time and avoid sensitive data leak ?
@ilmanzo What is meant by "avoiding allocation"? Do they avoid creating instances of structs in memory? The idea of the tag is very good but only if you know the struct you're going to log. I wanted to cover also the case I make an HTTP request, I get the response and without unmarshalling, I log the response directly, obscurating sensitive data if any. I thought if this is a heavy operation, I could extract the obscuration method outside, so it could be used only if it is explicit. Many thanks for all your precious suggestions.
alessandroargentieri
changed the title
Substitute encoding/json marshalling with a faster json library to remove reflection
Spike: check if you can substitute encoding/json marshalling with a faster json library to remove reflection
Apr 18, 2021
User Story
As a user, I would like to get higher performance for logging.
Detailed Description
Try to substitute classic "encoding/json" marshalling/unmarshalling which uses reflection, with a faster json library (i.e. https://github.com/mailru/easyjson)
The text was updated successfully, but these errors were encountered: