mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-29 09:32:38 +00:00
98873a2050
The layers freely convert between ExtensionTypeDescriptor (via ExtensionTypeDescriptor.Type) and ExtensionType (via ExtensionType.TypeDescriptor()). For certain hot functions , like (*extensionMap).Has() and (*extensionMap).Get(), this saves a Type() and TypeDescriptor() pair. Oddly, the gains are bigger than I expected. This commit is 02-typedesciptor-not-type, it is layered on top of CL 576315 (named 01-cse-hasextension): benchstat 00-cse-messageinfo 01-cse-hasextension 02-typedesciptor-not-type goarch: amd64 cpu: AMD Ryzen Threadripper PRO 3995WX 64-Cores │ 00-cse-messageinfo │ 01-cse-hasextension │ 02-typedesciptor-not-type │ │ sec/op │ sec/op vs base │ sec/op vs base │ Extension/Has/None-12 103.30n ± 3% 96.73n ± 1% -6.36% (p=0.000 n=10) 85.54n ± 2% -17.19% (p=0.000 n=10) Extension/Has/Set-12 113.05n ± 3% 107.15n ± 1% -5.22% (p=0.000 n=10) 97.36n ± 2% -13.88% (p=0.000 n=10) Extension/Get/None-12 182.7n ± 2% 176.3n ± 2% -3.48% (p=0.000 n=10) 173.3n ± 2% -5.09% (p=0.000 n=10) Extension/Get/Set-12 140.1n ± 2% 138.0n ± 1% -1.46% (p=0.024 n=10) 135.0n ± 1% -3.64% (p=0.000 n=10) Extension/Set-12 218.6n ± 2% 219.5n ± 1% ~ (p=0.172 n=10) 210.2n ± 2% -3.82% (p=0.001 n=10) geomean 145.6n 140.8n -3.25% 132.6n -8.91% Change-Id: If9c67c680ca57b5d93f863bb1c72f3e5031ed18c Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/576316 Reviewed-by: Michael Stapelberg <stapelberg@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Nicolas Hillegeer <aktau@google.com>