Skip to content

Commit 6b9629f

Browse files
committed
protobuf: add vtproto as a supplemental marshaler
vtproto is an extra protobuf compiler that generates special methods suffixed with `VT` that create typed and unrolled marshal and unmarshal functions similar to gogo that can be used for performance sensitive code. These extensions are optional for code to use but buildkit uses them. A codec is also included to utilize vtproto for grpc code. If the package `github.com/moby/buildkit/util/encoding/proto` is imported then vtproto will be used if it exists and otherwise it will use the standard marshaling and unmarshaling methods. Signed-off-by: Jonathan A. Sternberg <[email protected]>
1 parent 4eccb90 commit 6b9629f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+46390
-91
lines changed

api/services/control/control_bench_test.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package moby_buildkit_v1
1+
package moby_buildkit_v1 //nolint:revive
22

33
import (
44
"testing"
55
"time"
66

7-
"github.com/opencontainers/go-digest"
7+
digest "github.com/opencontainers/go-digest"
88
"github.com/stretchr/testify/require"
9-
"google.golang.org/protobuf/proto"
9+
proto "google.golang.org/protobuf/proto"
1010
"google.golang.org/protobuf/types/known/timestamppb"
1111
)
1212

@@ -17,7 +17,7 @@ func BenchmarkMarshalVertex(b *testing.B) {
1717
v := sampleVertex()
1818
for i := 0; i < b.N; i++ {
1919
var err error
20-
Buf, err = proto.Marshal(v)
20+
Buf, err = v.MarshalVT()
2121
require.NoError(b, err)
2222
}
2323
}
@@ -26,7 +26,7 @@ func BenchmarkMarshalVertexStatus(b *testing.B) {
2626
v := sampleVertexStatus()
2727
for i := 0; i < b.N; i++ {
2828
var err error
29-
Buf, err = proto.Marshal(v)
29+
Buf, err = v.MarshalVT()
3030
require.NoError(b, err)
3131
}
3232
}
@@ -35,7 +35,7 @@ func BenchmarkMarshalVertexLog(b *testing.B) {
3535
v := sampleVertexLog()
3636
for i := 0; i < b.N; i++ {
3737
var err error
38-
Buf, err = proto.Marshal(v)
38+
Buf, err = v.MarshalVT()
3939
require.NoError(b, err)
4040
}
4141
}
@@ -48,7 +48,7 @@ func BenchmarkUnmarshalVertex(b *testing.B) {
4848
require.NoError(b, err)
4949

5050
for i := 0; i < b.N; i++ {
51-
err := proto.Unmarshal(buf, &VertexOutput)
51+
err := VertexOutput.UnmarshalVT(buf)
5252
require.NoError(b, err)
5353
}
5454
}
@@ -61,7 +61,7 @@ func BenchmarkUnmarshalVertexStatus(b *testing.B) {
6161
require.NoError(b, err)
6262

6363
for i := 0; i < b.N; i++ {
64-
err := proto.Unmarshal(buf, &VertexStatusOutput)
64+
err := VertexStatusOutput.UnmarshalVT(buf)
6565
require.NoError(b, err)
6666
}
6767
}
@@ -74,7 +74,7 @@ func BenchmarkUnmarshalVertexLog(b *testing.B) {
7474
require.NoError(b, err)
7575

7676
for i := 0; i < b.N; i++ {
77-
err := proto.Unmarshal(buf, &VertexLogOutput)
77+
err := VertexLogOutput.UnmarshalVT(buf)
7878
require.NoError(b, err)
7979
}
8080
}

0 commit comments

Comments
 (0)