Go JSON decoding is very slow. What would be the best way to do this?

I use Go, Revel WAF and Redis.

I need to store large json data in Redis (maybe 20 MB).

json.Unmarshal()takes about 5 seconds. What would be the best way to do this?

I tried JsonLib, encode / json, ffjson, megajson, but none of them were fast enough.

I was thinking about using groupcache, but Json is being updated in real time.

This is a sample code:

package main

import (
 "github.com/garyburd/redigo/redis"
  json "github.com/pquerna/ffjson/ffjson"
)

func main() {
  c, err := redis.Dial("tcp", ":6379")
  defer c.Close()
  pointTable, err := redis.String(c.Do("GET", "data"))
  var hashPoint map[string][]float64
  json.Unmarshal([]byte(pointTable), &hashPoint) //Problem!!!
}
+4
source share
1 answer

Big JSON parsing looks slower than it should be. It would be wise to identify the cause and submit the correction to the Go authors.

, JSON , ; , ASCII- IEEE 754 (, , ).

Go, Go: gob.

, 2000 , 1050 20 JSON, 1,16 .

, , t0 := time.Now() Unmarshal time.Now().Sub(t0) .

GOB, 18 , 115 :
  .

, . , float64, 20 JSON , . JSON GOB .

, , JSON, , ( ~ 20 float.) JSON 1,02 , , ( ), .

Go, , GOB, , , "encoding/binary" .

+8

All Articles