go-json icon indicating copy to clipboard operation
go-json copied to clipboard

Fix: Switch to lazy init() in decoder and encoder

Open toddtreece opened this issue 1 year ago • 1 comments

Why

See: https://github.com/grafana/grafana/pull/78651

There is additional memory overhead in Grafana due the import of go-json in Apache Arrow. It looks like this is caused by init() initializing global variables in the encoder and decoder.

Grafana uses Apache Arrow, but does not currently use Arrow's JSON encoding/decoding features, so it would be ideal if we could avoid the additional memory overhead until JSON encoding/decoding is used.

What

Switch to lazy initialization of global variables in decoder and encoder.

toddtreece avatar Dec 19 '23 03:12 toddtreece

@goccy i apologize for pinging you directly, but could you take a quick look at this one when you have a chance?

toddtreece avatar Jan 12 '24 13:01 toddtreece