ruby_memprofiler_pprof 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/ruby_memprofiler_pprof/backtrace.c +429 -0
- data/ext/ruby_memprofiler_pprof/collector.c +1055 -0
- data/ext/ruby_memprofiler_pprof/compat.c +182 -0
- data/ext/ruby_memprofiler_pprof/extconf.rb +72 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.c +170 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.h +848 -0
- data/ext/ruby_memprofiler_pprof/pprof_out.c +285 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.c +11 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.h +301 -0
- data/ext/ruby_memprofiler_pprof/strtab.c +391 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/BUILD +719 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/CONTRIBUTING.md +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/DESIGN.md +201 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/LICENSE +26 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/README.md +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/WORKSPACE +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/BUILD +53 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/amalgamate.py +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/build_defs.bzl +160 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/lua.BUILD +127 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/protobuf.patch +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/py_proto_library.bzl +137 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/python_downloads.bzl +84 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/system_python.bzl +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/upb_proto_library.bzl +388 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/workspace_deps.bzl +89 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD +252 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD.googleapis +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/benchmark.cc +333 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/build_defs.bzl +88 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/compare.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor.proto +888 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor_sv.proto +890 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/empty.proto +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_protobuf_binary_cc.py +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_synthetic_protos.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_upb_binary_c.py +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/BUILD.bazel +102 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/README.md +23 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/build_defs.bzl +73 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/make_cmakelists.py +340 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test.py +57 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test_lib.py +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/render.py +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/style-guide.md +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/vs-cpp-protos.md +255 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/wrapping-upb.md +444 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/BUILD +216 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.c +394 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.h +63 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.c +1694 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.h +80 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.c +704 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.c +650 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.h +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/BUILD.bazel +193 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/dist.bzl +190 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.c +247 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.c +522 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.c +1909 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.h +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/minimal_test.py +183 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/BUILD +70 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/README.md +11 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_pool_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_test_wrapper.py +46 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/generator_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/json_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/keywords_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_factory_test_wrapper.py +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_test_wrapper.py +52 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/proto_builder_test_wrapper.py +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/pyproto_test_wrapper.bzl +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/reflection_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/service_reflection_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/symbol_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_encoding_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/unknown_fields_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/well_known_types_test_wrapper.py +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/wire_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.c +350 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.h +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/py_extension.bzl +55 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/python_api.h +61 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.c +828 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.h +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.c +404 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/version_script.lds +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/LICENSE +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/README.google +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/console.lua +156 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/lunit.lua +725 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/BUILD +19 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/LICENSE +21 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/naive.c +92 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-neon.c +157 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-sse.c +170 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/utf8_range.h +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/BUILD.bazel +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/README.md +8 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/def.c +939 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/lua_proto_library.bzl +138 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/main.c +83 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/msg.c +1118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test.proto +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test_upb.lua +846 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.c +258 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.h +132 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.lua +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upbc.cc +134 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.c +192 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.h +174 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb.c +346 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb_failures.txt +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.c +1221 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.c +1055 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.h +153 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_internal.h +211 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.c +3262 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.h +414 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.hpp +438 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/empty.proto +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.c +604 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.h +71 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/BUILD +13 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/file_descriptor_parsenew_fuzzer.cc +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.c +1509 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.h +47 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.c +776 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.c +1147 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.h +189 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.hpp +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.c +363 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.h +263 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_internal.h +59 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_test.cc +425 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_test.cc +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.c +428 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_internal.h +836 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.cc +491 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.proto +195 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_def.inc +261 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_undef.inc +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.c +323 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.h +109 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.hpp +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table.c +926 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table_internal.h +385 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test.proto +74 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.cc +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.proto +12 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_generated_code.cc +977 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_table.cc +580 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.c +472 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.h +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.c +362 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.h +378 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.hpp +115 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb_internal.h +68 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/BUILD +121 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/README.md +7 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.c +300 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare_test.cc +236 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.c +572 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_public_import_test.proto +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_regular_import_test.proto +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.cc +143 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.proto +119 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_weak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_wweak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.c +311 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.cc +202 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.proto +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/BUILD +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.cc +77 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.h +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upb.cc +1997 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upbdefs.cc +193 -0
- data/lib/ruby_memprofiler_pprof/atfork.rb +77 -0
- data/lib/ruby_memprofiler_pprof/block_flusher.rb +61 -0
- data/lib/ruby_memprofiler_pprof/file_flusher.rb +45 -0
- data/lib/ruby_memprofiler_pprof/profile_app.rb +30 -0
- data/lib/ruby_memprofiler_pprof/profile_data.rb +18 -0
- data/lib/ruby_memprofiler_pprof/version.rb +5 -0
- data/lib/ruby_memprofiler_pprof.rb +8 -0
- data/libexec/ruby_memprofiler_pprof_profile +16 -0
- metadata +257 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Copyright (c) 2009-2021, Google LLC
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
|
6
|
+
# * Redistributions of source code must retain the above copyright
|
|
7
|
+
# notice, this list of conditions and the following disclaimer.
|
|
8
|
+
# * Redistributions in binary form must reproduce the above copyright
|
|
9
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
10
|
+
# documentation and/or other materials provided with the distribution.
|
|
11
|
+
# * Neither the name of Google LLC nor the
|
|
12
|
+
# names of its contributors may be used to endorse or promote products
|
|
13
|
+
# derived from this software without specific prior written permission.
|
|
14
|
+
#
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
16
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
17
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
|
|
19
|
+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
20
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
21
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
22
|
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
24
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
# begin:google_only
|
|
27
|
+
# load("//tools/build_defs/proto/cpp:cc_proto_library.bzl", "cc_proto_library")
|
|
28
|
+
# end:google_only
|
|
29
|
+
|
|
30
|
+
load(
|
|
31
|
+
"//bazel:upb_proto_library.bzl",
|
|
32
|
+
"upb_proto_library",
|
|
33
|
+
"upb_proto_reflection_library",
|
|
34
|
+
)
|
|
35
|
+
load(
|
|
36
|
+
":build_defs.bzl",
|
|
37
|
+
"cc_optimizefor_proto_library",
|
|
38
|
+
"expand_suffixes",
|
|
39
|
+
"proto_library",
|
|
40
|
+
"tmpl_cc_binary",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
licenses(["notice"])
|
|
44
|
+
|
|
45
|
+
proto_library(
|
|
46
|
+
name = "descriptor_proto",
|
|
47
|
+
srcs = ["descriptor.proto"],
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
upb_proto_library(
|
|
51
|
+
name = "benchmark_descriptor_upb_proto",
|
|
52
|
+
deps = [":descriptor_proto"],
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
upb_proto_reflection_library(
|
|
56
|
+
name = "benchmark_descriptor_upb_proto_reflection",
|
|
57
|
+
deps = [":descriptor_proto"],
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
upb_proto_reflection_library(
|
|
61
|
+
name = "ads_upb_proto_reflection",
|
|
62
|
+
deps = ["@com_google_googleapis//:ads_proto"],
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
cc_proto_library(
|
|
66
|
+
name = "benchmark_descriptor_cc_proto",
|
|
67
|
+
deps = [":descriptor_proto"],
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
proto_library(
|
|
71
|
+
name = "benchmark_descriptor_sv_proto",
|
|
72
|
+
srcs = ["descriptor_sv.proto"],
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
cc_proto_library(
|
|
76
|
+
name = "benchmark_descriptor_sv_cc_proto",
|
|
77
|
+
deps = [":benchmark_descriptor_sv_proto"],
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
cc_test(
|
|
81
|
+
name = "benchmark",
|
|
82
|
+
testonly = 1,
|
|
83
|
+
srcs = ["benchmark.cc"],
|
|
84
|
+
deps = [
|
|
85
|
+
":ads_upb_proto_reflection",
|
|
86
|
+
":benchmark_descriptor_cc_proto",
|
|
87
|
+
":benchmark_descriptor_sv_cc_proto",
|
|
88
|
+
":benchmark_descriptor_upb_proto",
|
|
89
|
+
":benchmark_descriptor_upb_proto_reflection",
|
|
90
|
+
"//:descriptor_upb_proto",
|
|
91
|
+
"//:reflection",
|
|
92
|
+
"@com_github_google_benchmark//:benchmark_main",
|
|
93
|
+
"@com_google_absl//absl/container:flat_hash_set",
|
|
94
|
+
"@com_google_protobuf//:protobuf",
|
|
95
|
+
],
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Size benchmarks.
|
|
99
|
+
|
|
100
|
+
SIZE_BENCHMARKS = {
|
|
101
|
+
"empty": "Empty",
|
|
102
|
+
"descriptor": "FileDescriptorSet",
|
|
103
|
+
"100_msgs": "Message100",
|
|
104
|
+
"200_msgs": "Message200",
|
|
105
|
+
"100_fields": "Message",
|
|
106
|
+
"200_fields": "Message",
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
py_binary(
|
|
110
|
+
name = "gen_synthetic_protos",
|
|
111
|
+
srcs = ["gen_synthetic_protos.py"],
|
|
112
|
+
python_version = "PY3",
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
py_binary(
|
|
116
|
+
name = "gen_upb_binary_c",
|
|
117
|
+
srcs = ["gen_upb_binary_c.py"],
|
|
118
|
+
python_version = "PY3",
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
py_binary(
|
|
122
|
+
name = "gen_protobuf_binary_cc",
|
|
123
|
+
srcs = ["gen_protobuf_binary_cc.py"],
|
|
124
|
+
python_version = "PY3",
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
genrule(
|
|
128
|
+
name = "do_gen_synthetic_protos",
|
|
129
|
+
outs = [
|
|
130
|
+
"100_msgs.proto",
|
|
131
|
+
"200_msgs.proto",
|
|
132
|
+
"100_fields.proto",
|
|
133
|
+
"200_fields.proto",
|
|
134
|
+
],
|
|
135
|
+
cmd = "$(execpath :gen_synthetic_protos) $(RULEDIR)",
|
|
136
|
+
tools = [":gen_synthetic_protos"],
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
proto_library(
|
|
140
|
+
name = "100_msgs_proto",
|
|
141
|
+
srcs = ["100_msgs.proto"],
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
proto_library(
|
|
145
|
+
name = "200_msgs_proto",
|
|
146
|
+
srcs = ["200_msgs.proto"],
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
proto_library(
|
|
150
|
+
name = "100_fields_proto",
|
|
151
|
+
srcs = ["100_fields.proto"],
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
proto_library(
|
|
155
|
+
name = "200_fields_proto",
|
|
156
|
+
srcs = ["200_fields.proto"],
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
proto_library(
|
|
160
|
+
name = "empty_proto",
|
|
161
|
+
srcs = ["empty.proto"],
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
[(
|
|
165
|
+
upb_proto_library(
|
|
166
|
+
name = k + "_upb_proto",
|
|
167
|
+
deps = [":" + k + "_proto"],
|
|
168
|
+
),
|
|
169
|
+
cc_proto_library(
|
|
170
|
+
name = k + "_cc_proto",
|
|
171
|
+
deps = [":" + k + "_proto"],
|
|
172
|
+
),
|
|
173
|
+
tmpl_cc_binary(
|
|
174
|
+
name = k + "_upb_binary",
|
|
175
|
+
testonly = 1,
|
|
176
|
+
args = [
|
|
177
|
+
package_name() + "/" + k + ".upb.h",
|
|
178
|
+
"upb_benchmark_" + v,
|
|
179
|
+
],
|
|
180
|
+
gen = ":gen_upb_binary_c",
|
|
181
|
+
deps = [
|
|
182
|
+
":" + k + "_upb_proto",
|
|
183
|
+
],
|
|
184
|
+
),
|
|
185
|
+
tmpl_cc_binary(
|
|
186
|
+
name = k + "_protobuf_binary",
|
|
187
|
+
testonly = 1,
|
|
188
|
+
args = [
|
|
189
|
+
package_name() + "/" + k + ".pb.h",
|
|
190
|
+
"upb_benchmark::" + v,
|
|
191
|
+
],
|
|
192
|
+
gen = ":gen_protobuf_binary_cc",
|
|
193
|
+
deps = [
|
|
194
|
+
":" + k + "_cc_proto",
|
|
195
|
+
],
|
|
196
|
+
),
|
|
197
|
+
cc_optimizefor_proto_library(
|
|
198
|
+
name = k + "_cc_lite_proto",
|
|
199
|
+
srcs = [k + ".proto"],
|
|
200
|
+
outs = [k + "_lite.proto"],
|
|
201
|
+
optimize_for = "LITE_RUNTIME",
|
|
202
|
+
),
|
|
203
|
+
tmpl_cc_binary(
|
|
204
|
+
name = k + "_lite_protobuf_binary",
|
|
205
|
+
testonly = 1,
|
|
206
|
+
args = [
|
|
207
|
+
package_name() + "/" + k + "_lite.pb.h",
|
|
208
|
+
"upb_benchmark::" + v,
|
|
209
|
+
],
|
|
210
|
+
gen = ":gen_protobuf_binary_cc",
|
|
211
|
+
deps = [
|
|
212
|
+
":" + k + "_cc_lite_proto",
|
|
213
|
+
],
|
|
214
|
+
),
|
|
215
|
+
cc_optimizefor_proto_library(
|
|
216
|
+
name = k + "_cc_codesize_proto",
|
|
217
|
+
srcs = [k + ".proto"],
|
|
218
|
+
outs = [k + "_codesize.proto"],
|
|
219
|
+
optimize_for = "CODE_SIZE",
|
|
220
|
+
),
|
|
221
|
+
tmpl_cc_binary(
|
|
222
|
+
name = k + "_codesize_protobuf_binary",
|
|
223
|
+
testonly = 1,
|
|
224
|
+
args = [
|
|
225
|
+
package_name() + "/" + k + "_codesize.pb.h",
|
|
226
|
+
"upb_benchmark::" + v,
|
|
227
|
+
],
|
|
228
|
+
gen = ":gen_protobuf_binary_cc",
|
|
229
|
+
deps = [
|
|
230
|
+
":" + k + "_cc_codesize_proto",
|
|
231
|
+
],
|
|
232
|
+
),
|
|
233
|
+
) for k, v in SIZE_BENCHMARKS.items()]
|
|
234
|
+
|
|
235
|
+
genrule(
|
|
236
|
+
name = "size_data",
|
|
237
|
+
testonly = 1,
|
|
238
|
+
srcs = expand_suffixes(
|
|
239
|
+
SIZE_BENCHMARKS.keys(),
|
|
240
|
+
suffixes = [
|
|
241
|
+
"_upb_binary",
|
|
242
|
+
"_protobuf_binary",
|
|
243
|
+
"_lite_protobuf_binary",
|
|
244
|
+
"_codesize_protobuf_binary",
|
|
245
|
+
],
|
|
246
|
+
),
|
|
247
|
+
outs = ["size_data.txt"],
|
|
248
|
+
# We want --format=GNU which counts rodata with data, not text.
|
|
249
|
+
cmd = "size $$($$OSTYPE == 'linux-gnu' ? '--format=GNU -d' : '') $(SRCS) > $@",
|
|
250
|
+
# "size" sometimes isn't available remotely.
|
|
251
|
+
local = 1,
|
|
252
|
+
)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Copyright (c) 2009-2021, Google LLC
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
|
6
|
+
# * Redistributions of source code must retain the above copyright
|
|
7
|
+
# notice, this list of conditions and the following disclaimer.
|
|
8
|
+
# * Redistributions in binary form must reproduce the above copyright
|
|
9
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
10
|
+
# documentation and/or other materials provided with the distribution.
|
|
11
|
+
# * Neither the name of Google LLC nor the
|
|
12
|
+
# names of its contributors may be used to endorse or promote products
|
|
13
|
+
# derived from this software without specific prior written permission.
|
|
14
|
+
#
|
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
16
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
17
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
|
|
19
|
+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
20
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
21
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
22
|
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
24
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
load(
|
|
27
|
+
"@rules_proto//proto:defs.bzl",
|
|
28
|
+
"proto_library",
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
proto_library(
|
|
32
|
+
name = "ads_proto",
|
|
33
|
+
srcs = glob([
|
|
34
|
+
"google/ads/googleads/v7/**/*.proto",
|
|
35
|
+
"google/api/**/*.proto",
|
|
36
|
+
"google/rpc/**/*.proto",
|
|
37
|
+
"google/longrunning/**/*.proto",
|
|
38
|
+
"google/logging/**/*.proto",
|
|
39
|
+
]),
|
|
40
|
+
#srcs = ["google/ads/googleads/v5/services/google_ads_service.proto"],
|
|
41
|
+
visibility = ["//visibility:public"],
|
|
42
|
+
deps = [
|
|
43
|
+
"@com_google_protobuf//:any_proto",
|
|
44
|
+
"@com_google_protobuf//:api_proto",
|
|
45
|
+
"@com_google_protobuf//:descriptor_proto",
|
|
46
|
+
"@com_google_protobuf//:duration_proto",
|
|
47
|
+
"@com_google_protobuf//:empty_proto",
|
|
48
|
+
"@com_google_protobuf//:field_mask_proto",
|
|
49
|
+
"@com_google_protobuf//:struct_proto",
|
|
50
|
+
"@com_google_protobuf//:timestamp_proto",
|
|
51
|
+
"@com_google_protobuf//:type_proto",
|
|
52
|
+
"@com_google_protobuf//:wrappers_proto",
|
|
53
|
+
],
|
|
54
|
+
)
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// Copyright (c) 2009-2021, Google LLC
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// Redistribution and use in source and binary forms, with or without
|
|
5
|
+
// modification, are permitted provided that the following conditions are met:
|
|
6
|
+
// * Redistributions of source code must retain the above copyright
|
|
7
|
+
// notice, this list of conditions and the following disclaimer.
|
|
8
|
+
// * Redistributions in binary form must reproduce the above copyright
|
|
9
|
+
// notice, this list of conditions and the following disclaimer in the
|
|
10
|
+
// documentation and/or other materials provided with the distribution.
|
|
11
|
+
// * Neither the name of Google LLC nor the
|
|
12
|
+
// names of its contributors may be used to endorse or promote products
|
|
13
|
+
// derived from this software without specific prior written permission.
|
|
14
|
+
//
|
|
15
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
18
|
+
// ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
|
|
19
|
+
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
20
|
+
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
21
|
+
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
22
|
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
24
|
+
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
#include <benchmark/benchmark.h>
|
|
27
|
+
#include <string.h>
|
|
28
|
+
|
|
29
|
+
#include "absl/container/flat_hash_set.h"
|
|
30
|
+
#include "benchmarks/descriptor.pb.h"
|
|
31
|
+
#include "benchmarks/descriptor.upb.h"
|
|
32
|
+
#include "benchmarks/descriptor.upbdefs.h"
|
|
33
|
+
#include "benchmarks/descriptor_sv.pb.h"
|
|
34
|
+
#include "google/ads/googleads/v7/services/google_ads_service.upbdefs.h"
|
|
35
|
+
#include "google/protobuf/descriptor.pb.h"
|
|
36
|
+
#include "google/protobuf/dynamic_message.h"
|
|
37
|
+
#include "upb/def.hpp"
|
|
38
|
+
|
|
39
|
+
upb_StringView descriptor = benchmarks_descriptor_proto_upbdefinit.descriptor;
|
|
40
|
+
namespace protobuf = ::google::protobuf;
|
|
41
|
+
|
|
42
|
+
/* A buffer big enough to parse descriptor.proto without going to heap. */
|
|
43
|
+
char buf[65535];
|
|
44
|
+
|
|
45
|
+
void CollectFileDescriptors(
|
|
46
|
+
const _upb_DefPool_Init* file,
|
|
47
|
+
std::vector<upb_StringView>& serialized_files,
|
|
48
|
+
absl::flat_hash_set<const _upb_DefPool_Init*>& seen) {
|
|
49
|
+
if (!seen.insert(file).second) return;
|
|
50
|
+
for (_upb_DefPool_Init** deps = file->deps; *deps; deps++) {
|
|
51
|
+
CollectFileDescriptors(*deps, serialized_files, seen);
|
|
52
|
+
}
|
|
53
|
+
serialized_files.push_back(file->descriptor);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static void BM_ArenaOneAlloc(benchmark::State& state) {
|
|
57
|
+
for (auto _ : state) {
|
|
58
|
+
upb_Arena* arena = upb_Arena_New();
|
|
59
|
+
upb_Arena_Malloc(arena, 1);
|
|
60
|
+
upb_Arena_Free(arena);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
BENCHMARK(BM_ArenaOneAlloc);
|
|
64
|
+
|
|
65
|
+
static void BM_ArenaInitialBlockOneAlloc(benchmark::State& state) {
|
|
66
|
+
for (auto _ : state) {
|
|
67
|
+
upb_Arena* arena = upb_Arena_Init(buf, sizeof(buf), NULL);
|
|
68
|
+
upb_Arena_Malloc(arena, 1);
|
|
69
|
+
upb_Arena_Free(arena);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
BENCHMARK(BM_ArenaInitialBlockOneAlloc);
|
|
73
|
+
|
|
74
|
+
enum LoadDescriptorMode {
|
|
75
|
+
NoLayout,
|
|
76
|
+
WithLayout,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// This function is mostly copied from upb/def.c, but it is modified to avoid
|
|
80
|
+
// passing in the pre-generated mini-tables, in order to force upb to compute
|
|
81
|
+
// them dynamically. Generally you would never want to do this, but we want to
|
|
82
|
+
// simulate the cost we would pay if we were loading these types purely from
|
|
83
|
+
// descriptors, with no mini-tales available.
|
|
84
|
+
bool LoadDefInit_BuildLayout(upb_DefPool* s, const _upb_DefPool_Init* init,
|
|
85
|
+
size_t* bytes) {
|
|
86
|
+
_upb_DefPool_Init** deps = init->deps;
|
|
87
|
+
google_protobuf_FileDescriptorProto* file;
|
|
88
|
+
upb_Arena* arena;
|
|
89
|
+
upb_Status status;
|
|
90
|
+
|
|
91
|
+
upb_Status_Clear(&status);
|
|
92
|
+
|
|
93
|
+
if (upb_DefPool_FindFileByName(s, init->filename)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
arena = upb_Arena_New();
|
|
98
|
+
|
|
99
|
+
for (; *deps; deps++) {
|
|
100
|
+
if (!LoadDefInit_BuildLayout(s, *deps, bytes)) goto err;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
file = google_protobuf_FileDescriptorProto_parse_ex(
|
|
104
|
+
init->descriptor.data, init->descriptor.size, NULL,
|
|
105
|
+
kUpb_DecodeOption_AliasString, arena);
|
|
106
|
+
*bytes += init->descriptor.size;
|
|
107
|
+
|
|
108
|
+
if (!file) {
|
|
109
|
+
upb_Status_SetErrorFormat(
|
|
110
|
+
&status,
|
|
111
|
+
"Failed to parse compiled-in descriptor for file '%s'. This should "
|
|
112
|
+
"never happen.",
|
|
113
|
+
init->filename);
|
|
114
|
+
goto err;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// KEY DIFFERENCE: Here we pass in only the descriptor, and not the
|
|
118
|
+
// pre-generated minitables.
|
|
119
|
+
if (!upb_DefPool_AddFile(s, file, &status)) {
|
|
120
|
+
goto err;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
upb_Arena_Free(arena);
|
|
124
|
+
return true;
|
|
125
|
+
|
|
126
|
+
err:
|
|
127
|
+
fprintf(stderr,
|
|
128
|
+
"Error loading compiled-in descriptor for file '%s' (this should "
|
|
129
|
+
"never happen): %s\n",
|
|
130
|
+
init->filename, upb_Status_ErrorMessage(&status));
|
|
131
|
+
exit(1);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
template <LoadDescriptorMode Mode>
|
|
135
|
+
static void BM_LoadAdsDescriptor_Upb(benchmark::State& state) {
|
|
136
|
+
size_t bytes_per_iter = 0;
|
|
137
|
+
for (auto _ : state) {
|
|
138
|
+
upb::SymbolTable symtab;
|
|
139
|
+
if (Mode == NoLayout) {
|
|
140
|
+
google_ads_googleads_v7_services_SearchGoogleAdsRequest_getmsgdef(
|
|
141
|
+
symtab.ptr());
|
|
142
|
+
bytes_per_iter = _upb_DefPool_BytesLoaded(symtab.ptr());
|
|
143
|
+
} else {
|
|
144
|
+
bytes_per_iter = 0;
|
|
145
|
+
LoadDefInit_BuildLayout(
|
|
146
|
+
symtab.ptr(),
|
|
147
|
+
&google_ads_googleads_v7_services_google_ads_service_proto_upbdefinit,
|
|
148
|
+
&bytes_per_iter);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
state.SetBytesProcessed(state.iterations() * bytes_per_iter);
|
|
152
|
+
}
|
|
153
|
+
BENCHMARK_TEMPLATE(BM_LoadAdsDescriptor_Upb, NoLayout);
|
|
154
|
+
BENCHMARK_TEMPLATE(BM_LoadAdsDescriptor_Upb, WithLayout);
|
|
155
|
+
|
|
156
|
+
template <LoadDescriptorMode Mode>
|
|
157
|
+
static void BM_LoadAdsDescriptor_Proto2(benchmark::State& state) {
|
|
158
|
+
extern _upb_DefPool_Init
|
|
159
|
+
google_ads_googleads_v7_services_google_ads_service_proto_upbdefinit;
|
|
160
|
+
std::vector<upb_StringView> serialized_files;
|
|
161
|
+
absl::flat_hash_set<const _upb_DefPool_Init*> seen_files;
|
|
162
|
+
CollectFileDescriptors(
|
|
163
|
+
&google_ads_googleads_v7_services_google_ads_service_proto_upbdefinit,
|
|
164
|
+
serialized_files, seen_files);
|
|
165
|
+
size_t bytes_per_iter = 0;
|
|
166
|
+
for (auto _ : state) {
|
|
167
|
+
bytes_per_iter = 0;
|
|
168
|
+
protobuf::Arena arena;
|
|
169
|
+
protobuf::DescriptorPool pool;
|
|
170
|
+
for (auto file : serialized_files) {
|
|
171
|
+
protobuf::StringPiece input(file.data, file.size);
|
|
172
|
+
auto proto =
|
|
173
|
+
protobuf::Arena::CreateMessage<protobuf::FileDescriptorProto>(&arena);
|
|
174
|
+
bool ok = proto->ParseFrom<protobuf::MessageLite::kMergePartial>(input) &&
|
|
175
|
+
pool.BuildFile(*proto) != nullptr;
|
|
176
|
+
if (!ok) {
|
|
177
|
+
printf("Failed to add file.\n");
|
|
178
|
+
exit(1);
|
|
179
|
+
}
|
|
180
|
+
bytes_per_iter += input.size();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (Mode == WithLayout) {
|
|
184
|
+
protobuf::DynamicMessageFactory factory;
|
|
185
|
+
const protobuf::Descriptor* d = pool.FindMessageTypeByName(
|
|
186
|
+
"google.ads.googleads.v7.services.SearchGoogleAdsResponse");
|
|
187
|
+
if (!d) {
|
|
188
|
+
printf("Failed to find descriptor.\n");
|
|
189
|
+
exit(1);
|
|
190
|
+
}
|
|
191
|
+
factory.GetPrototype(d);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
state.SetBytesProcessed(state.iterations() * bytes_per_iter);
|
|
195
|
+
}
|
|
196
|
+
BENCHMARK_TEMPLATE(BM_LoadAdsDescriptor_Proto2, NoLayout);
|
|
197
|
+
BENCHMARK_TEMPLATE(BM_LoadAdsDescriptor_Proto2, WithLayout);
|
|
198
|
+
|
|
199
|
+
enum CopyStrings {
|
|
200
|
+
Copy,
|
|
201
|
+
Alias,
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
enum ArenaMode {
|
|
205
|
+
NoArena,
|
|
206
|
+
UseArena,
|
|
207
|
+
InitBlock,
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
template <ArenaMode AMode, CopyStrings Copy>
|
|
211
|
+
static void BM_Parse_Upb_FileDesc(benchmark::State& state) {
|
|
212
|
+
for (auto _ : state) {
|
|
213
|
+
upb_Arena* arena;
|
|
214
|
+
if (AMode == InitBlock) {
|
|
215
|
+
arena = upb_Arena_Init(buf, sizeof(buf), NULL);
|
|
216
|
+
} else {
|
|
217
|
+
arena = upb_Arena_New();
|
|
218
|
+
}
|
|
219
|
+
upb_benchmark_FileDescriptorProto* set =
|
|
220
|
+
upb_benchmark_FileDescriptorProto_parse_ex(
|
|
221
|
+
descriptor.data, descriptor.size, NULL,
|
|
222
|
+
Copy == Alias ? kUpb_DecodeOption_AliasString : 0, arena);
|
|
223
|
+
if (!set) {
|
|
224
|
+
printf("Failed to parse.\n");
|
|
225
|
+
exit(1);
|
|
226
|
+
}
|
|
227
|
+
upb_Arena_Free(arena);
|
|
228
|
+
}
|
|
229
|
+
state.SetBytesProcessed(state.iterations() * descriptor.size);
|
|
230
|
+
}
|
|
231
|
+
BENCHMARK_TEMPLATE(BM_Parse_Upb_FileDesc, UseArena, Copy);
|
|
232
|
+
BENCHMARK_TEMPLATE(BM_Parse_Upb_FileDesc, UseArena, Alias);
|
|
233
|
+
BENCHMARK_TEMPLATE(BM_Parse_Upb_FileDesc, InitBlock, Copy);
|
|
234
|
+
BENCHMARK_TEMPLATE(BM_Parse_Upb_FileDesc, InitBlock, Alias);
|
|
235
|
+
|
|
236
|
+
template <ArenaMode AMode, class P>
|
|
237
|
+
struct Proto2Factory;
|
|
238
|
+
|
|
239
|
+
template <class P>
|
|
240
|
+
struct Proto2Factory<NoArena, P> {
|
|
241
|
+
public:
|
|
242
|
+
P* GetProto() { return &proto_; }
|
|
243
|
+
|
|
244
|
+
private:
|
|
245
|
+
P proto_;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
template <class P>
|
|
249
|
+
struct Proto2Factory<UseArena, P> {
|
|
250
|
+
public:
|
|
251
|
+
P* GetProto() { return protobuf::Arena::CreateMessage<P>(&arena_); }
|
|
252
|
+
|
|
253
|
+
private:
|
|
254
|
+
protobuf::Arena arena_;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
template <class P>
|
|
258
|
+
struct Proto2Factory<InitBlock, P> {
|
|
259
|
+
public:
|
|
260
|
+
Proto2Factory() : arena_(GetOptions()) {}
|
|
261
|
+
P* GetProto() { return protobuf::Arena::CreateMessage<P>(&arena_); }
|
|
262
|
+
|
|
263
|
+
private:
|
|
264
|
+
protobuf::ArenaOptions GetOptions() {
|
|
265
|
+
protobuf::ArenaOptions opts;
|
|
266
|
+
opts.initial_block = buf;
|
|
267
|
+
opts.initial_block_size = sizeof(buf);
|
|
268
|
+
return opts;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
protobuf::Arena arena_;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
using FileDesc = ::upb_benchmark::FileDescriptorProto;
|
|
275
|
+
using FileDescSV = ::upb_benchmark::sv::FileDescriptorProto;
|
|
276
|
+
|
|
277
|
+
template <class P, ArenaMode AMode, CopyStrings kCopy>
|
|
278
|
+
void BM_Parse_Proto2(benchmark::State& state) {
|
|
279
|
+
constexpr protobuf::MessageLite::ParseFlags kParseFlags =
|
|
280
|
+
kCopy == Copy
|
|
281
|
+
? protobuf::MessageLite::ParseFlags::kMergePartial
|
|
282
|
+
: protobuf::MessageLite::ParseFlags::kMergePartialWithAliasing;
|
|
283
|
+
for (auto _ : state) {
|
|
284
|
+
Proto2Factory<AMode, P> proto_factory;
|
|
285
|
+
auto proto = proto_factory.GetProto();
|
|
286
|
+
protobuf::StringPiece input(descriptor.data, descriptor.size);
|
|
287
|
+
bool ok = proto->template ParseFrom<kParseFlags>(input);
|
|
288
|
+
if (!ok) {
|
|
289
|
+
printf("Failed to parse.\n");
|
|
290
|
+
exit(1);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
state.SetBytesProcessed(state.iterations() * descriptor.size);
|
|
294
|
+
}
|
|
295
|
+
BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDesc, NoArena, Copy);
|
|
296
|
+
BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDesc, UseArena, Copy);
|
|
297
|
+
BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDesc, InitBlock, Copy);
|
|
298
|
+
BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDescSV, InitBlock, Alias);
|
|
299
|
+
|
|
300
|
+
static void BM_SerializeDescriptor_Proto2(benchmark::State& state) {
|
|
301
|
+
upb_benchmark::FileDescriptorProto proto;
|
|
302
|
+
proto.ParseFromArray(descriptor.data, descriptor.size);
|
|
303
|
+
for (auto _ : state) {
|
|
304
|
+
proto.SerializePartialToArray(buf, sizeof(buf));
|
|
305
|
+
}
|
|
306
|
+
state.SetBytesProcessed(state.iterations() * descriptor.size);
|
|
307
|
+
}
|
|
308
|
+
BENCHMARK(BM_SerializeDescriptor_Proto2);
|
|
309
|
+
|
|
310
|
+
static void BM_SerializeDescriptor_Upb(benchmark::State& state) {
|
|
311
|
+
int64_t total = 0;
|
|
312
|
+
upb_Arena* arena = upb_Arena_New();
|
|
313
|
+
upb_benchmark_FileDescriptorProto* set =
|
|
314
|
+
upb_benchmark_FileDescriptorProto_parse(descriptor.data, descriptor.size,
|
|
315
|
+
arena);
|
|
316
|
+
if (!set) {
|
|
317
|
+
printf("Failed to parse.\n");
|
|
318
|
+
exit(1);
|
|
319
|
+
}
|
|
320
|
+
for (auto _ : state) {
|
|
321
|
+
upb_Arena* enc_arena = upb_Arena_Init(buf, sizeof(buf), NULL);
|
|
322
|
+
size_t size;
|
|
323
|
+
char* data =
|
|
324
|
+
upb_benchmark_FileDescriptorProto_serialize(set, enc_arena, &size);
|
|
325
|
+
if (!data) {
|
|
326
|
+
printf("Failed to serialize.\n");
|
|
327
|
+
exit(1);
|
|
328
|
+
}
|
|
329
|
+
total += size;
|
|
330
|
+
}
|
|
331
|
+
state.SetBytesProcessed(total);
|
|
332
|
+
}
|
|
333
|
+
BENCHMARK(BM_SerializeDescriptor_Upb);
|