|
|
|
// 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/file_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 <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "upb/base/string_view.h"
|
|
|
|
#include "upb/mini_table/extension.h"
|
|
|
|
#include "upb/mini_table/extension_registry.h"
|
|
|
|
#include "upb/mini_table/file.h"
|
|
|
|
#include "upb/reflection/def.h"
|
|
|
|
#include "upb/reflection/internal/def_builder.h"
|
|
|
|
#include "upb/reflection/internal/def_pool.h"
|
|
|
|
#include "upb/reflection/internal/enum_def.h"
|
|
|
|
#include "upb/reflection/internal/field_def.h"
|
|
|
|
#include "upb/reflection/internal/message_def.h"
|
|
|
|
#include "upb/reflection/internal/service_def.h"
|
|
|
|
#include "upb/reflection/internal/strdup2.h"
|
|
|
|
|
|
|
|
// Must be last.
|
|
|
|
#include "upb/port/def.inc"
|
|
|
|
|
|
|
|
struct upb_FileDef {
|
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
|
|
|
const UPB_DESC(FileOptions*) opts;
|
|
|
|
const UPB_DESC(FeatureSet*) resolved_features;
|
|
|
|
const char* name;
|
|
|
|
const char* package;
|
|
|
|
UPB_DESC(Edition) edition;
|
|
|
|
|
|
|
|
const upb_FileDef** deps;
|
|
|
|
const int32_t* public_deps;
|
|
|
|
const int32_t* weak_deps;
|
|
|
|
const upb_MessageDef* top_lvl_msgs;
|
|
|
|
const upb_EnumDef* top_lvl_enums;
|
|
|
|
const upb_FieldDef* top_lvl_exts;
|
|
|
|
const upb_ServiceDef* services;
|
|
|
|
const upb_MiniTableExtension** ext_layouts;
|
|
|
|
const upb_DefPool* symtab;
|
|
|
|
|
|
|
|
int dep_count;
|
|
|
|
int public_dep_count;
|
|
|
|
int weak_dep_count;
|
|
|
|
int top_lvl_msg_count;
|
|
|
|
int top_lvl_enum_count;
|
|
|
|
int top_lvl_ext_count;
|
|
|
|
int service_count;
|
|
|
|
int ext_count; // All exts in the file.
|
|
|
|
upb_Syntax syntax;
|
|
|
|
};
|
|
|
|
|
|
|
|
UPB_API const char* upb_FileDef_EditionName(int edition) {
|
|
|
|
// TODO Synchronize this with descriptor.proto better.
|
|
|
|
switch (edition) {
|
|
|
|
case UPB_DESC(EDITION_PROTO2):
|
|
|
|
return "PROTO2";
|
|
|
|
case UPB_DESC(EDITION_PROTO3):
|
|
|
|
return "PROTO3";
|
|
|
|
case UPB_DESC(EDITION_2023):
|
|
|
|
return "2023";
|
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const UPB_DESC(FileOptions) * upb_FileDef_Options(const upb_FileDef* f) {
|
|
|
|
return f->opts;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
const UPB_DESC(FeatureSet) *
|
|
|
|
upb_FileDef_ResolvedFeatures(const upb_FileDef* f) {
|
|
|
|
return f->resolved_features;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool upb_FileDef_HasOptions(const upb_FileDef* f) {
|
|
|
|
return f->opts != (void*)kUpbDefOptDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* upb_FileDef_Name(const upb_FileDef* f) { return f->name; }
|
|
|
|
|
|
|
|
const char* upb_FileDef_Package(const upb_FileDef* f) {
|
|
|
|
return f->package ? f->package : "";
|
|
|
|
}
|
|
|
|
|
|
|
|
UPB_DESC(Edition) upb_FileDef_Edition(const upb_FileDef* f) {
|
|
|
|
return f->edition;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* _upb_FileDef_RawPackage(const upb_FileDef* f) { return f->package; }
|
|
|
|
|
|
|
|
upb_Syntax upb_FileDef_Syntax(const upb_FileDef* f) { return f->syntax; }
|
|
|
|
|
|
|
|
int upb_FileDef_TopLevelMessageCount(const upb_FileDef* f) {
|
|
|
|
return f->top_lvl_msg_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int upb_FileDef_DependencyCount(const upb_FileDef* f) { return f->dep_count; }
|
|
|
|
|
|
|
|
int upb_FileDef_PublicDependencyCount(const upb_FileDef* f) {
|
|
|
|
return f->public_dep_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int upb_FileDef_WeakDependencyCount(const upb_FileDef* f) {
|
|
|
|
return f->weak_dep_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int32_t* _upb_FileDef_PublicDependencyIndexes(const upb_FileDef* f) {
|
|
|
|
return f->public_deps;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int32_t* _upb_FileDef_WeakDependencyIndexes(const upb_FileDef* f) {
|
|
|
|
return f->weak_deps;
|
|
|
|
}
|
|
|
|
|
|
|
|
int upb_FileDef_TopLevelEnumCount(const upb_FileDef* f) {
|
|
|
|
return f->top_lvl_enum_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int upb_FileDef_TopLevelExtensionCount(const upb_FileDef* f) {
|
|
|
|
return f->top_lvl_ext_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int upb_FileDef_ServiceCount(const upb_FileDef* f) { return f->service_count; }
|
|
|
|
|
|
|
|
const upb_FileDef* upb_FileDef_Dependency(const upb_FileDef* f, int i) {
|
|
|
|
UPB_ASSERT(0 <= i && i < f->dep_count);
|
|
|
|
return f->deps[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
const upb_FileDef* upb_FileDef_PublicDependency(const upb_FileDef* f, int i) {
|
|
|
|
UPB_ASSERT(0 <= i && i < f->public_dep_count);
|
|
|
|
return f->deps[f->public_deps[i]];
|
|
|
|
}
|
|
|
|
|
|
|
|
const upb_FileDef* upb_FileDef_WeakDependency(const upb_FileDef* f, int i) {
|
|
|
|
UPB_ASSERT(0 <= i && i < f->public_dep_count);
|
|
|
|
return f->deps[f->weak_deps[i]];
|
|
|
|
}
|
|
|
|
|
|
|
|
const upb_MessageDef* upb_FileDef_TopLevelMessage(const upb_FileDef* f, int i) {
|
|
|
|
UPB_ASSERT(0 <= i && i < f->top_lvl_msg_count);
|
|
|
|
return _upb_MessageDef_At(f->top_lvl_msgs, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
const upb_EnumDef* upb_FileDef_TopLevelEnum(const upb_FileDef* f, int i) {
|
|
|
|
UPB_ASSERT(0 <= i && i < f->top_lvl_enum_count);
|
|
|
|
return _upb_EnumDef_At(f->top_lvl_enums, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
const upb_FieldDef* upb_FileDef_TopLevelExtension(const upb_FileDef* f, int i) {
|
|
|
|
UPB_ASSERT(0 <= i && i < f->top_lvl_ext_count);
|
|
|
|
return _upb_FieldDef_At(f->top_lvl_exts, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
const upb_ServiceDef* upb_FileDef_Service(const upb_FileDef* f, int i) {
|
|
|
|
UPB_ASSERT(0 <= i && i < f->service_count);
|
|
|
|
return _upb_ServiceDef_At(f->services, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
const upb_DefPool* upb_FileDef_Pool(const upb_FileDef* f) { return f->symtab; }
|
|
|
|
|
|
|
|
const upb_MiniTableExtension* _upb_FileDef_ExtensionMiniTable(
|
|
|
|
const upb_FileDef* f, int i) {
|
|
|
|
return f->ext_layouts[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: Import cycles are not allowed so this will terminate.
|
|
|
|
bool upb_FileDef_Resolves(const upb_FileDef* f, const char* path) {
|
|
|
|
if (!strcmp(f->name, path)) return true;
|
|
|
|
|
|
|
|
for (int i = 0; i < upb_FileDef_PublicDependencyCount(f); i++) {
|
|
|
|
const upb_FileDef* dep = upb_FileDef_PublicDependency(f, i);
|
|
|
|
if (upb_FileDef_Resolves(dep, path)) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char* strviewdup(upb_DefBuilder* ctx, upb_StringView view) {
|
|
|
|
char* ret = upb_strdup2(view.data, view.size, _upb_DefBuilder_Arena(ctx));
|
|
|
|
if (!ret) _upb_DefBuilder_OomErr(ctx);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool streql_view(upb_StringView view, const char* b) {
|
|
|
|
return view.size == strlen(b) && memcmp(view.data, b, view.size) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int count_exts_in_msg(const UPB_DESC(DescriptorProto) * msg_proto) {
|
|
|
|
size_t n;
|
|
|
|
UPB_DESC(DescriptorProto_extension)(msg_proto, &n);
|
|
|
|
int ext_count = n;
|
|
|
|
|
|
|
|
const UPB_DESC(DescriptorProto)* const* nested_msgs =
|
|
|
|
UPB_DESC(DescriptorProto_nested_type)(msg_proto, &n);
|
|
|
|
for (size_t i = 0; i < n; i++) {
|
|
|
|
ext_count += count_exts_in_msg(nested_msgs[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ext_count;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
const UPB_DESC(FeatureSet*)
|
|
|
|
_upb_FileDef_FindEdition(upb_DefBuilder* ctx, int edition) {
|
|
|
|
const UPB_DESC(FeatureSetDefaults)* defaults =
|
|
|
|
upb_DefPool_FeatureSetDefaults(ctx->symtab);
|
|
|
|
|
|
|
|
int min = UPB_DESC(FeatureSetDefaults_minimum_edition)(defaults);
|
|
|
|
int max = UPB_DESC(FeatureSetDefaults_maximum_edition)(defaults);
|
|
|
|
if (edition < min) {
|
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_DefBuilder_Errf(ctx,
|
|
|
|
"Edition %s is earlier than the minimum edition %s "
|
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
|
|
|
"given in the defaults",
|
|
|
|
upb_FileDef_EditionName(edition),
|
|
|
|
upb_FileDef_EditionName(min));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (edition > max) {
|
|
|
|
_upb_DefBuilder_Errf(ctx,
|
|
|
|
"Edition %s is later than the maximum edition %s "
|
|
|
|
"given in the defaults",
|
|
|
|
upb_FileDef_EditionName(edition),
|
|
|
|
upb_FileDef_EditionName(max));
|
|
|
|
return NULL;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
size_t n;
|
|
|
|
const UPB_DESC(FeatureSetDefaults_FeatureSetEditionDefault)* const* d =
|
|
|
|
UPB_DESC(FeatureSetDefaults_defaults)(defaults, &n);
|
|
|
|
const UPB_DESC(FeatureSetDefaults_FeatureSetEditionDefault)* result = NULL;
|
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
|
|
|
for (size_t i = 0; i < n; i++) {
|
|
|
|
if (UPB_DESC(FeatureSetDefaults_FeatureSetEditionDefault_edition)(d[i]) >
|
|
|
|
edition) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
result = d[i];
|
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 (result == NULL) {
|
|
|
|
_upb_DefBuilder_Errf(ctx, "No valid default found for edition %s",
|
|
|
|
upb_FileDef_EditionName(edition));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Merge the fixed and overridable features to get the edition's default
|
|
|
|
// feature set.
|
|
|
|
const UPB_DESC(FeatureSet)* fixed = UPB_DESC(
|
|
|
|
FeatureSetDefaults_FeatureSetEditionDefault_fixed_features)(result);
|
|
|
|
const UPB_DESC(FeatureSet)* overridable = UPB_DESC(
|
|
|
|
FeatureSetDefaults_FeatureSetEditionDefault_overridable_features)(result);
|
|
|
|
if (!fixed && !overridable) {
|
|
|
|
_upb_DefBuilder_Errf(ctx, "No valid default found for edition %s",
|
|
|
|
upb_FileDef_EditionName(edition));
|
|
|
|
return NULL;
|
|
|
|
} else if (!fixed) {
|
|
|
|
return overridable;
|
|
|
|
}
|
|
|
|
return _upb_DefBuilder_DoResolveFeatures(ctx, fixed, overridable,
|
|
|
|
/*is_implicit=*/true);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Allocate and initialize one file def, and add it to the context object.
|
|
|
|
void _upb_FileDef_Create(upb_DefBuilder* ctx,
|
|
|
|
const UPB_DESC(FileDescriptorProto) * file_proto) {
|
|
|
|
upb_FileDef* file = _upb_DefBuilder_Alloc(ctx, sizeof(upb_FileDef));
|
|
|
|
ctx->file = file;
|
|
|
|
|
|
|
|
const UPB_DESC(DescriptorProto)* const* msgs;
|
|
|
|
const UPB_DESC(EnumDescriptorProto)* const* enums;
|
|
|
|
const UPB_DESC(FieldDescriptorProto)* const* exts;
|
|
|
|
const UPB_DESC(ServiceDescriptorProto)* const* services;
|
|
|
|
const upb_StringView* strs;
|
|
|
|
const int32_t* public_deps;
|
|
|
|
const int32_t* weak_deps;
|
|
|
|
size_t n;
|
|
|
|
|
|
|
|
file->symtab = ctx->symtab;
|
|
|
|
|
|
|
|
// Count all extensions in the file, to build a flat array of layouts.
|
|
|
|
UPB_DESC(FileDescriptorProto_extension)(file_proto, &n);
|
|
|
|
int ext_count = n;
|
|
|
|
msgs = UPB_DESC(FileDescriptorProto_message_type)(file_proto, &n);
|
|
|
|
for (size_t i = 0; i < n; i++) {
|
|
|
|
ext_count += count_exts_in_msg(msgs[i]);
|
|
|
|
}
|
|
|
|
file->ext_count = ext_count;
|
|
|
|
|
|
|
|
if (ctx->layout) {
|
|
|
|
// We are using the ext layouts that were passed in.
|
|
|
|
file->ext_layouts = ctx->layout->UPB_PRIVATE(exts);
|
|
|
|
const int mt_ext_count = upb_MiniTableFile_ExtensionCount(ctx->layout);
|
|
|
|
if (mt_ext_count != file->ext_count) {
|
|
|
|
_upb_DefBuilder_Errf(ctx,
|
|
|
|
"Extension count did not match layout (%d vs %d)",
|
|
|
|
mt_ext_count, file->ext_count);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We are building ext layouts from scratch.
|
|
|
|
file->ext_layouts = _upb_DefBuilder_Alloc(
|
|
|
|
ctx, sizeof(*file->ext_layouts) * file->ext_count);
|
|
|
|
upb_MiniTableExtension* ext =
|
|
|
|
_upb_DefBuilder_Alloc(ctx, sizeof(*ext) * file->ext_count);
|
|
|
|
for (int i = 0; i < file->ext_count; i++) {
|
|
|
|
file->ext_layouts[i] = &ext[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
upb_StringView name = UPB_DESC(FileDescriptorProto_name)(file_proto);
|
|
|
|
file->name = strviewdup(ctx, name);
|
|
|
|
if (strlen(file->name) != name.size) {
|
|
|
|
_upb_DefBuilder_Errf(ctx, "File name contained embedded NULL");
|
|
|
|
}
|
|
|
|
|
|
|
|
upb_StringView package = UPB_DESC(FileDescriptorProto_package)(file_proto);
|
|
|
|
|
|
|
|
if (package.size) {
|
|
|
|
_upb_DefBuilder_CheckIdentFull(ctx, package);
|
|
|
|
file->package = strviewdup(ctx, package);
|
|
|
|
} else {
|
|
|
|
file->package = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: How should we validate this?
|
|
|
|
file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto);
|
|
|
|
|
|
|
|
if (UPB_DESC(FileDescriptorProto_has_syntax)(file_proto)) {
|
|
|
|
upb_StringView syntax = UPB_DESC(FileDescriptorProto_syntax)(file_proto);
|
|
|
|
|
|
|
|
if (streql_view(syntax, "proto2")) {
|
|
|
|
file->syntax = kUpb_Syntax_Proto2;
|
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
|
|
|
file->edition = UPB_DESC(EDITION_PROTO2);
|
|
|
|
} else if (streql_view(syntax, "proto3")) {
|
|
|
|
file->syntax = kUpb_Syntax_Proto3;
|
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
|
|
|
file->edition = UPB_DESC(EDITION_PROTO3);
|
|
|
|
} else if (streql_view(syntax, "editions")) {
|
|
|
|
file->syntax = kUpb_Syntax_Editions;
|
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
|
|
|
file->edition = UPB_DESC(FileDescriptorProto_edition)(file_proto);
|
|
|
|
} else {
|
|
|
|
_upb_DefBuilder_Errf(ctx, "Invalid syntax '" UPB_STRINGVIEW_FORMAT "'",
|
|
|
|
UPB_STRINGVIEW_ARGS(syntax));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
file->syntax = kUpb_Syntax_Proto2;
|
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
|
|
|
file->edition = UPB_DESC(EDITION_PROTO2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read options.
|
|
|
|
UPB_DEF_SET_OPTIONS(file->opts, FileDescriptorProto, FileOptions, file_proto);
|
|
|
|
|
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
|
|
|
// Resolve features.
|
|
|
|
const UPB_DESC(FeatureSet*) edition_defaults =
|
|
|
|
_upb_FileDef_FindEdition(ctx, file->edition);
|
|
|
|
const UPB_DESC(FeatureSet*) unresolved =
|
|
|
|
UPB_DESC(FileOptions_features)(file->opts);
|
|
|
|
file->resolved_features =
|
|
|
|
_upb_DefBuilder_ResolveFeatures(ctx, edition_defaults, unresolved);
|
|
|
|
|
|
|
|
// Verify dependencies.
|
|
|
|
strs = UPB_DESC(FileDescriptorProto_dependency)(file_proto, &n);
|
|
|
|
file->dep_count = n;
|
|
|
|
file->deps = _upb_DefBuilder_Alloc(ctx, sizeof(*file->deps) * n);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < n; i++) {
|
|
|
|
upb_StringView str = strs[i];
|
|
|
|
file->deps[i] =
|
|
|
|
upb_DefPool_FindFileByNameWithSize(ctx->symtab, str.data, str.size);
|
|
|
|
if (!file->deps[i]) {
|
|
|
|
_upb_DefBuilder_Errf(ctx,
|
|
|
|
"Depends on file '" UPB_STRINGVIEW_FORMAT
|
|
|
|
"', but it has not been loaded",
|
|
|
|
UPB_STRINGVIEW_ARGS(str));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public_deps = UPB_DESC(FileDescriptorProto_public_dependency)(file_proto, &n);
|
|
|
|
file->public_dep_count = n;
|
|
|
|
file->public_deps =
|
|
|
|
_upb_DefBuilder_Alloc(ctx, sizeof(*file->public_deps) * n);
|
|
|
|
int32_t* mutable_public_deps = (int32_t*)file->public_deps;
|
|
|
|
for (size_t i = 0; i < n; i++) {
|
|
|
|
if (public_deps[i] >= file->dep_count) {
|
|
|
|
_upb_DefBuilder_Errf(ctx, "public_dep %d is out of range",
|
|
|
|
(int)public_deps[i]);
|
|
|
|
}
|
|
|
|
mutable_public_deps[i] = public_deps[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
weak_deps = UPB_DESC(FileDescriptorProto_weak_dependency)(file_proto, &n);
|
|
|
|
file->weak_dep_count = n;
|
|
|
|
file->weak_deps = _upb_DefBuilder_Alloc(ctx, sizeof(*file->weak_deps) * n);
|
|
|
|
int32_t* mutable_weak_deps = (int32_t*)file->weak_deps;
|
|
|
|
for (size_t i = 0; i < n; i++) {
|
|
|
|
if (weak_deps[i] >= file->dep_count) {
|
|
|
|
_upb_DefBuilder_Errf(ctx, "weak_dep %d is out of range",
|
|
|
|
(int)weak_deps[i]);
|
|
|
|
}
|
|
|
|
mutable_weak_deps[i] = weak_deps[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create enums.
|
|
|
|
enums = UPB_DESC(FileDescriptorProto_enum_type)(file_proto, &n);
|
|
|
|
file->top_lvl_enum_count = n;
|
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
|
|
|
file->top_lvl_enums =
|
|
|
|
_upb_EnumDefs_New(ctx, n, enums, file->resolved_features, NULL);
|
|
|
|
|
|
|
|
// Create extensions.
|
|
|
|
exts = UPB_DESC(FileDescriptorProto_extension)(file_proto, &n);
|
|
|
|
file->top_lvl_ext_count = n;
|
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
|
|
|
file->top_lvl_exts = _upb_Extensions_New(
|
|
|
|
ctx, n, exts, file->resolved_features, file->package, NULL);
|
|
|
|
|
|
|
|
// Create messages.
|
|
|
|
msgs = UPB_DESC(FileDescriptorProto_message_type)(file_proto, &n);
|
|
|
|
file->top_lvl_msg_count = n;
|
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
|
|
|
file->top_lvl_msgs =
|
|
|
|
_upb_MessageDefs_New(ctx, n, msgs, file->resolved_features, NULL);
|
|
|
|
|
|
|
|
// Create services.
|
|
|
|
services = UPB_DESC(FileDescriptorProto_service)(file_proto, &n);
|
|
|
|
file->service_count = n;
|
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
|
|
|
file->services =
|
|
|
|
_upb_ServiceDefs_New(ctx, n, services, file->resolved_features);
|
|
|
|
|
|
|
|
// Now that all names are in the table, build layouts and resolve refs.
|
|
|
|
|
|
|
|
for (int i = 0; i < file->top_lvl_msg_count; i++) {
|
|
|
|
upb_MessageDef* m = (upb_MessageDef*)upb_FileDef_TopLevelMessage(file, i);
|
|
|
|
_upb_MessageDef_Resolve(ctx, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < file->top_lvl_ext_count; i++) {
|
|
|
|
upb_FieldDef* f = (upb_FieldDef*)upb_FileDef_TopLevelExtension(file, i);
|
|
|
|
_upb_FieldDef_Resolve(ctx, file->package, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < file->top_lvl_msg_count; i++) {
|
|
|
|
upb_MessageDef* m = (upb_MessageDef*)upb_FileDef_TopLevelMessage(file, i);
|
|
|
|
_upb_MessageDef_CreateMiniTable(ctx, (upb_MessageDef*)m);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < file->top_lvl_ext_count; i++) {
|
|
|
|
upb_FieldDef* f = (upb_FieldDef*)upb_FileDef_TopLevelExtension(file, i);
|
|
|
|
_upb_FieldDef_BuildMiniTableExtension(ctx, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < file->top_lvl_msg_count; i++) {
|
|
|
|
upb_MessageDef* m = (upb_MessageDef*)upb_FileDef_TopLevelMessage(file, i);
|
|
|
|
_upb_MessageDef_LinkMiniTable(ctx, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file->ext_count) {
|
|
|
|
bool ok = upb_ExtensionRegistry_AddArray(
|
|
|
|
_upb_DefPool_ExtReg(ctx->symtab), file->ext_layouts, file->ext_count);
|
|
|
|
if (!ok) _upb_DefBuilder_OomErr(ctx);
|
|
|
|
}
|
|
|
|
}
|