|
|
|
// Protocol Buffers - Google's data interchange format
|
|
|
|
// Copyright 2023 Google LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
#include "upb/reflection/internal/def_builder.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
Implement feature inheritance and legacy editions for upb.
This switches upb to using legacy editions for all proto2/proto3 logic. This does not yet enable code generation for editions protos (ie. we do not yet turn on `FEATURE_SUPPORTS_EDITIONS`), but with feature inheritance in place, this will be a much smaller follow-on change.
There is a ~10% increase in allocations, but only a ~1% increase in peak memory. There are some <5% increases in instructions and cycles, but apparently no increase in time:
```
name old cpu/op new cpu/op delta
BM_ArenaOneAlloc 17.8ns ±11% 16.9ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 5.99ns ±13% 5.35ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.4ns ±11% 63.1ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 509ns ± 2% 532ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.73µs ±20% 4.43µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.77µs ±12% 8.64µs ± 4% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 67.5ns ±13% 62.6ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 552ns ±23% 496ns ±25% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.76µs ±14% 4.24µs ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 10.2µs ±14% 8.6µs ± 4% -15.61% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.20ms ±12% 6.18ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.91ms ±12% 6.63ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.0ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.1ms ±13% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.4µs ±13% 13.2µs ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.7µs ±12% 12.9µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.1µs ±11% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.7µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.6µs ±13% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±10% 10.6µs ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.4µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.62µs ±13% 6.00µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.1µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old time/op new time/op delta
BM_ArenaOneAlloc 17.9ns ±12% 17.0ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 6.03ns ±14% 5.36ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.9ns ±12% 63.3ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 511ns ± 2% 533ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.75µs ±20% 4.44µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.83µs ±12% 8.66µs ± 4% ~ (p=0.151 n=5+5)
BM_ArenaFuseBalanced/2 67.8ns ±13% 62.7ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 555ns ±24% 497ns ±26% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.79µs ±14% 4.25µs ± 4% ~ (p=0.310 n=5+5)
BM_ArenaFuseBalanced/128 10.3µs ±14% 8.6µs ± 4% -15.93% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.25ms ±12% 6.20ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.96ms ±13% 6.65ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.2ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.3ms ±14% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.5µs ±14% 13.2µs ± 3% ~ (p=0.690 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.8µs ±13% 13.0µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.2µs ±12% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.9µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.7µs ±14% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±11% 10.7µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.5µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.65µs ±13% 6.01µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.2µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old INSTRUCTIONS/op new INSTRUCTIONS/op delta
BM_ArenaOneAlloc 189 ± 0% 189 ± 0% ~ (p=0.881 n=5+5)
BM_ArenaInitialBlockOneAlloc 69.0 ± 0% 69.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 458 ± 0% 458 ± 0% ~ (p=1.000 n=5+5)
BM_ArenaFuseUnbalanced/8 3.28k ±15% 3.60k ± 0% ~ (p=0.286 n=5+4)
BM_ArenaFuseUnbalanced/64 28.6k ± 2% 29.2k ± 0% +2.17% (p=0.032 n=5+4)
BM_ArenaFuseUnbalanced/128 57.9k ± 1% 57.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/2 482 ± 0% 482 ± 0% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/8 3.35k ±14% 3.35k ±14% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/64 29.2k ± 2% 29.3k ± 1% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 59.2k ± 1% 59.3k ± 1% ~ (p=0.556 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 37.3M ± 0% 38.2M ± 0% +2.39% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 40.9M ± 0% 41.7M ± 0% +2.02% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 87.2M ± 0% 88.3M ± 1% +1.25% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 88.0M ± 0% 88.9M ± 1% +1.13% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 154k ± 0% 154k ± 0% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 143k ± 0% 143k ± 0% ~ (p=0.310 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 153k ± 0% 153k ± 0% ~ (p=1.016 n=5+4)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 142k ± 0% 142k ± 0% ~ (p=0.127 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 213k ± 1% 217k ± 5% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 122k ± 0% 123k ± 0% +0.86% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 120k ± 0% 120k ± 0% ~ (p=0.421 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 124k ± 0% 124k ± 0% ~ (p=0.587 n=5+5)
BM_SerializeDescriptor_Proto2 63.5k ± 0% 63.5k ± 0% ~ (p=0.278 n=5+5)
BM_SerializeDescriptor_Upb 111k ± 0% 111k ± 0% ~ (p=1.000 n=5+5)
name old CYCLES/op new CYCLES/op delta
BM_ArenaOneAlloc 53.5 ± 0% 53.4 ± 0% ~ (p=0.095 n=5+5)
BM_ArenaInitialBlockOneAlloc 17.5 ± 1% 17.4 ± 0% ~ (p=0.087 n=5+5)
BM_ArenaFuseUnbalanced/2 206 ± 0% 206 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/8 1.55k ±12% 1.67k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/64 14.1k ± 8% 14.1k ± 1% ~ (p=0.222 n=5+5)
BM_ArenaFuseUnbalanced/128 28.2k ± 1% 28.3k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/2 205 ± 0% 204 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/8 1.57k ±12% 1.56k ±12% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/64 13.9k ± 2% 13.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/128 28.1k ± 1% 28.2k ± 1% ~ (p=0.730 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 18.7M ± 0% 19.3M ± 1% +3.38% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 20.9M ± 0% 21.6M ± 0% +3.09% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 43.4M ± 0% 44.4M ± 1% +2.33% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 44.0M ± 0% 44.9M ± 2% +1.92% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 42.0k ± 1% 43.0k ± 1% +2.32% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 38.2k ± 1% 38.4k ± 0% +0.74% (p=0.032 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 41.6k ± 0% 42.6k ± 1% +2.51% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 37.6k ± 0% 38.1k ± 0% +1.34% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 71.9k ± 1% 74.1k ± 6% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 35.4k ± 1% 35.8k ± 0% +1.10% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 34.6k ± 1% 34.9k ± 1% ~ (p=0.095 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 40.5k ± 0% 40.0k ± 1% -1.36% (p=0.008 n=5+5)
BM_SerializeDescriptor_Proto2 20.1k ± 1% 19.7k ± 4% ~ (p=0.421 n=5+5)
BM_SerializeDescriptor_Upb 33.7k ± 0% 33.7k ± 0% ~ (p=0.222 n=5+5)
name old allocs/op new allocs/op delta
BM_ArenaOneAlloc 1.00 ± 0% 1.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.21k ± 0% 6.93k ± 0% +11.54% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.54k ± 0% 6.96k ± 0% +6.34% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 124k ± 0% 124k ± 0% +0.00% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 126k ± 0% 126k ± 0% +0.00% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 709 ± 0% 709 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
name old peak-mem(Bytes)/op new peak-mem(Bytes)/op delta
BM_ArenaOneAlloc 328 ± 0% 328 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 10.2M ± 0% 10.4M ± 0% +1.15% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 10.5M ± 0% 10.5M ± 0% +0.11% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 7.14M ± 0% 7.14M ± 0% ~ (p=0.317 n=4+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 7.18M ± 0% 7.18M ± 0% ~ (p=0.159 n=5+4)
BM_Parse_Upb_FileDesc<UseArena, Copy> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 35.4k ± 0% 35.4k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 65.3k ± 0% 65.3k ± 0% ~ (all samples are equal)
name old items/s new items/s delta
BM_ArenaFuseUnbalanced/2 28.2M ±12% 31.7M ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 15.7M ± 2% 15.1M ±14% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 13.7M ±18% 14.5M ± 9% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 13.2M ±12% 14.8M ± 5% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 29.9M ±12% 32.0M ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 14.8M ±28% 16.5M ±22% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 13.6M ±15% 15.1M ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 12.6M ±15% 14.9M ± 4% +17.88% (p=0.016 n=5+5)
name old speed new speed delta
BM_LoadAdsDescriptor_Upb<NoLayout> 128MB/s ±11% 128MB/s ±14% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 115MB/s ±12% 119MB/s ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 52.9MB/s ±12% 57.6MB/s ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 52.6MB/s ±14% 57.2MB/s ± 2% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 527MB/s ±14% 571MB/s ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 595MB/s ±11% 640MB/s ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 553MB/s ±12% 582MB/s ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 576MB/s ±12% 649MB/s ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 307MB/s ±13% 334MB/s ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 653MB/s ±13% 689MB/s ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 650MB/s ±10% 708MB/s ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 564MB/s ±12% 614MB/s ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 1.15GB/s ±12% 1.25GB/s ± 5% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 684MB/s ±12% 730MB/s ± 3% ~ (p=1.000 n=5+5)
```
This adds about 5Ki of code size. Some of this likely comes from the fact that we now link in `message/copy.c` to perform a deep copy of a FeatureSet proto.
```
$ /google/bin/releases/protobuf-team/bloaty/bloaty-google3-diff --blaze-build-opts="-c opt" third_party/upb/upb/conformance/conformance_upb
FILE SIZE VM SIZE
-------------- --------------
+0.5% +4.19Ki +0.5% +4.19Ki .text
+0.4% +656 +0.4% +656 .rodata
+0.1% +504 [ = ] 0 .strtab
+0.2% +384 [ = ] 0 .symtab
+0.2% +280 +0.2% +280 .eh_frame
+0.2% +216 +0.2% +216 .rela.dyn
+0.3% +96 +0.3% +96 .data.rel.ro
+0.2% +64 +0.2% +64 .eh_frame_hdr
+1.1% +16 [ = ] 0 .got.plt
+0.2% +8 +0.2% +8 .rela.plt
-4.6% -8 -4.6% -8 [LOAD #2 [RX]]
-50.0% -48 [ = ] 0 [Unmapped]
[ = ] 0 -81.7% -1.47Ki .relro_padding
+0.1% +6.30Ki +0.0% +4.00Ki TOTAL
```
PiperOrigin-RevId: 579321454
1 year ago
|
|
|
#include "upb/base/internal/log2.h"
|
|
|
|
#include "upb/base/upcast.h"
|
|
|
|
#include "upb/mem/alloc.h"
|
Implement feature inheritance and legacy editions for upb.
This switches upb to using legacy editions for all proto2/proto3 logic. This does not yet enable code generation for editions protos (ie. we do not yet turn on `FEATURE_SUPPORTS_EDITIONS`), but with feature inheritance in place, this will be a much smaller follow-on change.
There is a ~10% increase in allocations, but only a ~1% increase in peak memory. There are some <5% increases in instructions and cycles, but apparently no increase in time:
```
name old cpu/op new cpu/op delta
BM_ArenaOneAlloc 17.8ns ±11% 16.9ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 5.99ns ±13% 5.35ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.4ns ±11% 63.1ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 509ns ± 2% 532ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.73µs ±20% 4.43µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.77µs ±12% 8.64µs ± 4% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 67.5ns ±13% 62.6ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 552ns ±23% 496ns ±25% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.76µs ±14% 4.24µs ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 10.2µs ±14% 8.6µs ± 4% -15.61% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.20ms ±12% 6.18ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.91ms ±12% 6.63ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.0ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.1ms ±13% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.4µs ±13% 13.2µs ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.7µs ±12% 12.9µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.1µs ±11% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.7µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.6µs ±13% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±10% 10.6µs ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.4µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.62µs ±13% 6.00µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.1µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old time/op new time/op delta
BM_ArenaOneAlloc 17.9ns ±12% 17.0ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 6.03ns ±14% 5.36ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.9ns ±12% 63.3ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 511ns ± 2% 533ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.75µs ±20% 4.44µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.83µs ±12% 8.66µs ± 4% ~ (p=0.151 n=5+5)
BM_ArenaFuseBalanced/2 67.8ns ±13% 62.7ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 555ns ±24% 497ns ±26% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.79µs ±14% 4.25µs ± 4% ~ (p=0.310 n=5+5)
BM_ArenaFuseBalanced/128 10.3µs ±14% 8.6µs ± 4% -15.93% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.25ms ±12% 6.20ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.96ms ±13% 6.65ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.2ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.3ms ±14% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.5µs ±14% 13.2µs ± 3% ~ (p=0.690 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.8µs ±13% 13.0µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.2µs ±12% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.9µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.7µs ±14% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±11% 10.7µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.5µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.65µs ±13% 6.01µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.2µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old INSTRUCTIONS/op new INSTRUCTIONS/op delta
BM_ArenaOneAlloc 189 ± 0% 189 ± 0% ~ (p=0.881 n=5+5)
BM_ArenaInitialBlockOneAlloc 69.0 ± 0% 69.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 458 ± 0% 458 ± 0% ~ (p=1.000 n=5+5)
BM_ArenaFuseUnbalanced/8 3.28k ±15% 3.60k ± 0% ~ (p=0.286 n=5+4)
BM_ArenaFuseUnbalanced/64 28.6k ± 2% 29.2k ± 0% +2.17% (p=0.032 n=5+4)
BM_ArenaFuseUnbalanced/128 57.9k ± 1% 57.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/2 482 ± 0% 482 ± 0% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/8 3.35k ±14% 3.35k ±14% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/64 29.2k ± 2% 29.3k ± 1% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 59.2k ± 1% 59.3k ± 1% ~ (p=0.556 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 37.3M ± 0% 38.2M ± 0% +2.39% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 40.9M ± 0% 41.7M ± 0% +2.02% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 87.2M ± 0% 88.3M ± 1% +1.25% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 88.0M ± 0% 88.9M ± 1% +1.13% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 154k ± 0% 154k ± 0% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 143k ± 0% 143k ± 0% ~ (p=0.310 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 153k ± 0% 153k ± 0% ~ (p=1.016 n=5+4)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 142k ± 0% 142k ± 0% ~ (p=0.127 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 213k ± 1% 217k ± 5% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 122k ± 0% 123k ± 0% +0.86% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 120k ± 0% 120k ± 0% ~ (p=0.421 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 124k ± 0% 124k ± 0% ~ (p=0.587 n=5+5)
BM_SerializeDescriptor_Proto2 63.5k ± 0% 63.5k ± 0% ~ (p=0.278 n=5+5)
BM_SerializeDescriptor_Upb 111k ± 0% 111k ± 0% ~ (p=1.000 n=5+5)
name old CYCLES/op new CYCLES/op delta
BM_ArenaOneAlloc 53.5 ± 0% 53.4 ± 0% ~ (p=0.095 n=5+5)
BM_ArenaInitialBlockOneAlloc 17.5 ± 1% 17.4 ± 0% ~ (p=0.087 n=5+5)
BM_ArenaFuseUnbalanced/2 206 ± 0% 206 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/8 1.55k ±12% 1.67k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/64 14.1k ± 8% 14.1k ± 1% ~ (p=0.222 n=5+5)
BM_ArenaFuseUnbalanced/128 28.2k ± 1% 28.3k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/2 205 ± 0% 204 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/8 1.57k ±12% 1.56k ±12% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/64 13.9k ± 2% 13.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/128 28.1k ± 1% 28.2k ± 1% ~ (p=0.730 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 18.7M ± 0% 19.3M ± 1% +3.38% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 20.9M ± 0% 21.6M ± 0% +3.09% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 43.4M ± 0% 44.4M ± 1% +2.33% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 44.0M ± 0% 44.9M ± 2% +1.92% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 42.0k ± 1% 43.0k ± 1% +2.32% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 38.2k ± 1% 38.4k ± 0% +0.74% (p=0.032 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 41.6k ± 0% 42.6k ± 1% +2.51% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 37.6k ± 0% 38.1k ± 0% +1.34% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 71.9k ± 1% 74.1k ± 6% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 35.4k ± 1% 35.8k ± 0% +1.10% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 34.6k ± 1% 34.9k ± 1% ~ (p=0.095 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 40.5k ± 0% 40.0k ± 1% -1.36% (p=0.008 n=5+5)
BM_SerializeDescriptor_Proto2 20.1k ± 1% 19.7k ± 4% ~ (p=0.421 n=5+5)
BM_SerializeDescriptor_Upb 33.7k ± 0% 33.7k ± 0% ~ (p=0.222 n=5+5)
name old allocs/op new allocs/op delta
BM_ArenaOneAlloc 1.00 ± 0% 1.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.21k ± 0% 6.93k ± 0% +11.54% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.54k ± 0% 6.96k ± 0% +6.34% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 124k ± 0% 124k ± 0% +0.00% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 126k ± 0% 126k ± 0% +0.00% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 709 ± 0% 709 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
name old peak-mem(Bytes)/op new peak-mem(Bytes)/op delta
BM_ArenaOneAlloc 328 ± 0% 328 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 10.2M ± 0% 10.4M ± 0% +1.15% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 10.5M ± 0% 10.5M ± 0% +0.11% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 7.14M ± 0% 7.14M ± 0% ~ (p=0.317 n=4+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 7.18M ± 0% 7.18M ± 0% ~ (p=0.159 n=5+4)
BM_Parse_Upb_FileDesc<UseArena, Copy> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 35.4k ± 0% 35.4k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 65.3k ± 0% 65.3k ± 0% ~ (all samples are equal)
name old items/s new items/s delta
BM_ArenaFuseUnbalanced/2 28.2M ±12% 31.7M ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 15.7M ± 2% 15.1M ±14% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 13.7M ±18% 14.5M ± 9% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 13.2M ±12% 14.8M ± 5% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 29.9M ±12% 32.0M ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 14.8M ±28% 16.5M ±22% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 13.6M ±15% 15.1M ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 12.6M ±15% 14.9M ± 4% +17.88% (p=0.016 n=5+5)
name old speed new speed delta
BM_LoadAdsDescriptor_Upb<NoLayout> 128MB/s ±11% 128MB/s ±14% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 115MB/s ±12% 119MB/s ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 52.9MB/s ±12% 57.6MB/s ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 52.6MB/s ±14% 57.2MB/s ± 2% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 527MB/s ±14% 571MB/s ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 595MB/s ±11% 640MB/s ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 553MB/s ±12% 582MB/s ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 576MB/s ±12% 649MB/s ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 307MB/s ±13% 334MB/s ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 653MB/s ±13% 689MB/s ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 650MB/s ±10% 708MB/s ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 564MB/s ±12% 614MB/s ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 1.15GB/s ±12% 1.25GB/s ± 5% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 684MB/s ±12% 730MB/s ± 3% ~ (p=1.000 n=5+5)
```
This adds about 5Ki of code size. Some of this likely comes from the fact that we now link in `message/copy.c` to perform a deep copy of a FeatureSet proto.
```
$ /google/bin/releases/protobuf-team/bloaty/bloaty-google3-diff --blaze-build-opts="-c opt" third_party/upb/upb/conformance/conformance_upb
FILE SIZE VM SIZE
-------------- --------------
+0.5% +4.19Ki +0.5% +4.19Ki .text
+0.4% +656 +0.4% +656 .rodata
+0.1% +504 [ = ] 0 .strtab
+0.2% +384 [ = ] 0 .symtab
+0.2% +280 +0.2% +280 .eh_frame
+0.2% +216 +0.2% +216 .rela.dyn
+0.3% +96 +0.3% +96 .data.rel.ro
+0.2% +64 +0.2% +64 .eh_frame_hdr
+1.1% +16 [ = ] 0 .got.plt
+0.2% +8 +0.2% +8 .rela.plt
-4.6% -8 -4.6% -8 [LOAD #2 [RX]]
-50.0% -48 [ = ] 0 [Unmapped]
[ = ] 0 -81.7% -1.47Ki .relro_padding
+0.1% +6.30Ki +0.0% +4.00Ki TOTAL
```
PiperOrigin-RevId: 579321454
1 year ago
|
|
|
#include "upb/message/copy.h"
|
|
|
|
#include "upb/reflection/def_pool.h"
|
|
|
|
#include "upb/reflection/def_type.h"
|
|
|
|
#include "upb/reflection/field_def.h"
|
Implement feature inheritance and legacy editions for upb.
This switches upb to using legacy editions for all proto2/proto3 logic. This does not yet enable code generation for editions protos (ie. we do not yet turn on `FEATURE_SUPPORTS_EDITIONS`), but with feature inheritance in place, this will be a much smaller follow-on change.
There is a ~10% increase in allocations, but only a ~1% increase in peak memory. There are some <5% increases in instructions and cycles, but apparently no increase in time:
```
name old cpu/op new cpu/op delta
BM_ArenaOneAlloc 17.8ns ±11% 16.9ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 5.99ns ±13% 5.35ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.4ns ±11% 63.1ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 509ns ± 2% 532ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.73µs ±20% 4.43µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.77µs ±12% 8.64µs ± 4% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 67.5ns ±13% 62.6ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 552ns ±23% 496ns ±25% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.76µs ±14% 4.24µs ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 10.2µs ±14% 8.6µs ± 4% -15.61% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.20ms ±12% 6.18ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.91ms ±12% 6.63ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.0ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.1ms ±13% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.4µs ±13% 13.2µs ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.7µs ±12% 12.9µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.1µs ±11% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.7µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.6µs ±13% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±10% 10.6µs ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.4µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.62µs ±13% 6.00µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.1µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old time/op new time/op delta
BM_ArenaOneAlloc 17.9ns ±12% 17.0ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 6.03ns ±14% 5.36ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.9ns ±12% 63.3ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 511ns ± 2% 533ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.75µs ±20% 4.44µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.83µs ±12% 8.66µs ± 4% ~ (p=0.151 n=5+5)
BM_ArenaFuseBalanced/2 67.8ns ±13% 62.7ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 555ns ±24% 497ns ±26% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.79µs ±14% 4.25µs ± 4% ~ (p=0.310 n=5+5)
BM_ArenaFuseBalanced/128 10.3µs ±14% 8.6µs ± 4% -15.93% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.25ms ±12% 6.20ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.96ms ±13% 6.65ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.2ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.3ms ±14% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.5µs ±14% 13.2µs ± 3% ~ (p=0.690 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.8µs ±13% 13.0µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.2µs ±12% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.9µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.7µs ±14% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±11% 10.7µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.5µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.65µs ±13% 6.01µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.2µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old INSTRUCTIONS/op new INSTRUCTIONS/op delta
BM_ArenaOneAlloc 189 ± 0% 189 ± 0% ~ (p=0.881 n=5+5)
BM_ArenaInitialBlockOneAlloc 69.0 ± 0% 69.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 458 ± 0% 458 ± 0% ~ (p=1.000 n=5+5)
BM_ArenaFuseUnbalanced/8 3.28k ±15% 3.60k ± 0% ~ (p=0.286 n=5+4)
BM_ArenaFuseUnbalanced/64 28.6k ± 2% 29.2k ± 0% +2.17% (p=0.032 n=5+4)
BM_ArenaFuseUnbalanced/128 57.9k ± 1% 57.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/2 482 ± 0% 482 ± 0% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/8 3.35k ±14% 3.35k ±14% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/64 29.2k ± 2% 29.3k ± 1% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 59.2k ± 1% 59.3k ± 1% ~ (p=0.556 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 37.3M ± 0% 38.2M ± 0% +2.39% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 40.9M ± 0% 41.7M ± 0% +2.02% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 87.2M ± 0% 88.3M ± 1% +1.25% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 88.0M ± 0% 88.9M ± 1% +1.13% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 154k ± 0% 154k ± 0% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 143k ± 0% 143k ± 0% ~ (p=0.310 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 153k ± 0% 153k ± 0% ~ (p=1.016 n=5+4)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 142k ± 0% 142k ± 0% ~ (p=0.127 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 213k ± 1% 217k ± 5% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 122k ± 0% 123k ± 0% +0.86% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 120k ± 0% 120k ± 0% ~ (p=0.421 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 124k ± 0% 124k ± 0% ~ (p=0.587 n=5+5)
BM_SerializeDescriptor_Proto2 63.5k ± 0% 63.5k ± 0% ~ (p=0.278 n=5+5)
BM_SerializeDescriptor_Upb 111k ± 0% 111k ± 0% ~ (p=1.000 n=5+5)
name old CYCLES/op new CYCLES/op delta
BM_ArenaOneAlloc 53.5 ± 0% 53.4 ± 0% ~ (p=0.095 n=5+5)
BM_ArenaInitialBlockOneAlloc 17.5 ± 1% 17.4 ± 0% ~ (p=0.087 n=5+5)
BM_ArenaFuseUnbalanced/2 206 ± 0% 206 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/8 1.55k ±12% 1.67k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/64 14.1k ± 8% 14.1k ± 1% ~ (p=0.222 n=5+5)
BM_ArenaFuseUnbalanced/128 28.2k ± 1% 28.3k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/2 205 ± 0% 204 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/8 1.57k ±12% 1.56k ±12% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/64 13.9k ± 2% 13.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/128 28.1k ± 1% 28.2k ± 1% ~ (p=0.730 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 18.7M ± 0% 19.3M ± 1% +3.38% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 20.9M ± 0% 21.6M ± 0% +3.09% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 43.4M ± 0% 44.4M ± 1% +2.33% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 44.0M ± 0% 44.9M ± 2% +1.92% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 42.0k ± 1% 43.0k ± 1% +2.32% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 38.2k ± 1% 38.4k ± 0% +0.74% (p=0.032 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 41.6k ± 0% 42.6k ± 1% +2.51% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 37.6k ± 0% 38.1k ± 0% +1.34% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 71.9k ± 1% 74.1k ± 6% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 35.4k ± 1% 35.8k ± 0% +1.10% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 34.6k ± 1% 34.9k ± 1% ~ (p=0.095 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 40.5k ± 0% 40.0k ± 1% -1.36% (p=0.008 n=5+5)
BM_SerializeDescriptor_Proto2 20.1k ± 1% 19.7k ± 4% ~ (p=0.421 n=5+5)
BM_SerializeDescriptor_Upb 33.7k ± 0% 33.7k ± 0% ~ (p=0.222 n=5+5)
name old allocs/op new allocs/op delta
BM_ArenaOneAlloc 1.00 ± 0% 1.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.21k ± 0% 6.93k ± 0% +11.54% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.54k ± 0% 6.96k ± 0% +6.34% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 124k ± 0% 124k ± 0% +0.00% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 126k ± 0% 126k ± 0% +0.00% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 709 ± 0% 709 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
name old peak-mem(Bytes)/op new peak-mem(Bytes)/op delta
BM_ArenaOneAlloc 328 ± 0% 328 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 10.2M ± 0% 10.4M ± 0% +1.15% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 10.5M ± 0% 10.5M ± 0% +0.11% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 7.14M ± 0% 7.14M ± 0% ~ (p=0.317 n=4+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 7.18M ± 0% 7.18M ± 0% ~ (p=0.159 n=5+4)
BM_Parse_Upb_FileDesc<UseArena, Copy> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 35.4k ± 0% 35.4k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 65.3k ± 0% 65.3k ± 0% ~ (all samples are equal)
name old items/s new items/s delta
BM_ArenaFuseUnbalanced/2 28.2M ±12% 31.7M ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 15.7M ± 2% 15.1M ±14% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 13.7M ±18% 14.5M ± 9% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 13.2M ±12% 14.8M ± 5% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 29.9M ±12% 32.0M ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 14.8M ±28% 16.5M ±22% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 13.6M ±15% 15.1M ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 12.6M ±15% 14.9M ± 4% +17.88% (p=0.016 n=5+5)
name old speed new speed delta
BM_LoadAdsDescriptor_Upb<NoLayout> 128MB/s ±11% 128MB/s ±14% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 115MB/s ±12% 119MB/s ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 52.9MB/s ±12% 57.6MB/s ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 52.6MB/s ±14% 57.2MB/s ± 2% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 527MB/s ±14% 571MB/s ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 595MB/s ±11% 640MB/s ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 553MB/s ±12% 582MB/s ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 576MB/s ±12% 649MB/s ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 307MB/s ±13% 334MB/s ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 653MB/s ±13% 689MB/s ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 650MB/s ±10% 708MB/s ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 564MB/s ±12% 614MB/s ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 1.15GB/s ±12% 1.25GB/s ± 5% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 684MB/s ±12% 730MB/s ± 3% ~ (p=1.000 n=5+5)
```
This adds about 5Ki of code size. Some of this likely comes from the fact that we now link in `message/copy.c` to perform a deep copy of a FeatureSet proto.
```
$ /google/bin/releases/protobuf-team/bloaty/bloaty-google3-diff --blaze-build-opts="-c opt" third_party/upb/upb/conformance/conformance_upb
FILE SIZE VM SIZE
-------------- --------------
+0.5% +4.19Ki +0.5% +4.19Ki .text
+0.4% +656 +0.4% +656 .rodata
+0.1% +504 [ = ] 0 .strtab
+0.2% +384 [ = ] 0 .symtab
+0.2% +280 +0.2% +280 .eh_frame
+0.2% +216 +0.2% +216 .rela.dyn
+0.3% +96 +0.3% +96 .data.rel.ro
+0.2% +64 +0.2% +64 .eh_frame_hdr
+1.1% +16 [ = ] 0 .got.plt
+0.2% +8 +0.2% +8 .rela.plt
-4.6% -8 -4.6% -8 [LOAD #2 [RX]]
-50.0% -48 [ = ] 0 [Unmapped]
[ = ] 0 -81.7% -1.47Ki .relro_padding
+0.1% +6.30Ki +0.0% +4.00Ki TOTAL
```
PiperOrigin-RevId: 579321454
1 year ago
|
|
|
#include "upb/reflection/file_def.h"
|
|
|
|
#include "upb/reflection/internal/strdup2.h"
|
|
|
|
#include "upb/wire/decode.h"
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
#include "upb/port/def.inc"
|
|
|
|
|
|
|
|
/* The upb core does not generally have a concept of default instances. However
|
|
|
|
* for descriptor options we make an exception since the max size is known and
|
|
|
|
* modest (<200 bytes). All types can share a default instance since it is
|
|
|
|
* initialized to zeroes.
|
|
|
|
*
|
|
|
|
* We have to allocate an extra pointer for upb's internal metadata. */
|
|
|
|
static UPB_ALIGN_AS(8) const
|
|
|
|
char opt_default_buf[_UPB_MAXOPT_SIZE + sizeof(void*)] = {0};
|
|
|
|
const char* kUpbDefOptDefault = &opt_default_buf[sizeof(void*)];
|
|
|
|
|
|
|
|
const char* _upb_DefBuilder_FullToShort(const char* fullname) {
|
|
|
|
const char* p;
|
|
|
|
|
|
|
|
if (fullname == NULL) {
|
|
|
|
return NULL;
|
|
|
|
} else if ((p = strrchr(fullname, '.')) == NULL) {
|
|
|
|
/* No '.' in the name, return the full string. */
|
|
|
|
return fullname;
|
|
|
|
} else {
|
|
|
|
/* Return one past the last '.'. */
|
|
|
|
return p + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _upb_DefBuilder_FailJmp(upb_DefBuilder* ctx) { UPB_LONGJMP(ctx->err, 1); }
|
|
|
|
|
|
|
|
void _upb_DefBuilder_Errf(upb_DefBuilder* ctx, const char* fmt, ...) {
|
|
|
|
va_list argp;
|
|
|
|
va_start(argp, fmt);
|
|
|
|
upb_Status_VSetErrorFormat(ctx->status, fmt, argp);
|
|
|
|
va_end(argp);
|
|
|
|
_upb_DefBuilder_FailJmp(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _upb_DefBuilder_OomErr(upb_DefBuilder* ctx) {
|
|
|
|
upb_Status_SetErrorMessage(ctx->status, "out of memory");
|
|
|
|
_upb_DefBuilder_FailJmp(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify a relative identifier string. The loop is branchless for speed.
|
|
|
|
static void _upb_DefBuilder_CheckIdentNotFull(upb_DefBuilder* ctx,
|
|
|
|
upb_StringView name) {
|
|
|
|
bool good = name.size > 0;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < name.size; i++) {
|
|
|
|
const char c = name.data[i];
|
|
|
|
const char d = c | 0x20; // force lowercase
|
|
|
|
const bool is_alpha = (('a' <= d) & (d <= 'z')) | (c == '_');
|
|
|
|
const bool is_numer = ('0' <= c) & (c <= '9') & (i != 0);
|
|
|
|
|
|
|
|
good &= is_alpha | is_numer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!good) _upb_DefBuilder_CheckIdentSlow(ctx, name, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* _upb_DefBuilder_MakeFullName(upb_DefBuilder* ctx,
|
|
|
|
const char* prefix,
|
|
|
|
upb_StringView name) {
|
|
|
|
_upb_DefBuilder_CheckIdentNotFull(ctx, name);
|
|
|
|
if (prefix) {
|
|
|
|
// ret = prefix + '.' + name;
|
|
|
|
size_t n = strlen(prefix);
|
|
|
|
char* ret = _upb_DefBuilder_Alloc(ctx, n + name.size + 2);
|
|
|
|
strcpy(ret, prefix);
|
|
|
|
ret[n] = '.';
|
|
|
|
memcpy(&ret[n + 1], name.data, name.size);
|
|
|
|
ret[n + 1 + name.size] = '\0';
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
char* ret = upb_strdup2(name.data, name.size, ctx->arena);
|
|
|
|
if (!ret) _upb_DefBuilder_OomErr(ctx);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool remove_component(char* base, size_t* len) {
|
|
|
|
if (*len == 0) return false;
|
|
|
|
|
|
|
|
for (size_t i = *len - 1; i > 0; i--) {
|
|
|
|
if (base[i] == '.') {
|
|
|
|
*len = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*len = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const void* _upb_DefBuilder_ResolveAny(upb_DefBuilder* ctx,
|
|
|
|
const char* from_name_dbg,
|
|
|
|
const char* base, upb_StringView sym,
|
|
|
|
upb_deftype_t* type) {
|
|
|
|
if (sym.size == 0) goto notfound;
|
|
|
|
upb_value v;
|
|
|
|
if (sym.data[0] == '.') {
|
|
|
|
// Symbols starting with '.' are absolute, so we do a single lookup.
|
|
|
|
// Slice to omit the leading '.'
|
|
|
|
if (!_upb_DefPool_LookupSym(ctx->symtab, sym.data + 1, sym.size - 1, &v)) {
|
|
|
|
goto notfound;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Remove components from base until we find an entry or run out.
|
|
|
|
size_t baselen = base ? strlen(base) : 0;
|
|
|
|
char* tmp = upb_gmalloc(sym.size + baselen + 1);
|
|
|
|
while (1) {
|
|
|
|
char* p = tmp;
|
|
|
|
if (baselen) {
|
|
|
|
memcpy(p, base, baselen);
|
|
|
|
p[baselen] = '.';
|
|
|
|
p += baselen + 1;
|
|
|
|
}
|
|
|
|
memcpy(p, sym.data, sym.size);
|
|
|
|
p += sym.size;
|
|
|
|
if (_upb_DefPool_LookupSym(ctx->symtab, tmp, p - tmp, &v)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!remove_component(tmp, &baselen)) {
|
|
|
|
upb_gfree(tmp);
|
|
|
|
goto notfound;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
upb_gfree(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
*type = _upb_DefType_Type(v);
|
|
|
|
return _upb_DefType_Unpack(v, *type);
|
|
|
|
|
|
|
|
notfound:
|
|
|
|
_upb_DefBuilder_Errf(ctx, "couldn't resolve name '" UPB_STRINGVIEW_FORMAT "'",
|
|
|
|
UPB_STRINGVIEW_ARGS(sym));
|
|
|
|
}
|
|
|
|
|
|
|
|
const void* _upb_DefBuilder_Resolve(upb_DefBuilder* ctx,
|
|
|
|
const char* from_name_dbg, const char* base,
|
|
|
|
upb_StringView sym, upb_deftype_t type) {
|
|
|
|
upb_deftype_t found_type;
|
|
|
|
const void* ret =
|
|
|
|
_upb_DefBuilder_ResolveAny(ctx, from_name_dbg, base, sym, &found_type);
|
|
|
|
if (ret && found_type != type) {
|
|
|
|
_upb_DefBuilder_Errf(ctx,
|
|
|
|
"type mismatch when resolving %s: couldn't find "
|
|
|
|
"name " UPB_STRINGVIEW_FORMAT " with type=%d",
|
|
|
|
from_name_dbg, UPB_STRINGVIEW_ARGS(sym), (int)type);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Per ASCII this will lower-case a letter. If the result is a letter, the
|
|
|
|
// input was definitely a letter. If the output is not a letter, this may
|
|
|
|
// have transformed the character unpredictably.
|
|
|
|
static char upb_ascii_lower(char ch) { return ch | 0x20; }
|
|
|
|
|
|
|
|
// isalpha() etc. from <ctype.h> are locale-dependent, which we don't want.
|
|
|
|
static bool upb_isbetween(uint8_t c, uint8_t low, uint8_t high) {
|
|
|
|
return low <= c && c <= high;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool upb_isletter(char c) {
|
|
|
|
char lower = upb_ascii_lower(c);
|
|
|
|
return upb_isbetween(lower, 'a', 'z') || c == '_';
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool upb_isalphanum(char c) {
|
|
|
|
return upb_isletter(c) || upb_isbetween(c, '0', '9');
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool TryGetChar(const char** src, const char* end, char* ch) {
|
|
|
|
if (*src == end) return false;
|
|
|
|
*ch = **src;
|
|
|
|
*src += 1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int TryGetHexDigit(const char** src, const char* end) {
|
|
|
|
char ch;
|
|
|
|
if (!TryGetChar(src, end, &ch)) return -1;
|
|
|
|
if ('0' <= ch && ch <= '9') {
|
|
|
|
return ch - '0';
|
|
|
|
}
|
|
|
|
ch = upb_ascii_lower(ch);
|
|
|
|
if ('a' <= ch && ch <= 'f') {
|
|
|
|
return ch - 'a' + 0xa;
|
|
|
|
}
|
|
|
|
*src -= 1; // Char wasn't actually a hex digit.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char upb_DefBuilder_ParseHexEscape(upb_DefBuilder* ctx,
|
|
|
|
const upb_FieldDef* f,
|
|
|
|
const char** src, const char* end) {
|
|
|
|
int hex_digit = TryGetHexDigit(src, end);
|
|
|
|
if (hex_digit < 0) {
|
|
|
|
_upb_DefBuilder_Errf(
|
|
|
|
ctx, "\\x must be followed by at least one hex digit (field='%s')",
|
|
|
|
upb_FieldDef_FullName(f));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
unsigned int ret = hex_digit;
|
|
|
|
while ((hex_digit = TryGetHexDigit(src, end)) >= 0) {
|
|
|
|
ret = (ret << 4) | hex_digit;
|
|
|
|
}
|
|
|
|
if (ret > 0xff) {
|
|
|
|
_upb_DefBuilder_Errf(ctx, "Value of hex escape in field %s exceeds 8 bits",
|
|
|
|
upb_FieldDef_FullName(f));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char TryGetOctalDigit(const char** src, const char* end) {
|
|
|
|
char ch;
|
|
|
|
if (!TryGetChar(src, end, &ch)) return -1;
|
|
|
|
if ('0' <= ch && ch <= '7') {
|
|
|
|
return ch - '0';
|
|
|
|
}
|
|
|
|
*src -= 1; // Char wasn't actually an octal digit.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char upb_DefBuilder_ParseOctalEscape(upb_DefBuilder* ctx,
|
|
|
|
const upb_FieldDef* f,
|
|
|
|
const char** src, const char* end) {
|
|
|
|
char ch = 0;
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
char digit;
|
|
|
|
if ((digit = TryGetOctalDigit(src, end)) >= 0) {
|
|
|
|
ch = (ch << 3) | digit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
char _upb_DefBuilder_ParseEscape(upb_DefBuilder* ctx, const upb_FieldDef* f,
|
|
|
|
const char** src, const char* end) {
|
|
|
|
char ch;
|
|
|
|
if (!TryGetChar(src, end, &ch)) {
|
|
|
|
_upb_DefBuilder_Errf(ctx, "unterminated escape sequence in field %s",
|
|
|
|
upb_FieldDef_FullName(f));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
switch (ch) {
|
|
|
|
case 'a':
|
|
|
|
return '\a';
|
|
|
|
case 'b':
|
|
|
|
return '\b';
|
|
|
|
case 'f':
|
|
|
|
return '\f';
|
|
|
|
case 'n':
|
|
|
|
return '\n';
|
|
|
|
case 'r':
|
|
|
|
return '\r';
|
|
|
|
case 't':
|
|
|
|
return '\t';
|
|
|
|
case 'v':
|
|
|
|
return '\v';
|
|
|
|
case '\\':
|
|
|
|
return '\\';
|
|
|
|
case '\'':
|
|
|
|
return '\'';
|
|
|
|
case '\"':
|
|
|
|
return '\"';
|
|
|
|
case '?':
|
|
|
|
return '\?';
|
|
|
|
case 'x':
|
|
|
|
case 'X':
|
|
|
|
return upb_DefBuilder_ParseHexEscape(ctx, f, src, end);
|
|
|
|
case '0':
|
|
|
|
case '1':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
*src -= 1;
|
|
|
|
return upb_DefBuilder_ParseOctalEscape(ctx, f, src, end);
|
|
|
|
}
|
|
|
|
_upb_DefBuilder_Errf(ctx, "Unknown escape sequence: \\%c", ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _upb_DefBuilder_CheckIdentSlow(upb_DefBuilder* ctx, upb_StringView name,
|
|
|
|
bool full) {
|
|
|
|
const char* str = name.data;
|
|
|
|
const size_t len = name.size;
|
|
|
|
bool start = true;
|
|
|
|
for (size_t i = 0; i < len; i++) {
|
|
|
|
const char c = str[i];
|
|
|
|
if (c == '.') {
|
|
|
|
if (start || !full) {
|
|
|
|
_upb_DefBuilder_Errf(
|
|
|
|
ctx, "invalid name: unexpected '.' (" UPB_STRINGVIEW_FORMAT ")",
|
|
|
|
UPB_STRINGVIEW_ARGS(name));
|
|
|
|
}
|
|
|
|
start = true;
|
|
|
|
} else if (start) {
|
|
|
|
if (!upb_isletter(c)) {
|
|
|
|
_upb_DefBuilder_Errf(ctx,
|
|
|
|
"invalid name: path components must start with a "
|
|
|
|
"letter (" UPB_STRINGVIEW_FORMAT ")",
|
|
|
|
UPB_STRINGVIEW_ARGS(name));
|
|
|
|
}
|
|
|
|
start = false;
|
|
|
|
} else if (!upb_isalphanum(c)) {
|
|
|
|
_upb_DefBuilder_Errf(
|
|
|
|
ctx,
|
|
|
|
"invalid name: non-alphanumeric character (" UPB_STRINGVIEW_FORMAT
|
|
|
|
")",
|
|
|
|
UPB_STRINGVIEW_ARGS(name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (start) {
|
|
|
|
_upb_DefBuilder_Errf(ctx,
|
|
|
|
"invalid name: empty part (" UPB_STRINGVIEW_FORMAT ")",
|
|
|
|
UPB_STRINGVIEW_ARGS(name));
|
|
|
|
}
|
|
|
|
|
|
|
|
// We should never reach this point.
|
|
|
|
UPB_ASSERT(false);
|
|
|
|
}
|
Implement feature inheritance and legacy editions for upb.
This switches upb to using legacy editions for all proto2/proto3 logic. This does not yet enable code generation for editions protos (ie. we do not yet turn on `FEATURE_SUPPORTS_EDITIONS`), but with feature inheritance in place, this will be a much smaller follow-on change.
There is a ~10% increase in allocations, but only a ~1% increase in peak memory. There are some <5% increases in instructions and cycles, but apparently no increase in time:
```
name old cpu/op new cpu/op delta
BM_ArenaOneAlloc 17.8ns ±11% 16.9ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 5.99ns ±13% 5.35ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.4ns ±11% 63.1ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 509ns ± 2% 532ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.73µs ±20% 4.43µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.77µs ±12% 8.64µs ± 4% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 67.5ns ±13% 62.6ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 552ns ±23% 496ns ±25% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.76µs ±14% 4.24µs ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 10.2µs ±14% 8.6µs ± 4% -15.61% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.20ms ±12% 6.18ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.91ms ±12% 6.63ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.0ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.1ms ±13% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.4µs ±13% 13.2µs ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.7µs ±12% 12.9µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.1µs ±11% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.7µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.6µs ±13% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±10% 10.6µs ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.4µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.62µs ±13% 6.00µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.1µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old time/op new time/op delta
BM_ArenaOneAlloc 17.9ns ±12% 17.0ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 6.03ns ±14% 5.36ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.9ns ±12% 63.3ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 511ns ± 2% 533ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.75µs ±20% 4.44µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.83µs ±12% 8.66µs ± 4% ~ (p=0.151 n=5+5)
BM_ArenaFuseBalanced/2 67.8ns ±13% 62.7ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 555ns ±24% 497ns ±26% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.79µs ±14% 4.25µs ± 4% ~ (p=0.310 n=5+5)
BM_ArenaFuseBalanced/128 10.3µs ±14% 8.6µs ± 4% -15.93% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.25ms ±12% 6.20ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.96ms ±13% 6.65ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.2ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.3ms ±14% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.5µs ±14% 13.2µs ± 3% ~ (p=0.690 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.8µs ±13% 13.0µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.2µs ±12% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.9µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.7µs ±14% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±11% 10.7µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.5µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.65µs ±13% 6.01µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.2µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old INSTRUCTIONS/op new INSTRUCTIONS/op delta
BM_ArenaOneAlloc 189 ± 0% 189 ± 0% ~ (p=0.881 n=5+5)
BM_ArenaInitialBlockOneAlloc 69.0 ± 0% 69.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 458 ± 0% 458 ± 0% ~ (p=1.000 n=5+5)
BM_ArenaFuseUnbalanced/8 3.28k ±15% 3.60k ± 0% ~ (p=0.286 n=5+4)
BM_ArenaFuseUnbalanced/64 28.6k ± 2% 29.2k ± 0% +2.17% (p=0.032 n=5+4)
BM_ArenaFuseUnbalanced/128 57.9k ± 1% 57.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/2 482 ± 0% 482 ± 0% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/8 3.35k ±14% 3.35k ±14% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/64 29.2k ± 2% 29.3k ± 1% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 59.2k ± 1% 59.3k ± 1% ~ (p=0.556 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 37.3M ± 0% 38.2M ± 0% +2.39% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 40.9M ± 0% 41.7M ± 0% +2.02% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 87.2M ± 0% 88.3M ± 1% +1.25% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 88.0M ± 0% 88.9M ± 1% +1.13% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 154k ± 0% 154k ± 0% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 143k ± 0% 143k ± 0% ~ (p=0.310 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 153k ± 0% 153k ± 0% ~ (p=1.016 n=5+4)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 142k ± 0% 142k ± 0% ~ (p=0.127 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 213k ± 1% 217k ± 5% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 122k ± 0% 123k ± 0% +0.86% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 120k ± 0% 120k ± 0% ~ (p=0.421 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 124k ± 0% 124k ± 0% ~ (p=0.587 n=5+5)
BM_SerializeDescriptor_Proto2 63.5k ± 0% 63.5k ± 0% ~ (p=0.278 n=5+5)
BM_SerializeDescriptor_Upb 111k ± 0% 111k ± 0% ~ (p=1.000 n=5+5)
name old CYCLES/op new CYCLES/op delta
BM_ArenaOneAlloc 53.5 ± 0% 53.4 ± 0% ~ (p=0.095 n=5+5)
BM_ArenaInitialBlockOneAlloc 17.5 ± 1% 17.4 ± 0% ~ (p=0.087 n=5+5)
BM_ArenaFuseUnbalanced/2 206 ± 0% 206 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/8 1.55k ±12% 1.67k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/64 14.1k ± 8% 14.1k ± 1% ~ (p=0.222 n=5+5)
BM_ArenaFuseUnbalanced/128 28.2k ± 1% 28.3k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/2 205 ± 0% 204 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/8 1.57k ±12% 1.56k ±12% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/64 13.9k ± 2% 13.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/128 28.1k ± 1% 28.2k ± 1% ~ (p=0.730 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 18.7M ± 0% 19.3M ± 1% +3.38% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 20.9M ± 0% 21.6M ± 0% +3.09% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 43.4M ± 0% 44.4M ± 1% +2.33% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 44.0M ± 0% 44.9M ± 2% +1.92% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 42.0k ± 1% 43.0k ± 1% +2.32% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 38.2k ± 1% 38.4k ± 0% +0.74% (p=0.032 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 41.6k ± 0% 42.6k ± 1% +2.51% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 37.6k ± 0% 38.1k ± 0% +1.34% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 71.9k ± 1% 74.1k ± 6% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 35.4k ± 1% 35.8k ± 0% +1.10% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 34.6k ± 1% 34.9k ± 1% ~ (p=0.095 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 40.5k ± 0% 40.0k ± 1% -1.36% (p=0.008 n=5+5)
BM_SerializeDescriptor_Proto2 20.1k ± 1% 19.7k ± 4% ~ (p=0.421 n=5+5)
BM_SerializeDescriptor_Upb 33.7k ± 0% 33.7k ± 0% ~ (p=0.222 n=5+5)
name old allocs/op new allocs/op delta
BM_ArenaOneAlloc 1.00 ± 0% 1.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.21k ± 0% 6.93k ± 0% +11.54% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.54k ± 0% 6.96k ± 0% +6.34% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 124k ± 0% 124k ± 0% +0.00% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 126k ± 0% 126k ± 0% +0.00% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 709 ± 0% 709 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
name old peak-mem(Bytes)/op new peak-mem(Bytes)/op delta
BM_ArenaOneAlloc 328 ± 0% 328 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 10.2M ± 0% 10.4M ± 0% +1.15% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 10.5M ± 0% 10.5M ± 0% +0.11% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 7.14M ± 0% 7.14M ± 0% ~ (p=0.317 n=4+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 7.18M ± 0% 7.18M ± 0% ~ (p=0.159 n=5+4)
BM_Parse_Upb_FileDesc<UseArena, Copy> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 35.4k ± 0% 35.4k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 65.3k ± 0% 65.3k ± 0% ~ (all samples are equal)
name old items/s new items/s delta
BM_ArenaFuseUnbalanced/2 28.2M ±12% 31.7M ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 15.7M ± 2% 15.1M ±14% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 13.7M ±18% 14.5M ± 9% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 13.2M ±12% 14.8M ± 5% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 29.9M ±12% 32.0M ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 14.8M ±28% 16.5M ±22% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 13.6M ±15% 15.1M ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 12.6M ±15% 14.9M ± 4% +17.88% (p=0.016 n=5+5)
name old speed new speed delta
BM_LoadAdsDescriptor_Upb<NoLayout> 128MB/s ±11% 128MB/s ±14% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 115MB/s ±12% 119MB/s ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 52.9MB/s ±12% 57.6MB/s ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 52.6MB/s ±14% 57.2MB/s ± 2% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 527MB/s ±14% 571MB/s ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 595MB/s ±11% 640MB/s ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 553MB/s ±12% 582MB/s ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 576MB/s ±12% 649MB/s ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 307MB/s ±13% 334MB/s ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 653MB/s ±13% 689MB/s ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 650MB/s ±10% 708MB/s ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 564MB/s ±12% 614MB/s ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 1.15GB/s ±12% 1.25GB/s ± 5% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 684MB/s ±12% 730MB/s ± 3% ~ (p=1.000 n=5+5)
```
This adds about 5Ki of code size. Some of this likely comes from the fact that we now link in `message/copy.c` to perform a deep copy of a FeatureSet proto.
```
$ /google/bin/releases/protobuf-team/bloaty/bloaty-google3-diff --blaze-build-opts="-c opt" third_party/upb/upb/conformance/conformance_upb
FILE SIZE VM SIZE
-------------- --------------
+0.5% +4.19Ki +0.5% +4.19Ki .text
+0.4% +656 +0.4% +656 .rodata
+0.1% +504 [ = ] 0 .strtab
+0.2% +384 [ = ] 0 .symtab
+0.2% +280 +0.2% +280 .eh_frame
+0.2% +216 +0.2% +216 .rela.dyn
+0.3% +96 +0.3% +96 .data.rel.ro
+0.2% +64 +0.2% +64 .eh_frame_hdr
+1.1% +16 [ = ] 0 .got.plt
+0.2% +8 +0.2% +8 .rela.plt
-4.6% -8 -4.6% -8 [LOAD #2 [RX]]
-50.0% -48 [ = ] 0 [Unmapped]
[ = ] 0 -81.7% -1.47Ki .relro_padding
+0.1% +6.30Ki +0.0% +4.00Ki TOTAL
```
PiperOrigin-RevId: 579321454
1 year ago
|
|
|
|
|
|
|
upb_StringView _upb_DefBuilder_MakeKey(upb_DefBuilder* ctx,
|
|
|
|
const UPB_DESC(FeatureSet*) parent,
|
|
|
|
upb_StringView key) {
|
|
|
|
size_t need = key.size + sizeof(void*);
|
|
|
|
if (ctx->tmp_buf_size < need) {
|
|
|
|
ctx->tmp_buf_size = UPB_MAX(64, upb_Log2Ceiling(need));
|
|
|
|
ctx->tmp_buf = upb_Arena_Malloc(ctx->tmp_arena, ctx->tmp_buf_size);
|
|
|
|
if (!ctx->tmp_buf) _upb_DefBuilder_OomErr(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(ctx->tmp_buf, &parent, sizeof(void*));
|
|
|
|
memcpy(ctx->tmp_buf + sizeof(void*), key.data, key.size);
|
|
|
|
return upb_StringView_FromDataAndSize(ctx->tmp_buf, need);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool _upb_DefBuilder_GetOrCreateFeatureSet(upb_DefBuilder* ctx,
|
|
|
|
const UPB_DESC(FeatureSet*) parent,
|
|
|
|
upb_StringView key,
|
|
|
|
UPB_DESC(FeatureSet**) set) {
|
|
|
|
upb_StringView k = _upb_DefBuilder_MakeKey(ctx, parent, key);
|
|
|
|
upb_value v;
|
|
|
|
if (upb_strtable_lookup2(&ctx->feature_cache, k.data, k.size, &v)) {
|
|
|
|
*set = upb_value_getptr(v);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*set = (UPB_DESC(FeatureSet*))upb_Message_DeepClone(
|
|
|
|
UPB_UPCAST(parent), UPB_DESC_MINITABLE(FeatureSet), ctx->arena);
|
Implement feature inheritance and legacy editions for upb.
This switches upb to using legacy editions for all proto2/proto3 logic. This does not yet enable code generation for editions protos (ie. we do not yet turn on `FEATURE_SUPPORTS_EDITIONS`), but with feature inheritance in place, this will be a much smaller follow-on change.
There is a ~10% increase in allocations, but only a ~1% increase in peak memory. There are some <5% increases in instructions and cycles, but apparently no increase in time:
```
name old cpu/op new cpu/op delta
BM_ArenaOneAlloc 17.8ns ±11% 16.9ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 5.99ns ±13% 5.35ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.4ns ±11% 63.1ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 509ns ± 2% 532ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.73µs ±20% 4.43µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.77µs ±12% 8.64µs ± 4% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 67.5ns ±13% 62.6ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 552ns ±23% 496ns ±25% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.76µs ±14% 4.24µs ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 10.2µs ±14% 8.6µs ± 4% -15.61% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.20ms ±12% 6.18ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.91ms ±12% 6.63ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.0ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.1ms ±13% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.4µs ±13% 13.2µs ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.7µs ±12% 12.9µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.1µs ±11% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.7µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.6µs ±13% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±10% 10.6µs ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.4µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.62µs ±13% 6.00µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.1µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old time/op new time/op delta
BM_ArenaOneAlloc 17.9ns ±12% 17.0ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 6.03ns ±14% 5.36ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.9ns ±12% 63.3ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 511ns ± 2% 533ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.75µs ±20% 4.44µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.83µs ±12% 8.66µs ± 4% ~ (p=0.151 n=5+5)
BM_ArenaFuseBalanced/2 67.8ns ±13% 62.7ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 555ns ±24% 497ns ±26% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.79µs ±14% 4.25µs ± 4% ~ (p=0.310 n=5+5)
BM_ArenaFuseBalanced/128 10.3µs ±14% 8.6µs ± 4% -15.93% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.25ms ±12% 6.20ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.96ms ±13% 6.65ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.2ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.3ms ±14% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.5µs ±14% 13.2µs ± 3% ~ (p=0.690 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.8µs ±13% 13.0µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.2µs ±12% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.9µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.7µs ±14% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±11% 10.7µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.5µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.65µs ±13% 6.01µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.2µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old INSTRUCTIONS/op new INSTRUCTIONS/op delta
BM_ArenaOneAlloc 189 ± 0% 189 ± 0% ~ (p=0.881 n=5+5)
BM_ArenaInitialBlockOneAlloc 69.0 ± 0% 69.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 458 ± 0% 458 ± 0% ~ (p=1.000 n=5+5)
BM_ArenaFuseUnbalanced/8 3.28k ±15% 3.60k ± 0% ~ (p=0.286 n=5+4)
BM_ArenaFuseUnbalanced/64 28.6k ± 2% 29.2k ± 0% +2.17% (p=0.032 n=5+4)
BM_ArenaFuseUnbalanced/128 57.9k ± 1% 57.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/2 482 ± 0% 482 ± 0% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/8 3.35k ±14% 3.35k ±14% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/64 29.2k ± 2% 29.3k ± 1% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 59.2k ± 1% 59.3k ± 1% ~ (p=0.556 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 37.3M ± 0% 38.2M ± 0% +2.39% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 40.9M ± 0% 41.7M ± 0% +2.02% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 87.2M ± 0% 88.3M ± 1% +1.25% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 88.0M ± 0% 88.9M ± 1% +1.13% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 154k ± 0% 154k ± 0% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 143k ± 0% 143k ± 0% ~ (p=0.310 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 153k ± 0% 153k ± 0% ~ (p=1.016 n=5+4)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 142k ± 0% 142k ± 0% ~ (p=0.127 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 213k ± 1% 217k ± 5% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 122k ± 0% 123k ± 0% +0.86% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 120k ± 0% 120k ± 0% ~ (p=0.421 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 124k ± 0% 124k ± 0% ~ (p=0.587 n=5+5)
BM_SerializeDescriptor_Proto2 63.5k ± 0% 63.5k ± 0% ~ (p=0.278 n=5+5)
BM_SerializeDescriptor_Upb 111k ± 0% 111k ± 0% ~ (p=1.000 n=5+5)
name old CYCLES/op new CYCLES/op delta
BM_ArenaOneAlloc 53.5 ± 0% 53.4 ± 0% ~ (p=0.095 n=5+5)
BM_ArenaInitialBlockOneAlloc 17.5 ± 1% 17.4 ± 0% ~ (p=0.087 n=5+5)
BM_ArenaFuseUnbalanced/2 206 ± 0% 206 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/8 1.55k ±12% 1.67k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/64 14.1k ± 8% 14.1k ± 1% ~ (p=0.222 n=5+5)
BM_ArenaFuseUnbalanced/128 28.2k ± 1% 28.3k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/2 205 ± 0% 204 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/8 1.57k ±12% 1.56k ±12% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/64 13.9k ± 2% 13.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/128 28.1k ± 1% 28.2k ± 1% ~ (p=0.730 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 18.7M ± 0% 19.3M ± 1% +3.38% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 20.9M ± 0% 21.6M ± 0% +3.09% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 43.4M ± 0% 44.4M ± 1% +2.33% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 44.0M ± 0% 44.9M ± 2% +1.92% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 42.0k ± 1% 43.0k ± 1% +2.32% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 38.2k ± 1% 38.4k ± 0% +0.74% (p=0.032 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 41.6k ± 0% 42.6k ± 1% +2.51% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 37.6k ± 0% 38.1k ± 0% +1.34% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 71.9k ± 1% 74.1k ± 6% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 35.4k ± 1% 35.8k ± 0% +1.10% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 34.6k ± 1% 34.9k ± 1% ~ (p=0.095 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 40.5k ± 0% 40.0k ± 1% -1.36% (p=0.008 n=5+5)
BM_SerializeDescriptor_Proto2 20.1k ± 1% 19.7k ± 4% ~ (p=0.421 n=5+5)
BM_SerializeDescriptor_Upb 33.7k ± 0% 33.7k ± 0% ~ (p=0.222 n=5+5)
name old allocs/op new allocs/op delta
BM_ArenaOneAlloc 1.00 ± 0% 1.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.21k ± 0% 6.93k ± 0% +11.54% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.54k ± 0% 6.96k ± 0% +6.34% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 124k ± 0% 124k ± 0% +0.00% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 126k ± 0% 126k ± 0% +0.00% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 709 ± 0% 709 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
name old peak-mem(Bytes)/op new peak-mem(Bytes)/op delta
BM_ArenaOneAlloc 328 ± 0% 328 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 10.2M ± 0% 10.4M ± 0% +1.15% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 10.5M ± 0% 10.5M ± 0% +0.11% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 7.14M ± 0% 7.14M ± 0% ~ (p=0.317 n=4+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 7.18M ± 0% 7.18M ± 0% ~ (p=0.159 n=5+4)
BM_Parse_Upb_FileDesc<UseArena, Copy> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 35.4k ± 0% 35.4k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 65.3k ± 0% 65.3k ± 0% ~ (all samples are equal)
name old items/s new items/s delta
BM_ArenaFuseUnbalanced/2 28.2M ±12% 31.7M ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 15.7M ± 2% 15.1M ±14% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 13.7M ±18% 14.5M ± 9% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 13.2M ±12% 14.8M ± 5% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 29.9M ±12% 32.0M ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 14.8M ±28% 16.5M ±22% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 13.6M ±15% 15.1M ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 12.6M ±15% 14.9M ± 4% +17.88% (p=0.016 n=5+5)
name old speed new speed delta
BM_LoadAdsDescriptor_Upb<NoLayout> 128MB/s ±11% 128MB/s ±14% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 115MB/s ±12% 119MB/s ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 52.9MB/s ±12% 57.6MB/s ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 52.6MB/s ±14% 57.2MB/s ± 2% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 527MB/s ±14% 571MB/s ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 595MB/s ±11% 640MB/s ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 553MB/s ±12% 582MB/s ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 576MB/s ±12% 649MB/s ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 307MB/s ±13% 334MB/s ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 653MB/s ±13% 689MB/s ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 650MB/s ±10% 708MB/s ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 564MB/s ±12% 614MB/s ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 1.15GB/s ±12% 1.25GB/s ± 5% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 684MB/s ±12% 730MB/s ± 3% ~ (p=1.000 n=5+5)
```
This adds about 5Ki of code size. Some of this likely comes from the fact that we now link in `message/copy.c` to perform a deep copy of a FeatureSet proto.
```
$ /google/bin/releases/protobuf-team/bloaty/bloaty-google3-diff --blaze-build-opts="-c opt" third_party/upb/upb/conformance/conformance_upb
FILE SIZE VM SIZE
-------------- --------------
+0.5% +4.19Ki +0.5% +4.19Ki .text
+0.4% +656 +0.4% +656 .rodata
+0.1% +504 [ = ] 0 .strtab
+0.2% +384 [ = ] 0 .symtab
+0.2% +280 +0.2% +280 .eh_frame
+0.2% +216 +0.2% +216 .rela.dyn
+0.3% +96 +0.3% +96 .data.rel.ro
+0.2% +64 +0.2% +64 .eh_frame_hdr
+1.1% +16 [ = ] 0 .got.plt
+0.2% +8 +0.2% +8 .rela.plt
-4.6% -8 -4.6% -8 [LOAD #2 [RX]]
-50.0% -48 [ = ] 0 [Unmapped]
[ = ] 0 -81.7% -1.47Ki .relro_padding
+0.1% +6.30Ki +0.0% +4.00Ki TOTAL
```
PiperOrigin-RevId: 579321454
1 year ago
|
|
|
if (!*set) _upb_DefBuilder_OomErr(ctx);
|
|
|
|
|
|
|
|
v = upb_value_ptr(*set);
|
|
|
|
if (!upb_strtable_insert(&ctx->feature_cache, k.data, k.size, v,
|
|
|
|
ctx->tmp_arena)) {
|
|
|
|
_upb_DefBuilder_OomErr(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const UPB_DESC(FeatureSet*)
|
|
|
|
_upb_DefBuilder_DoResolveFeatures(upb_DefBuilder* ctx,
|
|
|
|
const UPB_DESC(FeatureSet*) parent,
|
|
|
|
const UPB_DESC(FeatureSet*) child,
|
|
|
|
bool is_implicit) {
|
|
|
|
assert(parent);
|
|
|
|
if (!child) return parent;
|
|
|
|
|
|
|
|
if (child && !is_implicit &&
|
|
|
|
upb_FileDef_Syntax(ctx->file) != kUpb_Syntax_Editions) {
|
|
|
|
_upb_DefBuilder_Errf(ctx, "Features can only be specified for editions");
|
|
|
|
}
|
|
|
|
|
|
|
|
UPB_DESC(FeatureSet*) resolved;
|
|
|
|
size_t child_size;
|
|
|
|
const char* child_bytes =
|
|
|
|
UPB_DESC(FeatureSet_serialize)(child, ctx->tmp_arena, &child_size);
|
|
|
|
if (!child_bytes) _upb_DefBuilder_OomErr(ctx);
|
|
|
|
|
|
|
|
upb_StringView key = upb_StringView_FromDataAndSize(child_bytes, child_size);
|
|
|
|
if (!_upb_DefBuilder_GetOrCreateFeatureSet(ctx, parent, key, &resolved)) {
|
|
|
|
return resolved;
|
|
|
|
}
|
|
|
|
|
|
|
|
upb_DecodeStatus dec_status =
|
|
|
|
upb_Decode(child_bytes, child_size, UPB_UPCAST(resolved),
|
Implement feature inheritance and legacy editions for upb.
This switches upb to using legacy editions for all proto2/proto3 logic. This does not yet enable code generation for editions protos (ie. we do not yet turn on `FEATURE_SUPPORTS_EDITIONS`), but with feature inheritance in place, this will be a much smaller follow-on change.
There is a ~10% increase in allocations, but only a ~1% increase in peak memory. There are some <5% increases in instructions and cycles, but apparently no increase in time:
```
name old cpu/op new cpu/op delta
BM_ArenaOneAlloc 17.8ns ±11% 16.9ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 5.99ns ±13% 5.35ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.4ns ±11% 63.1ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 509ns ± 2% 532ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.73µs ±20% 4.43µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.77µs ±12% 8.64µs ± 4% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 67.5ns ±13% 62.6ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 552ns ±23% 496ns ±25% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.76µs ±14% 4.24µs ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 10.2µs ±14% 8.6µs ± 4% -15.61% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.20ms ±12% 6.18ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.91ms ±12% 6.63ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.0ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.1ms ±13% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.4µs ±13% 13.2µs ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.7µs ±12% 12.9µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.1µs ±11% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.7µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.6µs ±13% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±10% 10.6µs ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.4µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.62µs ±13% 6.00µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.1µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old time/op new time/op delta
BM_ArenaOneAlloc 17.9ns ±12% 17.0ns ±17% ~ (p=0.310 n=5+5)
BM_ArenaInitialBlockOneAlloc 6.03ns ±14% 5.36ns ± 2% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/2 71.9ns ±12% 63.3ns ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 511ns ± 2% 533ns ±15% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 4.75µs ±20% 4.44µs ±10% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 9.83µs ±12% 8.66µs ± 4% ~ (p=0.151 n=5+5)
BM_ArenaFuseBalanced/2 67.8ns ±13% 62.7ns ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 555ns ±24% 497ns ±26% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 4.79µs ±14% 4.25µs ± 4% ~ (p=0.310 n=5+5)
BM_ArenaFuseBalanced/128 10.3µs ±14% 8.6µs ± 4% -15.93% (p=0.016 n=5+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.25ms ±12% 6.20ms ±16% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.96ms ±13% 6.65ms ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 15.2ms ±12% 13.7ms ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 15.3ms ±14% 13.8ms ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 14.5µs ±14% 13.2µs ± 3% ~ (p=0.690 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 12.8µs ±12% 11.8µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 13.8µs ±13% 13.0µs ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 13.2µs ±12% 11.6µs ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 24.9µs ±12% 22.6µs ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 11.7µs ±14% 10.9µs ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 11.7µs ±11% 10.7µs ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 13.5µs ±12% 12.3µs ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 6.65µs ±13% 6.01µs ± 6% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 11.2µs ±13% 10.3µs ± 3% ~ (p=1.000 n=5+5)
name old INSTRUCTIONS/op new INSTRUCTIONS/op delta
BM_ArenaOneAlloc 189 ± 0% 189 ± 0% ~ (p=0.881 n=5+5)
BM_ArenaInitialBlockOneAlloc 69.0 ± 0% 69.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 458 ± 0% 458 ± 0% ~ (p=1.000 n=5+5)
BM_ArenaFuseUnbalanced/8 3.28k ±15% 3.60k ± 0% ~ (p=0.286 n=5+4)
BM_ArenaFuseUnbalanced/64 28.6k ± 2% 29.2k ± 0% +2.17% (p=0.032 n=5+4)
BM_ArenaFuseUnbalanced/128 57.9k ± 1% 57.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/2 482 ± 0% 482 ± 0% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/8 3.35k ±14% 3.35k ±14% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/64 29.2k ± 2% 29.3k ± 1% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 59.2k ± 1% 59.3k ± 1% ~ (p=0.556 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 37.3M ± 0% 38.2M ± 0% +2.39% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 40.9M ± 0% 41.7M ± 0% +2.02% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 87.2M ± 0% 88.3M ± 1% +1.25% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 88.0M ± 0% 88.9M ± 1% +1.13% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 154k ± 0% 154k ± 0% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 143k ± 0% 143k ± 0% ~ (p=0.310 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 153k ± 0% 153k ± 0% ~ (p=1.016 n=5+4)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 142k ± 0% 142k ± 0% ~ (p=0.127 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 213k ± 1% 217k ± 5% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 122k ± 0% 123k ± 0% +0.86% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 120k ± 0% 120k ± 0% ~ (p=0.421 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 124k ± 0% 124k ± 0% ~ (p=0.587 n=5+5)
BM_SerializeDescriptor_Proto2 63.5k ± 0% 63.5k ± 0% ~ (p=0.278 n=5+5)
BM_SerializeDescriptor_Upb 111k ± 0% 111k ± 0% ~ (p=1.000 n=5+5)
name old CYCLES/op new CYCLES/op delta
BM_ArenaOneAlloc 53.5 ± 0% 53.4 ± 0% ~ (p=0.095 n=5+5)
BM_ArenaInitialBlockOneAlloc 17.5 ± 1% 17.4 ± 0% ~ (p=0.087 n=5+5)
BM_ArenaFuseUnbalanced/2 206 ± 0% 206 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/8 1.55k ±12% 1.67k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseUnbalanced/64 14.1k ± 8% 14.1k ± 1% ~ (p=0.222 n=5+5)
BM_ArenaFuseUnbalanced/128 28.2k ± 1% 28.3k ± 1% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/2 205 ± 0% 204 ± 0% ~ (p=0.548 n=5+5)
BM_ArenaFuseBalanced/8 1.57k ±12% 1.56k ±12% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/64 13.9k ± 2% 13.9k ± 1% ~ (p=1.000 n=5+5)
BM_ArenaFuseBalanced/128 28.1k ± 1% 28.2k ± 1% ~ (p=0.730 n=4+5)
BM_LoadAdsDescriptor_Upb<NoLayout> 18.7M ± 0% 19.3M ± 1% +3.38% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 20.9M ± 0% 21.6M ± 0% +3.09% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 43.4M ± 0% 44.4M ± 1% +2.33% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 44.0M ± 0% 44.9M ± 2% +1.92% (p=0.016 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 42.0k ± 1% 43.0k ± 1% +2.32% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 38.2k ± 1% 38.4k ± 0% +0.74% (p=0.032 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 41.6k ± 0% 42.6k ± 1% +2.51% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 37.6k ± 0% 38.1k ± 0% +1.34% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 71.9k ± 1% 74.1k ± 6% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 35.4k ± 1% 35.8k ± 0% +1.10% (p=0.008 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 34.6k ± 1% 34.9k ± 1% ~ (p=0.095 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 40.5k ± 0% 40.0k ± 1% -1.36% (p=0.008 n=5+5)
BM_SerializeDescriptor_Proto2 20.1k ± 1% 19.7k ± 4% ~ (p=0.421 n=5+5)
BM_SerializeDescriptor_Upb 33.7k ± 0% 33.7k ± 0% ~ (p=0.222 n=5+5)
name old allocs/op new allocs/op delta
BM_ArenaOneAlloc 1.00 ± 0% 1.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 2.00 ± 0% 2.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 64.0 ± 0% 64.0 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 128 ± 0% 128 ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 6.21k ± 0% 6.93k ± 0% +11.54% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 6.54k ± 0% 6.96k ± 0% +6.34% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 124k ± 0% 124k ± 0% +0.00% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 126k ± 0% 126k ± 0% +0.00% (p=0.008 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 7.00 ± 0% 7.00 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 709 ± 0% 709 ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 8.00 ± 0% 8.00 ± 0% ~ (all samples are equal)
name old peak-mem(Bytes)/op new peak-mem(Bytes)/op delta
BM_ArenaOneAlloc 328 ± 0% 328 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseUnbalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/2 656 ± 0% 656 ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/8 2.62k ± 0% 2.62k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/64 21.0k ± 0% 21.0k ± 0% ~ (all samples are equal)
BM_ArenaFuseBalanced/128 42.0k ± 0% 42.0k ± 0% ~ (all samples are equal)
BM_LoadAdsDescriptor_Upb<NoLayout> 10.2M ± 0% 10.4M ± 0% +1.15% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 10.5M ± 0% 10.5M ± 0% +0.11% (p=0.008 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 7.14M ± 0% 7.14M ± 0% ~ (p=0.317 n=4+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 7.18M ± 0% 7.18M ± 0% ~ (p=0.159 n=5+4)
BM_Parse_Upb_FileDesc<UseArena, Copy> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Upb_FileDesc<UseArena, Alias> 36.5k ± 0% 36.5k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 35.4k ± 0% 35.4k ± 0% ~ (all samples are equal)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 65.3k ± 0% 65.3k ± 0% ~ (all samples are equal)
name old items/s new items/s delta
BM_ArenaFuseUnbalanced/2 28.2M ±12% 31.7M ± 3% ~ (p=0.095 n=5+5)
BM_ArenaFuseUnbalanced/8 15.7M ± 2% 15.1M ±14% ~ (p=0.421 n=5+5)
BM_ArenaFuseUnbalanced/64 13.7M ±18% 14.5M ± 9% ~ (p=0.841 n=5+5)
BM_ArenaFuseUnbalanced/128 13.2M ±12% 14.8M ± 5% ~ (p=0.095 n=5+5)
BM_ArenaFuseBalanced/2 29.9M ±12% 32.0M ± 3% ~ (p=0.841 n=5+5)
BM_ArenaFuseBalanced/8 14.8M ±28% 16.5M ±22% ~ (p=0.222 n=5+5)
BM_ArenaFuseBalanced/64 13.6M ±15% 15.1M ± 4% ~ (p=0.421 n=5+5)
BM_ArenaFuseBalanced/128 12.6M ±15% 14.9M ± 4% +17.88% (p=0.016 n=5+5)
name old speed new speed delta
BM_LoadAdsDescriptor_Upb<NoLayout> 128MB/s ±11% 128MB/s ±14% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Upb<WithLayout> 115MB/s ±12% 119MB/s ± 3% ~ (p=0.690 n=5+5)
BM_LoadAdsDescriptor_Proto2<NoLayout> 52.9MB/s ±12% 57.6MB/s ± 3% ~ (p=0.421 n=5+5)
BM_LoadAdsDescriptor_Proto2<WithLayout> 52.6MB/s ±14% 57.2MB/s ± 2% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Copy> 527MB/s ±14% 571MB/s ± 3% ~ (p=0.548 n=5+5)
BM_Parse_Upb_FileDesc<UseArena, Alias> 595MB/s ±11% 640MB/s ± 3% ~ (p=0.222 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Copy> 553MB/s ±12% 582MB/s ± 3% ~ (p=1.000 n=5+5)
BM_Parse_Upb_FileDesc<InitBlock, Alias> 576MB/s ±12% 649MB/s ± 3% ~ (p=0.056 n=5+5)
BM_Parse_Proto2<FileDesc, NoArena, Copy> 307MB/s ±13% 334MB/s ± 8% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDesc, UseArena, Copy> 653MB/s ±13% 689MB/s ± 2% ~ (p=1.000 n=5+5)
BM_Parse_Proto2<FileDesc, InitBlock, Copy> 650MB/s ±10% 708MB/s ± 3% ~ (p=0.310 n=5+5)
BM_Parse_Proto2<FileDescSV, InitBlock, Alias> 564MB/s ±12% 614MB/s ± 4% ~ (p=0.310 n=5+5)
BM_SerializeDescriptor_Proto2 1.15GB/s ±12% 1.25GB/s ± 5% ~ (p=0.056 n=5+5)
BM_SerializeDescriptor_Upb 684MB/s ±12% 730MB/s ± 3% ~ (p=1.000 n=5+5)
```
This adds about 5Ki of code size. Some of this likely comes from the fact that we now link in `message/copy.c` to perform a deep copy of a FeatureSet proto.
```
$ /google/bin/releases/protobuf-team/bloaty/bloaty-google3-diff --blaze-build-opts="-c opt" third_party/upb/upb/conformance/conformance_upb
FILE SIZE VM SIZE
-------------- --------------
+0.5% +4.19Ki +0.5% +4.19Ki .text
+0.4% +656 +0.4% +656 .rodata
+0.1% +504 [ = ] 0 .strtab
+0.2% +384 [ = ] 0 .symtab
+0.2% +280 +0.2% +280 .eh_frame
+0.2% +216 +0.2% +216 .rela.dyn
+0.3% +96 +0.3% +96 .data.rel.ro
+0.2% +64 +0.2% +64 .eh_frame_hdr
+1.1% +16 [ = ] 0 .got.plt
+0.2% +8 +0.2% +8 .rela.plt
-4.6% -8 -4.6% -8 [LOAD #2 [RX]]
-50.0% -48 [ = ] 0 [Unmapped]
[ = ] 0 -81.7% -1.47Ki .relro_padding
+0.1% +6.30Ki +0.0% +4.00Ki TOTAL
```
PiperOrigin-RevId: 579321454
1 year ago
|
|
|
UPB_DESC_MINITABLE(FeatureSet), NULL, 0, ctx->arena);
|
|
|
|
if (dec_status != kUpb_DecodeStatus_Ok) _upb_DefBuilder_OomErr(ctx);
|
|
|
|
|
|
|
|
return resolved;
|
|
|
|
}
|