Optimize FileInfo(Version) transfer (#10775)
File Info decoding, in particular, is showing up as a major allocator and time consumer for internode data transfers Switch to message pack for cross-server transfers: ``` MSGP: Size: 945 bytes BenchmarkEncodeFileInfoMsgp-32 1558444 866 ns/op 1.16 MB/s 0 B/op 0 allocs/op BenchmarkDecodeFileInfoMsgp-32 479968 2487 ns/op 0.40 MB/s 848 B/op 18 allocs/op GOB: Size: 1409 bytes BenchmarkEncodeFileInfoGOB-32 333339 3237 ns/op 0.31 MB/s 576 B/op 19 allocs/op BenchmarkDecodeFileInfoGOB-32 20869 57837 ns/op 0.02 MB/s 16439 B/op 428 allocs/op ```master
parent
86e0d272f3
commit
37749f4623
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,575 @@ |
||||
package cmd |
||||
|
||||
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
|
||||
|
||||
import ( |
||||
"bytes" |
||||
"testing" |
||||
|
||||
"github.com/tinylib/msgp/msgp" |
||||
) |
||||
|
||||
func TestMarshalUnmarshalFileInfo(t *testing.T) { |
||||
v := FileInfo{} |
||||
bts, err := v.MarshalMsg(nil) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
left, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) |
||||
} |
||||
|
||||
left, err = msgp.Skip(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after Skip(): %q", len(left), left) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkMarshalMsgFileInfo(b *testing.B) { |
||||
v := FileInfo{} |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.MarshalMsg(nil) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkAppendMsgFileInfo(b *testing.B) { |
||||
v := FileInfo{} |
||||
bts := make([]byte, 0, v.Msgsize()) |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkUnmarshalFileInfo(b *testing.B) { |
||||
v := FileInfo{} |
||||
bts, _ := v.MarshalMsg(nil) |
||||
b.ReportAllocs() |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
_, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func TestEncodeDecodeFileInfo(t *testing.T) { |
||||
v := FileInfo{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
|
||||
m := v.Msgsize() |
||||
if buf.Len() > m { |
||||
t.Log("WARNING: TestEncodeDecodeFileInfo Msgsize() is inaccurate") |
||||
} |
||||
|
||||
vn := FileInfo{} |
||||
err := msgp.Decode(&buf, &vn) |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
|
||||
buf.Reset() |
||||
msgp.Encode(&buf, &v) |
||||
err = msgp.NewReader(&buf).Skip() |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkEncodeFileInfo(b *testing.B) { |
||||
v := FileInfo{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
en := msgp.NewWriter(msgp.Nowhere) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.EncodeMsg(en) |
||||
} |
||||
en.Flush() |
||||
} |
||||
|
||||
func BenchmarkDecodeFileInfo(b *testing.B) { |
||||
v := FileInfo{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
rd := msgp.NewEndlessReader(buf.Bytes(), b) |
||||
dc := msgp.NewReader(rd) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
err := v.DecodeMsg(dc) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func TestMarshalUnmarshalFileInfoVersions(t *testing.T) { |
||||
v := FileInfoVersions{} |
||||
bts, err := v.MarshalMsg(nil) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
left, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) |
||||
} |
||||
|
||||
left, err = msgp.Skip(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after Skip(): %q", len(left), left) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkMarshalMsgFileInfoVersions(b *testing.B) { |
||||
v := FileInfoVersions{} |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.MarshalMsg(nil) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkAppendMsgFileInfoVersions(b *testing.B) { |
||||
v := FileInfoVersions{} |
||||
bts := make([]byte, 0, v.Msgsize()) |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkUnmarshalFileInfoVersions(b *testing.B) { |
||||
v := FileInfoVersions{} |
||||
bts, _ := v.MarshalMsg(nil) |
||||
b.ReportAllocs() |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
_, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func TestEncodeDecodeFileInfoVersions(t *testing.T) { |
||||
v := FileInfoVersions{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
|
||||
m := v.Msgsize() |
||||
if buf.Len() > m { |
||||
t.Log("WARNING: TestEncodeDecodeFileInfoVersions Msgsize() is inaccurate") |
||||
} |
||||
|
||||
vn := FileInfoVersions{} |
||||
err := msgp.Decode(&buf, &vn) |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
|
||||
buf.Reset() |
||||
msgp.Encode(&buf, &v) |
||||
err = msgp.NewReader(&buf).Skip() |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkEncodeFileInfoVersions(b *testing.B) { |
||||
v := FileInfoVersions{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
en := msgp.NewWriter(msgp.Nowhere) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.EncodeMsg(en) |
||||
} |
||||
en.Flush() |
||||
} |
||||
|
||||
func BenchmarkDecodeFileInfoVersions(b *testing.B) { |
||||
v := FileInfoVersions{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
rd := msgp.NewEndlessReader(buf.Bytes(), b) |
||||
dc := msgp.NewReader(rd) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
err := v.DecodeMsg(dc) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func TestMarshalUnmarshalFilesInfo(t *testing.T) { |
||||
v := FilesInfo{} |
||||
bts, err := v.MarshalMsg(nil) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
left, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) |
||||
} |
||||
|
||||
left, err = msgp.Skip(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after Skip(): %q", len(left), left) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkMarshalMsgFilesInfo(b *testing.B) { |
||||
v := FilesInfo{} |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.MarshalMsg(nil) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkAppendMsgFilesInfo(b *testing.B) { |
||||
v := FilesInfo{} |
||||
bts := make([]byte, 0, v.Msgsize()) |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkUnmarshalFilesInfo(b *testing.B) { |
||||
v := FilesInfo{} |
||||
bts, _ := v.MarshalMsg(nil) |
||||
b.ReportAllocs() |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
_, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func TestEncodeDecodeFilesInfo(t *testing.T) { |
||||
v := FilesInfo{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
|
||||
m := v.Msgsize() |
||||
if buf.Len() > m { |
||||
t.Log("WARNING: TestEncodeDecodeFilesInfo Msgsize() is inaccurate") |
||||
} |
||||
|
||||
vn := FilesInfo{} |
||||
err := msgp.Decode(&buf, &vn) |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
|
||||
buf.Reset() |
||||
msgp.Encode(&buf, &v) |
||||
err = msgp.NewReader(&buf).Skip() |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkEncodeFilesInfo(b *testing.B) { |
||||
v := FilesInfo{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
en := msgp.NewWriter(msgp.Nowhere) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.EncodeMsg(en) |
||||
} |
||||
en.Flush() |
||||
} |
||||
|
||||
func BenchmarkDecodeFilesInfo(b *testing.B) { |
||||
v := FilesInfo{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
rd := msgp.NewEndlessReader(buf.Bytes(), b) |
||||
dc := msgp.NewReader(rd) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
err := v.DecodeMsg(dc) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func TestMarshalUnmarshalFilesInfoVersions(t *testing.T) { |
||||
v := FilesInfoVersions{} |
||||
bts, err := v.MarshalMsg(nil) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
left, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) |
||||
} |
||||
|
||||
left, err = msgp.Skip(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after Skip(): %q", len(left), left) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkMarshalMsgFilesInfoVersions(b *testing.B) { |
||||
v := FilesInfoVersions{} |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.MarshalMsg(nil) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkAppendMsgFilesInfoVersions(b *testing.B) { |
||||
v := FilesInfoVersions{} |
||||
bts := make([]byte, 0, v.Msgsize()) |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkUnmarshalFilesInfoVersions(b *testing.B) { |
||||
v := FilesInfoVersions{} |
||||
bts, _ := v.MarshalMsg(nil) |
||||
b.ReportAllocs() |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
_, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func TestEncodeDecodeFilesInfoVersions(t *testing.T) { |
||||
v := FilesInfoVersions{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
|
||||
m := v.Msgsize() |
||||
if buf.Len() > m { |
||||
t.Log("WARNING: TestEncodeDecodeFilesInfoVersions Msgsize() is inaccurate") |
||||
} |
||||
|
||||
vn := FilesInfoVersions{} |
||||
err := msgp.Decode(&buf, &vn) |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
|
||||
buf.Reset() |
||||
msgp.Encode(&buf, &v) |
||||
err = msgp.NewReader(&buf).Skip() |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkEncodeFilesInfoVersions(b *testing.B) { |
||||
v := FilesInfoVersions{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
en := msgp.NewWriter(msgp.Nowhere) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.EncodeMsg(en) |
||||
} |
||||
en.Flush() |
||||
} |
||||
|
||||
func BenchmarkDecodeFilesInfoVersions(b *testing.B) { |
||||
v := FilesInfoVersions{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
rd := msgp.NewEndlessReader(buf.Bytes(), b) |
||||
dc := msgp.NewReader(rd) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
err := v.DecodeMsg(dc) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func TestMarshalUnmarshalVolInfo(t *testing.T) { |
||||
v := VolInfo{} |
||||
bts, err := v.MarshalMsg(nil) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
left, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) |
||||
} |
||||
|
||||
left, err = msgp.Skip(bts) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
if len(left) > 0 { |
||||
t.Errorf("%d bytes left over after Skip(): %q", len(left), left) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkMarshalMsgVolInfo(b *testing.B) { |
||||
v := VolInfo{} |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.MarshalMsg(nil) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkAppendMsgVolInfo(b *testing.B) { |
||||
v := VolInfo{} |
||||
bts := make([]byte, 0, v.Msgsize()) |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
bts, _ = v.MarshalMsg(bts[0:0]) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkUnmarshalVolInfo(b *testing.B) { |
||||
v := VolInfo{} |
||||
bts, _ := v.MarshalMsg(nil) |
||||
b.ReportAllocs() |
||||
b.SetBytes(int64(len(bts))) |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
_, err := v.UnmarshalMsg(bts) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func TestEncodeDecodeVolInfo(t *testing.T) { |
||||
v := VolInfo{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
|
||||
m := v.Msgsize() |
||||
if buf.Len() > m { |
||||
t.Log("WARNING: TestEncodeDecodeVolInfo Msgsize() is inaccurate") |
||||
} |
||||
|
||||
vn := VolInfo{} |
||||
err := msgp.Decode(&buf, &vn) |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
|
||||
buf.Reset() |
||||
msgp.Encode(&buf, &v) |
||||
err = msgp.NewReader(&buf).Skip() |
||||
if err != nil { |
||||
t.Error(err) |
||||
} |
||||
} |
||||
|
||||
func BenchmarkEncodeVolInfo(b *testing.B) { |
||||
v := VolInfo{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
en := msgp.NewWriter(msgp.Nowhere) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
v.EncodeMsg(en) |
||||
} |
||||
en.Flush() |
||||
} |
||||
|
||||
func BenchmarkDecodeVolInfo(b *testing.B) { |
||||
v := VolInfo{} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(int64(buf.Len())) |
||||
rd := msgp.NewEndlessReader(buf.Bytes(), b) |
||||
dc := msgp.NewReader(rd) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
err := v.DecodeMsg(dc) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,73 @@ |
||||
package cmd |
||||
|
||||
import ( |
||||
"bytes" |
||||
"encoding/gob" |
||||
"io/ioutil" |
||||
"testing" |
||||
|
||||
"github.com/tinylib/msgp/msgp" |
||||
) |
||||
|
||||
func BenchmarkDecodeFileInfoMsgp(b *testing.B) { |
||||
v := FileInfo{Volume: "testbucket", Name: "src/compress/zlib/reader_test.go", VersionID: "", IsLatest: true, Deleted: false, DataDir: "5e0153cc-621a-4267-8cb6-4919140d53b3", XLV1: false, ModTime: UTCNow(), Size: 3430, Mode: 0x0, Metadata: map[string]string{"X-Minio-Internal-Server-Side-Encryption-Iv": "jIJPsrkkVYYMvc7edBrNl+7zcM7+ZwXqMb/YAjBO/ck=", "X-Minio-Internal-Server-Side-Encryption-S3-Kms-Key-Id": "my-minio-key", "X-Minio-Internal-Server-Side-Encryption-S3-Kms-Sealed-Key": "IAAfAP2p7ZLv3UpLwBnsKkF2mtWba0qoY42tymK0szRgGvAxBNcXyHXYooe9dQpeeEJWgKUa/8R61oCy1mFwIg==", "X-Minio-Internal-Server-Side-Encryption-S3-Sealed-Key": "IAAfAPFYRDkHVirJBJxBixNj3PLWt78dFuUTyTLIdLG820J7XqLPBO4gpEEEWw/DoTsJIb+apnaem+rKtQ1h3Q==", "X-Minio-Internal-Server-Side-Encryption-Seal-Algorithm": "DAREv2-HMAC-SHA256", "content-type": "application/octet-stream", "etag": "20000f00e2c3709dc94905c6ce31e1cadbd1c064e14acdcd44cf0ac2db777eeedd88d639fcd64de16851ade8b21a9a1a"}, Parts: []ObjectPartInfo{{ETag: "", Number: 1, Size: 3430, ActualSize: 3398}}, Erasure: ErasureInfo{Algorithm: "reedsolomon", DataBlocks: 2, ParityBlocks: 2, BlockSize: 10485760, Index: 3, Distribution: []int{3, 4, 1, 2}, Checksums: []ChecksumInfo{{PartNumber: 1, Algorithm: 0x3, Hash: []uint8{}}}}} |
||||
var buf bytes.Buffer |
||||
msgp.Encode(&buf, &v) |
||||
b.SetBytes(1) |
||||
rd := msgp.NewEndlessReader(buf.Bytes(), b) |
||||
dc := msgp.NewReader(rd) |
||||
b.Log("Size:", buf.Len(), "bytes") |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
err := v.DecodeMsg(dc) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func BenchmarkDecodeFileInfoGOB(b *testing.B) { |
||||
v := FileInfo{Volume: "testbucket", Name: "src/compress/zlib/reader_test.go", VersionID: "", IsLatest: true, Deleted: false, DataDir: "5e0153cc-621a-4267-8cb6-4919140d53b3", XLV1: false, ModTime: UTCNow(), Size: 3430, Mode: 0x0, Metadata: map[string]string{"X-Minio-Internal-Server-Side-Encryption-Iv": "jIJPsrkkVYYMvc7edBrNl+7zcM7+ZwXqMb/YAjBO/ck=", "X-Minio-Internal-Server-Side-Encryption-S3-Kms-Key-Id": "my-minio-key", "X-Minio-Internal-Server-Side-Encryption-S3-Kms-Sealed-Key": "IAAfAP2p7ZLv3UpLwBnsKkF2mtWba0qoY42tymK0szRgGvAxBNcXyHXYooe9dQpeeEJWgKUa/8R61oCy1mFwIg==", "X-Minio-Internal-Server-Side-Encryption-S3-Sealed-Key": "IAAfAPFYRDkHVirJBJxBixNj3PLWt78dFuUTyTLIdLG820J7XqLPBO4gpEEEWw/DoTsJIb+apnaem+rKtQ1h3Q==", "X-Minio-Internal-Server-Side-Encryption-Seal-Algorithm": "DAREv2-HMAC-SHA256", "content-type": "application/octet-stream", "etag": "20000f00e2c3709dc94905c6ce31e1cadbd1c064e14acdcd44cf0ac2db777eeedd88d639fcd64de16851ade8b21a9a1a"}, Parts: []ObjectPartInfo{{ETag: "", Number: 1, Size: 3430, ActualSize: 3398}}, Erasure: ErasureInfo{Algorithm: "reedsolomon", DataBlocks: 2, ParityBlocks: 2, BlockSize: 10485760, Index: 3, Distribution: []int{3, 4, 1, 2}, Checksums: []ChecksumInfo{{PartNumber: 1, Algorithm: 0x3, Hash: []uint8{}}}}} |
||||
var buf bytes.Buffer |
||||
gob.NewEncoder(&buf).Encode(v) |
||||
encoded := buf.Bytes() |
||||
b.Log("Size:", buf.Len(), "bytes") |
||||
b.SetBytes(1) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
dec := gob.NewDecoder(bytes.NewBuffer(encoded)) |
||||
err := dec.Decode(&v) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func BenchmarkEncodeFileInfoMsgp(b *testing.B) { |
||||
v := FileInfo{Volume: "testbucket", Name: "src/compress/zlib/reader_test.go", VersionID: "", IsLatest: true, Deleted: false, DataDir: "5e0153cc-621a-4267-8cb6-4919140d53b3", XLV1: false, ModTime: UTCNow(), Size: 3430, Mode: 0x0, Metadata: map[string]string{"X-Minio-Internal-Server-Side-Encryption-Iv": "jIJPsrkkVYYMvc7edBrNl+7zcM7+ZwXqMb/YAjBO/ck=", "X-Minio-Internal-Server-Side-Encryption-S3-Kms-Key-Id": "my-minio-key", "X-Minio-Internal-Server-Side-Encryption-S3-Kms-Sealed-Key": "IAAfAP2p7ZLv3UpLwBnsKkF2mtWba0qoY42tymK0szRgGvAxBNcXyHXYooe9dQpeeEJWgKUa/8R61oCy1mFwIg==", "X-Minio-Internal-Server-Side-Encryption-S3-Sealed-Key": "IAAfAPFYRDkHVirJBJxBixNj3PLWt78dFuUTyTLIdLG820J7XqLPBO4gpEEEWw/DoTsJIb+apnaem+rKtQ1h3Q==", "X-Minio-Internal-Server-Side-Encryption-Seal-Algorithm": "DAREv2-HMAC-SHA256", "content-type": "application/octet-stream", "etag": "20000f00e2c3709dc94905c6ce31e1cadbd1c064e14acdcd44cf0ac2db777eeedd88d639fcd64de16851ade8b21a9a1a"}, Parts: []ObjectPartInfo{{ETag: "", Number: 1, Size: 3430, ActualSize: 3398}}, Erasure: ErasureInfo{Algorithm: "reedsolomon", DataBlocks: 2, ParityBlocks: 2, BlockSize: 10485760, Index: 3, Distribution: []int{3, 4, 1, 2}, Checksums: []ChecksumInfo{{PartNumber: 1, Algorithm: 0x3, Hash: []uint8{}}}}} |
||||
b.SetBytes(1) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
err := msgp.Encode(ioutil.Discard, &v) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
||||
|
||||
func BenchmarkEncodeFileInfoGOB(b *testing.B) { |
||||
v := FileInfo{Volume: "testbucket", Name: "src/compress/zlib/reader_test.go", VersionID: "", IsLatest: true, Deleted: false, DataDir: "5e0153cc-621a-4267-8cb6-4919140d53b3", XLV1: false, ModTime: UTCNow(), Size: 3430, Mode: 0x0, Metadata: map[string]string{"X-Minio-Internal-Server-Side-Encryption-Iv": "jIJPsrkkVYYMvc7edBrNl+7zcM7+ZwXqMb/YAjBO/ck=", "X-Minio-Internal-Server-Side-Encryption-S3-Kms-Key-Id": "my-minio-key", "X-Minio-Internal-Server-Side-Encryption-S3-Kms-Sealed-Key": "IAAfAP2p7ZLv3UpLwBnsKkF2mtWba0qoY42tymK0szRgGvAxBNcXyHXYooe9dQpeeEJWgKUa/8R61oCy1mFwIg==", "X-Minio-Internal-Server-Side-Encryption-S3-Sealed-Key": "IAAfAPFYRDkHVirJBJxBixNj3PLWt78dFuUTyTLIdLG820J7XqLPBO4gpEEEWw/DoTsJIb+apnaem+rKtQ1h3Q==", "X-Minio-Internal-Server-Side-Encryption-Seal-Algorithm": "DAREv2-HMAC-SHA256", "content-type": "application/octet-stream", "etag": "20000f00e2c3709dc94905c6ce31e1cadbd1c064e14acdcd44cf0ac2db777eeedd88d639fcd64de16851ade8b21a9a1a"}, Parts: []ObjectPartInfo{{ETag: "", Number: 1, Size: 3430, ActualSize: 3398}}, Erasure: ErasureInfo{Algorithm: "reedsolomon", DataBlocks: 2, ParityBlocks: 2, BlockSize: 10485760, Index: 3, Distribution: []int{3, 4, 1, 2}, Checksums: []ChecksumInfo{{PartNumber: 1, Algorithm: 0x3, Hash: []uint8{}}}}} |
||||
enc := gob.NewEncoder(ioutil.Discard) |
||||
b.SetBytes(1) |
||||
b.ReportAllocs() |
||||
b.ResetTimer() |
||||
for i := 0; i < b.N; i++ { |
||||
err := enc.Encode(&v) |
||||
if err != nil { |
||||
b.Fatal(err) |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue