proto: make safe for App Engine
Factor unsafe code into its own file that can be replaced with
reflect code when building for App Engine.
benchmark old MB/s new MB/s speedup
BenchmarkMarshal 126.34 120.38 0.95x
BenchmarkUnmarshal 111.84 110.78 0.99x
BenchmarkMarshalBytes 893.70 853.55 0.96x
BenchmarkUnmarshalBytes 615.23 619.73 1.01x
Comparing the two new variants, old = unsafe, new = reflect:
benchmark old MB/s new MB/s speedup
BenchmarkMarshal 120.38 50.52 0.42x
BenchmarkUnmarshal 110.78 20.12 0.18x
BenchmarkMarshalBytes 853.55 182.21 0.21x
BenchmarkUnmarshalBytes 619.73 227.66 0.37x
But really these numbers are unfair since they ignore the
qualitative difference: proto was completely unavailable
on App Engine, and now it can be run there.
R=dsymonds, r
CC=golang-dev
http://codereview.appspot.com/6494085
diff --git a/proto/text.go b/proto/text.go
index 18fb493..3bbf9aa 100644
--- a/proto/text.go
+++ b/proto/text.go
@@ -105,8 +105,7 @@
}
var (
- messageSetType = reflect.TypeOf((*MessageSet)(nil)).Elem()
- extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem()
+ messageSetType = reflect.TypeOf((*MessageSet)(nil)).Elem()
)
// raw is the interface satisfied by RawMessage.