mirror of
https://github.com/minio/minio.git
synced 2025-11-29 05:19:03 -05:00
Use jsoniter whenever applicable instead of encoding/json (#8766)
This PR adds jsoniter package to replace encoding/json in places where faster json unmarshal is necessary whenever input JSON is large enough. Some benchmarking comparison between jsoniter and enconding/json benchmark old MB/s new MB/s speedup BenchmarkParseUnmarshal/N10-4 110.02 331.17 3.01x BenchmarkParseUnmarshal/N100-4 125.74 524.09 4.17x BenchmarkParseUnmarshal/N500-4 131.68 542.60 4.12x BenchmarkParseUnmarshal/N1000-4 133.93 514.88 3.84x BenchmarkParseUnmarshal/N5000-4 122.10 415.36 3.40x BenchmarkParseUnmarshal/N10000-4 132.13 403.90 3.06x
This commit is contained in:
committed by
Nitish Tiwari
parent
60813bef29
commit
aa2e89bfe3
@@ -18,11 +18,11 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"hash/crc32"
|
||||
"path"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/minio/minio/cmd/logger"
|
||||
"github.com/minio/minio/pkg/sync/errgroup"
|
||||
)
|
||||
@@ -117,6 +117,7 @@ func hashOrder(key string, cardinality int) []int {
|
||||
|
||||
// Constructs xlMetaV1 using `jsoniter` lib.
|
||||
func xlMetaV1UnmarshalJSON(ctx context.Context, xlMetaBuf []byte) (xlMeta xlMetaV1, err error) {
|
||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
err = json.Unmarshal(xlMetaBuf, &xlMeta)
|
||||
return xlMeta, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user