golang too many json unmarshal trigger gc frequency to many

253 views
Skip to first unread message

刘桂祥

unread,
Oct 26, 2016, 10:29:01 PM10/26/16
to golang-nuts
    
      In my server many requests need to handle a loop to unmarshal json strings and I find gc is very frequency 



Tamás Gulácsi

unread,
Oct 27, 2016, 1:06:03 PM10/27/16
to golang-nuts
If you can't avoid generating garbage, then at least try to reuse it!
That's what sync.Pool is for (don't make the map, reuse one).

Can't you read the Redis reply by chunks?

Erik Dubbelboer

unread,
Oct 28, 2016, 1:36:20 AM10/28/16
to golang-nuts
Try https://github.com/pquerna/ffjson to improve speed and reduce garbage generation. This in combination with sync.Pool will increase your throughput by A LOT.

Klaus Post

unread,
Oct 28, 2016, 4:49:42 AM10/28/16
to golang-nuts
On Friday, 28 October 2016 07:36:20 UTC+2, Erik Dubbelboer wrote:
Try https://github.com/pquerna/ffjson to improve speed and reduce garbage generation. This in combination with sync.Pool will increase your throughput by A LOT.

Also try out http://ugorji.net/blog/go-codec-primer - depending on your usage that is also really great.

/Klaus

 
Reply all
Reply to author
Forward
0 new messages