├── .ruby-version ├── ext └── ruby_memprofiler_pprof_ext │ ├── vendor │ └── upb │ │ ├── .bazelignore │ │ ├── upb │ │ ├── empty.proto │ │ ├── conformance_upb_failures.txt │ │ ├── util │ │ │ ├── README.md │ │ │ ├── def_to_proto_weak_import_test.proto │ │ │ ├── def_to_proto_wweak_import_test.proto │ │ │ ├── def_to_proto_public_import_test.proto │ │ │ ├── def_to_proto_regular_import_test.proto │ │ │ ├── required_fields_test.proto │ │ │ ├── compare.h │ │ │ ├── BUILD │ │ │ └── def_to_proto.h │ │ ├── bindings │ │ │ └── lua │ │ │ │ ├── README.md │ │ │ │ ├── test.proto │ │ │ │ ├── upb.lua │ │ │ │ └── main.c │ │ ├── test_cpp.proto │ │ ├── fuzz │ │ │ ├── BUILD │ │ │ └── file_descriptor_parsenew_fuzzer.cc │ │ ├── reflection.hpp │ │ ├── json_decode.h │ │ ├── test.proto │ │ ├── mini_table_accessors_internal.h │ │ ├── port_undef.inc │ │ ├── encode.h │ │ ├── json_encode.h │ │ ├── text_encode.h │ │ └── upb_internal.h │ │ ├── .gitignore │ │ ├── .clang-format │ │ ├── benchmarks │ │ ├── empty.proto │ │ ├── gen_protobuf_binary_cc.py │ │ ├── gen_upb_binary_c.py │ │ ├── BUILD.googleapis │ │ └── build_defs.bzl │ │ ├── python │ │ ├── version_script.lds │ │ ├── pb_unit_tests │ │ │ ├── README.md │ │ │ ├── pyproto_test_wrapper.bzl │ │ │ ├── keywords_test_wrapper.py │ │ │ ├── generator_test_wrapper.py │ │ │ ├── json_format_test_wrapper.py │ │ │ ├── text_format_test_wrapper.py │ │ │ ├── wire_format_test_wrapper.py │ │ │ ├── text_encoding_test_wrapper.py │ │ │ ├── symbol_database_test_wrapper.py │ │ │ ├── unknown_fields_test_wrapper.py │ │ │ ├── service_reflection_test_wrapper.py │ │ │ ├── descriptor_database_test_wrapper.py │ │ │ ├── proto_builder_test_wrapper.py │ │ │ ├── well_known_types_test_wrapper.py │ │ │ ├── message_factory_test_wrapper.py │ │ │ ├── descriptor_pool_test_wrapper.py │ │ │ ├── reflection_test_wrapper.py │ │ │ ├── descriptor_test_wrapper.py │ │ │ ├── BUILD │ │ │ └── message_test_wrapper.py │ │ ├── extension_dict.h │ │ ├── unknown_fields.h │ │ ├── py_extension.bzl │ │ ├── descriptor_pool.h │ │ ├── python_api.h │ │ ├── map.h │ │ ├── convert.h │ │ └── repeated.h │ │ ├── third_party │ │ ├── lunit │ │ │ ├── README.google │ │ │ └── LICENSE │ │ └── utf8_range │ │ │ ├── utf8_range.h │ │ │ ├── BUILD │ │ │ └── LICENSE │ │ ├── .bazelci │ │ └── presubmit.yml │ │ ├── .github │ │ └── workflows │ │ │ ├── clang_format.yml │ │ │ ├── generate_files.yml │ │ │ ├── cifuzz.yml │ │ │ └── bazel_tests.yml │ │ ├── cmake │ │ ├── README.md │ │ ├── staleness_test.py │ │ └── build_defs.bzl │ │ ├── docs │ │ ├── render.py │ │ └── style-guide.md │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── bazel │ │ ├── protobuf.patch │ │ ├── BUILD │ │ ├── python_downloads.bzl │ │ └── workspace_deps.bzl │ │ ├── WORKSPACE │ │ ├── README.md │ │ ├── upbc │ │ ├── BUILD │ │ └── common.cc │ │ └── .bazelrc │ ├── ruby_memprofiler_pprof.c │ ├── ruby_private.h │ └── sample.c ├── .clang-format ├── .rubocop.yml ├── doc └── images │ ├── app_latency.png │ ├── app_profile.png │ └── go_flamegraph_example.png ├── lib ├── ruby_memprofiler_pprof │ ├── version.rb │ ├── profile_data.rb │ ├── profile_app.rb │ ├── file_flusher.rb │ ├── atfork.rb │ └── block_flusher.rb └── ruby_memprofiler_pprof.rb ├── .gitignore ├── Gemfile ├── script ├── benchmark_isolated.rb ├── benchmark.rb ├── torture_test.rb └── benchmark_support.rb ├── libexec └── ruby_memprofiler_pprof_profile ├── .github └── workflows │ └── test.yml ├── ruby_memprofiler_pprof.gemspec ├── Rakefile ├── Gemfile.lock └── test ├── test_helper.rb ├── test_profiling.rb ├── test_file_flusher.rb └── pprof_pb.rb /.ruby-version: -------------------------------------------------------------------------------- 1 | 3.0.4 2 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/.bazelignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: 'LLVM' 3 | ColumnLimit: 120 4 | 5 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/empty.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | require: standard 2 | inherit_gem: 3 | standard: config/base.yml 4 | 5 | -------------------------------------------------------------------------------- /doc/images/app_latency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/ruby_memprofiler_pprof/HEAD/doc/images/app_latency.png -------------------------------------------------------------------------------- /doc/images/app_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/ruby_memprofiler_pprof/HEAD/doc/images/app_profile.png -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/.gitignore: -------------------------------------------------------------------------------- 1 | *.sw? 2 | obj/ 3 | lib/ 4 | bazel-* 5 | _build 6 | .vscode 7 | -------------------------------------------------------------------------------- /doc/images/go_flamegraph_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/ruby_memprofiler_pprof/HEAD/doc/images/go_flamegraph_example.png -------------------------------------------------------------------------------- /lib/ruby_memprofiler_pprof/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MemprofilerPprof 4 | VERSION = "0.0.4" 5 | end 6 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | DerivePointerAlignment: false 3 | PointerAlignment: Left 4 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/conformance_upb_failures.txt: -------------------------------------------------------------------------------- 1 | # No conformance tests are failing, thus the failure list is empty. 2 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/benchmarks/empty.proto: -------------------------------------------------------------------------------- 1 | 2 | syntax = "proto3"; 3 | 4 | package upb_benchmark; 5 | 6 | message Empty {} 7 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/version_script.lds: -------------------------------------------------------------------------------- 1 | message { 2 | global: 3 | PyInit__message; 4 | local: 5 | *; 6 | }; 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.bundle 3 | tmp/ 4 | *.gem 5 | ext/ruby_memprofiler_pprof/Makefile 6 | mkmf.log 7 | *.o 8 | .vscode/ 9 | .gdb_history 10 | extconf.h 11 | .cache/ 12 | compile_commands.json 13 | .DS_Store 14 | 15 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/third_party/lunit/README.google: -------------------------------------------------------------------------------- 1 | URL: https://github.com/dcurrie/lunit 2 | Version: 0.5 3 | License: MIT 4 | License File: LICENSE 5 | Description: 6 | A unit testing library for Lua. 7 | 8 | Local Modifications: 9 | Extracted the two file we actually need from the distribution. 10 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/.bazelci/presubmit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | tasks: 3 | ubuntu: 4 | platform: ubuntu1804 5 | shell_commands: 6 | - "sudo apt -y update && sudo apt -y install libreadline-dev cmake" 7 | test_targets: 8 | - //... 9 | macos: 10 | platform: macos 11 | test_targets: 12 | - //... 13 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/util/README.md: -------------------------------------------------------------------------------- 1 | 2 | # upb util library 3 | 4 | The libraries in this directory contain useful functionality that is layered 5 | on top of the main upb APIs. In other words, the APIs in this directory have 6 | no special access to upb internals; you could easily implement the same things 7 | yourself. 8 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/bindings/lua/README.md: -------------------------------------------------------------------------------- 1 | 2 | # upb Lua bindings 3 | 4 | These are some bare-bones upb bindings for Lua. 5 | 6 | These bindings exist primarily for experimentation and testing. They are 7 | incomplete and are not really intended for use in any application. This is by 8 | no means a complete or supported protobuf library. 9 | -------------------------------------------------------------------------------- /lib/ruby_memprofiler_pprof.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'backtracie' 4 | require "ruby_memprofiler_pprof/version" 5 | require "ruby_memprofiler_pprof/profile_data" 6 | require "ruby_memprofiler_pprof_ext" 7 | require "ruby_memprofiler_pprof/atfork" 8 | require "ruby_memprofiler_pprof/block_flusher" 9 | require "ruby_memprofiler_pprof/file_flusher" 10 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/test_cpp.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package upb.test; 4 | 5 | message TestMessage { 6 | optional int32 i32 = 1 [default = 5]; 7 | repeated int32 r_i32 = 2; 8 | optional string str = 3 [default = "abc"]; 9 | repeated string r_str = 4; 10 | optional TestMessage msg = 5; 11 | repeated TestMessage r_msg = 6; 12 | } 13 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | gemspec 6 | 7 | gem "bump", "~> 0.10" 8 | gem "google-protobuf", "~> 3" 9 | gem "minitest", "~> 5" 10 | gem "pry", "~> 0.14" 11 | gem "rake", "~> 13" 12 | gem "rake-compiler", "~> 1" 13 | gem "sinatra", "~> 2" 14 | gem "standard", "~> 1.14" 15 | gem "thwait", "~> 0.2" 16 | gem "timecop", "~> 0.9" 17 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/ruby_memprofiler_pprof.c: -------------------------------------------------------------------------------- 1 | #include "ruby_memprofiler_pprof.h" 2 | #include 3 | 4 | // This should be the only symbol actually visible to Ruby 5 | __attribute__((visibility("default"))) void Init_ruby_memprofiler_pprof_ext() { 6 | rb_ext_ractor_safe(true); 7 | 8 | rb_define_module("MemprofilerPprof"); 9 | mpp_setup_collector_class(); 10 | } 11 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/third_party/utf8_range/utf8_range.h: -------------------------------------------------------------------------------- 1 | 2 | #if (defined(__ARM_NEON) && defined(__aarch64__)) || defined(__SSE4_1__) 3 | int utf8_range2(const unsigned char* data, int len); 4 | #else 5 | int utf8_naive(const unsigned char* data, int len); 6 | static inline int utf8_range2(const unsigned char* data, int len) { 7 | return utf8_naive(data, len); 8 | } 9 | #endif 10 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/fuzz/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test") 2 | 3 | licenses(["notice"]) 4 | 5 | cc_fuzz_test( 6 | name = "file_descriptor_parsenew_fuzzer", 7 | srcs = ["file_descriptor_parsenew_fuzzer.cc"], 8 | deps = [ 9 | "//:descriptor_upb_proto", 10 | "//:reflection", 11 | "//:upb", 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /script/benchmark_isolated.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative "benchmark_support" 4 | 5 | leak_pit = [] 6 | sc = BENCHMARK_SCENARIO.dup 7 | GC.start 8 | $collector = MemprofilerPprof::Collector.new 9 | $collector.sample_rate = 0.1 10 | time = Benchmark.measure do 11 | $collector.start! 12 | benchmark_machine(sc, leak_pit) 13 | File.write("tmp/benchmark-10p.pb.gz", $collector.flush.pprof_data) 14 | $collector.stop! 15 | end 16 | 17 | puts time 18 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/third_party/utf8_range/BUILD: -------------------------------------------------------------------------------- 1 | 2 | # Pulled from: https://github.com/cyb70289/utf8 3 | 4 | cc_library( 5 | name = "utf8_range", 6 | hdrs = ["utf8_range.h"], 7 | srcs = [ 8 | "naive.c", 9 | "range2-neon.c", 10 | "range2-sse.c", 11 | ], 12 | visibility = ["//:__pkg__"], 13 | ) 14 | 15 | filegroup( 16 | name = "cmake_files", 17 | srcs = glob(["*"]), 18 | visibility = ["//cmake:__pkg__"], 19 | ) 20 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/.github/workflows/clang_format.yml: -------------------------------------------------------------------------------- 1 | name: Check ClangFormat 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | workflow_dispatch: 11 | 12 | jobs: 13 | check_clang_format: 14 | runs-on: ubuntu-20.04 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Run ClangFormat 18 | run: find . | grep -E '\.(c|h|cc)$' | grep -E -v '^./(third_party|cmake)' | xargs clang-format -i 19 | - name: Check for differences 20 | run: git diff --exit-code 21 | -------------------------------------------------------------------------------- /libexec/ruby_memprofiler_pprof_profile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # Simply starts the provided program as-is, but sets RUBYLIB so that it will be 5 | # profiled by ruby_memprofiler_pprof. 6 | 7 | require "shellwords" 8 | 9 | base_path = File.expand_path("../lib", __dir__) 10 | profile_lib = File.join(base_path, "ruby_memprofiler_pprof", "profile_app.rb") 11 | opts = [ 12 | "-I#{Shellwords.escape base_path}", 13 | "-r#{Shellwords.escape profile_lib}" 14 | ] 15 | ENV["RUBYOPT"] = ([ENV.fetch("RUBYOPT", nil)] + opts).compact.join(" ") 16 | exec(*ARGV) 17 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Protobuf Unit Tests 3 | 4 | This directory contains wrappers around the Python unit tests defined in 5 | the protobuf repo. Python+upb is intended to be a drop-in replacement for 6 | protobuf Python, so we should be able to pass the same set of unit tests. 7 | 8 | Our wrappers contain exclusion lists for tests we know we are not currently 9 | passing. Ideally these exclusion lists will become empty once Python+upb is 10 | fully implemented. However there may be a few edge cases that we decide 11 | are not worth matching with perfect parity. 12 | -------------------------------------------------------------------------------- /lib/ruby_memprofiler_pprof/profile_data.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MemprofilerPprof 4 | class ProfileData 5 | attr_accessor :pprof_data, :heap_samples_count, :dropped_samples_heap_bufsize, 6 | :flush_duration_nsecs, :pprof_serialization_nsecs, :sample_add_nsecs, 7 | :sample_add_without_gvl_nsecs, 8 | :gvl_proactive_yield_count, :gvl_proactive_check_yield_count, 9 | 10 | def to_s 11 | "" 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/.github/workflows/generate_files.yml: -------------------------------------------------------------------------------- 1 | name: Generate Files 2 | 3 | # After any push to the main branch, re-generate pregenerated files. 4 | on: 5 | push: 6 | branches: 7 | - main 8 | 9 | jobs: 10 | generate: 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Merge generated branch with main 16 | run: cd ${{ github.workspace }} && (git checkout generated || git checkout -b generated) && git merge --no-edit main 17 | - name: Rebuild generated CMake files 18 | run: cd ${{ github.workspace }} && bazel test cmake:test_generated_files || bazel-bin/cmake/test_generated_files --fix 19 | - name: Commit and push changes to generated files 20 | run: cd ${{ github.workspace }} && git add -A && (git diff --staged --quiet || git commit -am "Regenerated files") && git push 21 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/.github/workflows/cifuzz.yml: -------------------------------------------------------------------------------- 1 | name: CIFuzz 2 | on: [pull_request] 3 | jobs: 4 | Fuzzing: 5 | runs-on: ubuntu-latest 6 | strategy: 7 | fail-fast: false 8 | matrix: 9 | sanitizer: [address, undefined] 10 | steps: 11 | - name: Build Fuzzers (${{ matrix.sanitizer }}) 12 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 13 | with: 14 | oss-fuzz-project-name: 'upb' 15 | dry-run: false 16 | sanitizer: ${{ matrix.sanitizer }} 17 | - name: Run Fuzzers (${{ matrix.sanitizer }}) 18 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 19 | with: 20 | oss-fuzz-project-name: 'upb' 21 | fuzz-seconds: 600 22 | dry-run: false 23 | sanitizer: ${{ matrix.sanitizer }} 24 | - name: Upload Crash 25 | uses: actions/upload-artifact@v1 26 | if: failure() 27 | with: 28 | name: ${{ matrix.sanitizer }}-artifacts 29 | path: ./out/artifacts 30 | -------------------------------------------------------------------------------- /lib/ruby_memprofiler_pprof/profile_app.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # This file gets loaded by libexec/ruby_memprofiler_pprof_profile as part 4 | # of RUBYOPTS for a child process. This means we're going to run in some target 5 | # process _before_ any of the app code is run. Our job here is to set up 6 | # heap profiling in some default way. 7 | 8 | require "logger" 9 | require "ruby_memprofiler_pprof" 10 | 11 | collector = MemprofilerPprof::Collector.new 12 | collector.sample_rate = ENV.fetch("RUBY_MEMPROFILER_PPROF_SAMPLE_RATE", "1").to_f 13 | if ENV.key?("RUBY_MEMPROFILER_PPROF_MAX_HEAP_SAMPLES") 14 | collector.max_heap_samples = ENV["RUBY_MEMPROFILER_PPROF_MAX_HEAP_SAMPLES"].to_i 15 | end 16 | 17 | kwargs = { 18 | logger: Logger.new($stderr) 19 | } 20 | if ENV.key?("RUBY_MEMPROFILER_PPROF_FILE_PATTERN") 21 | kwargs[:pattern] = ENV["RUBY_MEMPROFILER_PPROF_FILE_PATTERN"] 22 | end 23 | 24 | flusher = MemprofilerPprof::FileFlusher.new(collector, **kwargs) 25 | collector.start! 26 | flusher.start! 27 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/ruby_private.h: -------------------------------------------------------------------------------- 1 | #ifndef __RUBY_PRIVATE_H 2 | #define __RUBY_PRIVATE_H 3 | 4 | #include "extconf.h" 5 | #include RUBY_MJIT_HEADER 6 | 7 | #include 8 | #include 9 | 10 | // Default this to zero unless the MJIT header already has a value 11 | #ifndef GC_DEBUG_STRESS_TO_CLASS 12 | #define GC_DEBUG_STRESS_TO_CLASS 0 13 | #endif 14 | 15 | // This is the correct default for GC_ENABLE_INCREMENTAL_MARK 16 | #ifndef GC_ENABLE_INCREMENTAL_MARK 17 | #define GC_ENABLE_INCREMENTAL_MARK USE_RINCGC 18 | #endif 19 | 20 | // Prototype for functions that are exposed with external linkage, but not in 21 | // the public headers. 22 | size_t rb_obj_memsize_of(VALUE obj); 23 | 24 | // Bring in an appropriate version of the rb_objspace structs; this will include 25 | // one of the files under ruby_private/ depending on version. 26 | #include "gc_private.h" 27 | 28 | #define CLASS_OR_MODULE_P(obj) \ 29 | (!SPECIAL_CONST_P(obj) && (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE)) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: push 3 | jobs: 4 | test: 5 | name: test 6 | runs-on: ubuntu-20.04 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | ruby: 11 | - '2.6' 12 | - '2.7' 13 | - '3.0' 14 | - '3.1' 15 | steps: 16 | - uses: zendesk/checkout@v2 17 | - uses: zendesk/setup-ruby@v1 18 | with: 19 | ruby-version: ${{ matrix.ruby }} 20 | - name: setup_env 21 | run: | 22 | echo "BUNDLE_GEMFILE=$GITHUB_WORKSPACE/Gemfile" >> $GITHUB_ENV 23 | shell: bash 24 | - name: gem_cache 25 | id: cache 26 | uses: zendesk/cache@v2 27 | with: 28 | path: vendor/bundle 29 | key: cache-${{ runner.os }}-ruby-${{ matrix.ruby }}-${{ hashFiles('Gemfile.lock') }} 30 | - name: install_gems 31 | run: | 32 | bundle config path vendor/bundle 33 | bundle install 34 | - name: compile 35 | run: | 36 | bundle exec rake compile VERBOSE=true 37 | - name: test 38 | run: | 39 | bundle exec rake test 40 | -------------------------------------------------------------------------------- /ruby_memprofiler_pprof.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative "./lib/ruby_memprofiler_pprof/version" 4 | 5 | Gem::Specification.new do |spec| 6 | spec.name = "ruby_memprofiler_pprof" 7 | spec.version = MemprofilerPprof::VERSION 8 | spec.authors = ["KJ Tsanaktsidis"] 9 | spec.email = ["ktsanaktsidis@zendesk.com"] 10 | spec.summary = "Ruby pprof memproy profiler" 11 | spec.description = "Generates pprof profiles of ruby memory usage" 12 | spec.homepage = "https://github.com/zendesk/ruby_memprofiler_pprof" 13 | spec.license = "Apache-2.0" 14 | 15 | spec.files = Dir.glob("{ext,lib,libexec}/**/*").reject { |f| %w[.so .bundle].include? File.extname(f) } 16 | spec.extensions = ["ext/ruby_memprofiler_pprof_ext/extconf.rb"] 17 | spec.bindir = "libexec" 18 | spec.executables = %w[ruby_memprofiler_pprof_profile] 19 | 20 | spec.required_ruby_version = ">= 2.6.0" 21 | 22 | # This incredibly tight pin on backtracie is required, because we're calling its C internals via 23 | # a header file we vendored. Upgrading this requires copoying a new version of the header file. 24 | spec.add_dependency 'backtracie', '= 1.0.0' 25 | end 26 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/pyproto_test_wrapper.bzl: -------------------------------------------------------------------------------- 1 | # begin:github_only 2 | 3 | def pyproto_test_wrapper(name): 4 | src = name + "_wrapper.py" 5 | native.py_test( 6 | name = name, 7 | srcs = [src], 8 | legacy_create_init = False, 9 | main = src, 10 | data = ["@com_google_protobuf//:testdata"], 11 | deps = [ 12 | "//python:_message", 13 | "@com_google_protobuf//:python_common_test_protos", 14 | "@com_google_protobuf//:python_specific_test_protos", 15 | "@com_google_protobuf//:python_test_srcs", 16 | "@com_google_protobuf//:python_srcs", 17 | ], 18 | ) 19 | 20 | # end:github_only 21 | 22 | # begin:google_only 23 | # 24 | # def pyproto_test_wrapper(name): 25 | # src = name + "_wrapper.py" 26 | # native.py_test( 27 | # name = name, 28 | # srcs = [src], 29 | # main = src, 30 | # deps = [ 31 | # "//net/proto2/python/internal:" + name + "_for_deps", 32 | # "//net/proto2/python/public:use_upb_protos", 33 | # ], 34 | # ) 35 | # 36 | # end:google_only 37 | -------------------------------------------------------------------------------- /script/benchmark.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative "benchmark_support" 4 | 5 | Benchmark.bm(36) do |b| 6 | leak_pit = [] 7 | sc = BENCHMARK_SCENARIO.dup 8 | GC.start 9 | b.report("no profiling (1)") do 10 | benchmark_machine(sc, leak_pit) 11 | end 12 | 13 | leak_pit = [] 14 | sc = BENCHMARK_SCENARIO.dup 15 | GC.start 16 | b.report("no profiling (2)") do 17 | benchmark_machine(sc, leak_pit) 18 | end 19 | 20 | [1, 10, 100].each do |perc| 21 | leak_pit = [] 22 | sc = BENCHMARK_SCENARIO.dup 23 | GC.start 24 | $collector = MemprofilerPprof::Collector.new 25 | $collector.sample_rate = 0.01 * perc 26 | b.report("with profiling (#{perc}%, no flush)") do 27 | $collector.start! 28 | 29 | benchmark_machine(sc, leak_pit) 30 | 31 | $collector.stop! 32 | end 33 | 34 | leak_pit = [] 35 | sc = BENCHMARK_SCENARIO.dup 36 | GC.start 37 | b.report("with reporting (#{perc}%, with flush)") do 38 | $collector.start! 39 | 40 | benchmark_machine(sc, leak_pit) 41 | File.write("tmp/benchmark-#{perc}p.pb.gz", $collector.flush.pprof_data) 42 | $collector.stop! 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/third_party/utf8_range/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Yibo Cai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/cmake/README.md: -------------------------------------------------------------------------------- 1 | 2 | # upb CMake build (EXPERIMENTAL) 3 | 4 | upb's CMake support is experimental. The core library builds successfully 5 | under CMake, and this is verified by the Bazel tests in this directory. 6 | However there is no support for building the upb compiler or for generating 7 | .upb.c/upb.h files. This means upb's CMake support is incomplete at best, 8 | unless your application is intended to be purely reflective. 9 | 10 | If you find this CMake setup useful in its current state, please consider 11 | filing an issue so we know. If you have suggestions for how it could be 12 | more useful (and particularly if you can contribute some code for it) 13 | please feel free to file an issue for that too. Do keep in mind that upb 14 | does not currently provide any ABI stability, so we want to avoid providing 15 | a shared library. 16 | 17 | The CMakeLists.txt is generated from the Bazel BUILD files using the Python 18 | scripts in this directory. We want to avoid having two separate sources of 19 | truth that both need to be updated when a file is added or removed. 20 | 21 | This directory also contains some generated files that would be created 22 | on the fly during a Bazel build. These are automaticaly kept in sync by 23 | the Bazel test `//cmake:test_generated_files`. 24 | -------------------------------------------------------------------------------- /script/torture_test.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "sinatra/base" 5 | require "securerandom" 6 | require "rack/mock" 7 | require "thwait" 8 | require "ruby_memprofiler_pprof" 9 | 10 | Thread.abort_on_exception = true 11 | 12 | # This is a mock sinatra app, which will generate all the benchmarking. 13 | class TestApp < Sinatra::Base 14 | @bench_bucket = [] 15 | get "/bench" do 16 | if @bench_bucket.size < 50000 17 | rand(0..100).times do 18 | @bench_bucket << SecureRandom.hex(20) 19 | end 20 | else 21 | rand(0..100).times do 22 | @bench_bucket.pop 23 | end 24 | end 25 | 26 | @bench_bucket.pop || "empty!" 27 | end 28 | end 29 | 30 | collector = MemprofilerPprof::Collector.new 31 | collector.sample_rate = 1.0 32 | 33 | threads = (0..5).map do 34 | Thread.new do 35 | loop do 36 | r = Rack::MockRequest.new(TestApp) 37 | r.get("/bench") 38 | end 39 | end 40 | end 41 | 42 | threads << Thread.new do 43 | collector.start! 44 | loop do 45 | sleep 15 46 | collector.flush # Flush to dev-null 47 | end 48 | end 49 | 50 | threads << Thread.new do 51 | collector.start! 52 | loop do 53 | sleep 50 54 | collector.stop! 55 | collector.start! 56 | end 57 | end 58 | 59 | threads << Thread.new do 60 | loop do 61 | sleep 10 62 | GC.compact 63 | end 64 | end 65 | 66 | ThreadsWait.all_waits(*threads) 67 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rake/extensiontask" 3 | require "rake/testtask" 4 | require "bump/tasks" 5 | 6 | # Compile verbosely if specified. 7 | ENV["MAKE"] = "make V=1" if ENV["VERBOSE"] == "true" 8 | 9 | Rake::ExtensionTask.new("ruby_memprofiler_pprof_ext") 10 | 11 | Rake::TestTask.new(:test) do |t| 12 | t.libs << "test" 13 | t.libs << "lib" 14 | t.test_files = FileList["test/**/test_*.rb"] 15 | t.verbose = true 16 | t.options = "--verbose" 17 | t.warning = false 18 | end 19 | 20 | task default: [:compile] 21 | 22 | # These Rake tasks run the protobuf compiler to generate the .upb.c code. These are not run as part of 23 | # the gem install; the generated protobufs are actually checked in. We also check in a complete copy 24 | # of the upb library source and build it when the gem is installed too. 25 | 26 | task :proto_compile do 27 | upb_dir = "ext/ruby_memprofiler_pprof/vendor/upb" 28 | # Build protoc-gen-upb 29 | cd "#{upb_dir}/upbc" do 30 | sh "bazel", "build", "protoc-gen-upb" 31 | end 32 | 33 | # Delete & recompile the protobufs 34 | Dir["ext/ruby_memprofiler_pprof/*.upb.{c,h}"].each { |f| rm_rf f } 35 | Dir["lib/ruby_memprofiler_pprof/pb/*_pb.rb"].each { |f| rm_rf f } 36 | 37 | protoc_gen_upb = "#{upb_dir}/bazel-bin/upbc/protoc-gen-upb" 38 | sh "protoc", "--proto_path=proto", "--plugin=#{protoc_gen_upb}", 39 | "--upb_out=ext/ruby_memprofiler_pprof_ext", "--ruby_out=test", 40 | *Dir["proto/*.proto"] 41 | end 42 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/docs/render.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import subprocess 4 | import sys 5 | import shutil 6 | import os 7 | 8 | if len(sys.argv) < 2: 9 | print("Must pass a filename argument") 10 | sys.exit(1) 11 | 12 | in_filename = sys.argv[1] 13 | out_filename = in_filename.replace(".in.md", ".md") 14 | out_dir = in_filename.replace(".in.md", "") 15 | 16 | if in_filename == out_filename: 17 | print("File must end in .in.md") 18 | sys.exit(1) 19 | 20 | if os.path.isdir(out_dir): 21 | shutil.rmtree(out_dir) 22 | 23 | os.mkdir(out_dir) 24 | file_num = 1 25 | 26 | with open(out_filename, "wb") as out_file, open(in_filename, "rb") as in_file: 27 | for line in in_file: 28 | if line.startswith(b"```dot"): 29 | dot_lines = [] 30 | while True: 31 | dot_line = next(in_file) 32 | if dot_line == b"```\n": 33 | break 34 | dot_lines.append(dot_line) 35 | dot_input = b"".join(dot_lines) 36 | svg_filename = out_dir + "/" + str(file_num) + ".svg" 37 | svg = subprocess.check_output(['dot', '-Tsvg', '-o', svg_filename], input=dot_input) 38 | out_file.write(b"
\n") 39 | out_file.write(b"\n" % (svg_filename.encode('utf-8'))) 40 | out_file.write(b"
\n") 41 | file_num += 1 42 | else: 43 | out_file.write(line) 44 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # How to Contribute 3 | 4 | We'd love to accept your patches and contributions to this project. There are 5 | just a few small guidelines you need to follow. 6 | 7 | ## Get in touch 8 | 9 | If your idea will take you more than, say, 30 minutes to 10 | implement, please get in touch first via the issue tracker 11 | to touch base about your plan. That will give an 12 | opportunity for early feedback and help avoid wasting your 13 | time. 14 | 15 | ## Contributor License Agreement 16 | 17 | Contributions to this project must be accompanied by a Contributor License 18 | Agreement. You (or your employer) retain the copyright to your contribution; 19 | this simply gives us permission to use and redistribute your contributions as 20 | part of the project. Head over to to see 21 | your current agreements on file or to sign a new one. 22 | 23 | You generally only need to submit a CLA once, so if you've already submitted one 24 | (even if it was for a different project), you probably don't need to do it 25 | again. 26 | 27 | ## Code Reviews 28 | 29 | All submissions, including submissions by project members, require review. We 30 | use GitHub pull requests for this purpose. Consult 31 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 32 | information on using pull requests. 33 | 34 | ## Community Guidelines 35 | 36 | This project follows [Google's Open Source Community 37 | Guidelines](https://opensource.google/conduct/). 38 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/third_party/lunit/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Lunit License 3 | ------------- 4 | 5 | Lunit is written by Michael Roth and is licensed 6 | under the terms of the MIT license reproduced below. 7 | 8 | ======================================================================== 9 | 10 | Copyright (c) 2004-2010 Michael Roth 11 | 12 | Permission is hereby granted, free of charge, to any person 13 | obtaining a copy of this software and associated documentation 14 | files (the "Software"), to deal in the Software without restriction, 15 | including without limitation the rights to use, copy, modify, merge, 16 | publish, distribute, sublicense, and/or sell copies of the Software, 17 | and to permit persons to whom the Software is furnished to do so, 18 | subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 26 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 27 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 28 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 29 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ======================================================================== 32 | 33 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2009-2021, Google LLC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of Google LLC nor the names of any other 14 | contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | EVENT SHALL GOOGLE LLC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 24 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/util/def_to_proto_weak_import_test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | syntax = "proto3"; 29 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/util/def_to_proto_wweak_import_test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | syntax = "proto3"; 29 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/util/def_to_proto_public_import_test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | syntax = "proto3"; 29 | 30 | package pkg; 31 | 32 | message PublicImportMessage {} 33 | -------------------------------------------------------------------------------- /lib/ruby_memprofiler_pprof/file_flusher.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "fileutils" 4 | require "forwardable" 5 | require "time" 6 | 7 | module MemprofilerPprof 8 | class FileFlusher 9 | extend Forwardable 10 | 11 | def initialize( 12 | collector, pattern: "tmp/profiles/mem-%{pid}-%{isotime}.pprof", interval: 30, logger: nil, priority: nil, 13 | yield_gvl: false, proactively_yield_gvl: false 14 | ) 15 | @logger = logger 16 | @pattern = pattern 17 | @profile_counter = 0 18 | @block_flusher = BlockFlusher.new( 19 | collector, interval: interval, logger: logger, priority: priority, 20 | yield_gvl: yield_gvl, proactively_yield_gvl: proactively_yield_gvl, 21 | on_flush: method(:on_flush) 22 | ) 23 | end 24 | 25 | def_delegators :@block_flusher, :start!, :stop!, :run 26 | attr_accessor :pattern 27 | 28 | private 29 | 30 | def on_flush(profile_data) 31 | fname = template_string(@pattern) 32 | dirname = File.dirname(fname) 33 | FileUtils.mkdir_p dirname 34 | # Need to explicitly specify the encoding, because some applications might do exotic 35 | # things to File#default_external/#default_internal that would attempt to convert 36 | # our protobuf to UTF-8. 37 | File.write(template_string(@pattern), profile_data.pprof_data, encoding: "ASCII-8BIT") 38 | @profile_counter += 1 39 | rescue => e 40 | @logger&.error("FileFlusher: failed to flush profiling data: #{e.inspect}") 41 | end 42 | 43 | def template_string(tmpl) 44 | vars = { 45 | pid: Process.pid, 46 | isotime: Time.now.iso8601, 47 | unixtime: Time.now.to_i, 48 | index: @profile_counter 49 | } 50 | sprintf(tmpl, vars) 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/keywords_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.keywords_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/generator_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.generator_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/json_format_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.json_format_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/text_format_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.text_format_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/wire_format_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.wire_format_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/text_encoding_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.text_encoding_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/symbol_database_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.symbol_database_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/unknown_fields_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.unknown_fields_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/service_reflection_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.service_reflection_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/descriptor_database_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.descriptor_database_test import * 27 | import unittest 28 | 29 | if __name__ == '__main__': 30 | unittest.main(verbosity=2) 31 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/util/def_to_proto_regular_import_test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | syntax = "proto3"; 29 | 30 | package pkg; 31 | 32 | message RegularImportMessage {} 33 | 34 | enum Proto3Enum { 35 | PROTO3_ENUM_ZERO = 0; 36 | } 37 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/sample.c: -------------------------------------------------------------------------------- 1 | #include "ruby_memprofiler_pprof.h" 2 | #include 3 | #include 4 | 5 | // Total size of all things owned by the sample, for accounting purposes 6 | size_t mpp_sample_memsize(struct mpp_sample *sample) { 7 | return sizeof(struct mpp_sample) + sample->frames_capacity * sizeof(minimal_location_t); 8 | } 9 | 10 | // Free the sample, incl. releasing strings it interned. 11 | void mpp_sample_free(struct mpp_sample *sample) { mpp_free(sample); } 12 | 13 | struct mpp_sample *mpp_sample_capture(VALUE allocated_value_weak) { 14 | VALUE thread = rb_thread_current(); 15 | int stack_size = backtracie_frame_count_for_thread(thread); 16 | struct mpp_sample *sample = mpp_xmalloc(sizeof(struct mpp_sample) + stack_size * sizeof(minimal_location_t)); 17 | sample->frames_capacity = stack_size; 18 | sample->frames_count = 0; 19 | sample->allocated_value_weak = allocated_value_weak; 20 | memset(sample->frames, 0, stack_size * sizeof(minimal_location_t)); 21 | 22 | for (int i = 0; i < stack_size; i++) { 23 | minimal_location_t *frame = &sample->frames[sample->frames_count]; 24 | bool is_valid = backtracie_capture_minimal_frame_for_thread(thread, i, frame); 25 | if (is_valid) { 26 | sample->frames_count++; 27 | } 28 | } 29 | 30 | return sample; 31 | } 32 | 33 | size_t mpp_sample_frame_function_name(struct mpp_sample *sample, int frame_index, char *outbuf, size_t outbuf_len) { 34 | return backtracie_minimal_frame_name_cstr(&sample->frames[frame_index], outbuf, outbuf_len); 35 | } 36 | 37 | size_t mpp_sample_frame_file_name(struct mpp_sample *sample, int frame_index, char *outbuf, size_t outbuf_len) { 38 | return backtracie_minimal_frame_filename_cstr(&sample->frames[frame_index], outbuf, outbuf_len); 39 | } 40 | 41 | int mpp_sample_frame_line_number(struct mpp_sample *sample, int frame_index) { 42 | return sample->frames[frame_index].line_number; 43 | } 44 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/proto_builder_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.proto_builder_test import * 27 | import unittest 28 | 29 | ProtoBuilderTest.testMakeLargeProtoClass.__unittest_expecting_failure__ = True 30 | 31 | if __name__ == '__main__': 32 | unittest.main(verbosity=2) 33 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/reflection.hpp: -------------------------------------------------------------------------------- 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 | #ifndef UPB_REFLECTION_HPP_ 27 | #define UPB_REFLECTION_HPP_ 28 | 29 | #include "upb/reflection.h" 30 | 31 | namespace upb { 32 | 33 | typedef upb_MessageValue MessageValue; 34 | 35 | } // namespace upb 36 | 37 | #endif // UPB_REFLECTION_HPP_ 38 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/extension_dict.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PYUPB_EXTENSION_DICT_H__ 29 | #define PYUPB_EXTENSION_DICT_H__ 30 | 31 | #include 32 | 33 | #include "python/python_api.h" 34 | 35 | PyObject* PyUpb_ExtensionDict_New(PyObject* msg); 36 | 37 | bool PyUpb_InitExtensionDict(PyObject* m); 38 | 39 | #endif // PYUPB_EXTENSION_DICT_H__ 40 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/unknown_fields.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PYUPB_UNKNOWN_FIELDS_H__ 29 | #define PYUPB_UNKNOWN_FIELDS_H__ 30 | 31 | #include 32 | 33 | #include "python/python_api.h" 34 | 35 | PyObject* PyUpb_UnknownFields_New(PyObject* msg); 36 | 37 | bool PyUpb_UnknownFields_Init(PyObject* m); 38 | 39 | #endif // PYUPB_UNKNOWN_FIELDS_H__ 40 | -------------------------------------------------------------------------------- /script/benchmark_support.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | require "logger" 3 | require "benchmark" 4 | require "securerandom" 5 | require "objspace" 6 | require "pp" 7 | require "ruby_memprofiler_pprof" 8 | 9 | NUM_DISTINCT_CLASSES = 10000 10 | NUM_DISTINCT_METHODS = 20000 11 | BENCHMARK_LENGTH = 350000 * 2 12 | MAX_DEPTH = 100 13 | 14 | benchmark_classes = (0..NUM_DISTINCT_CLASSES).map do |n| 15 | TOPLEVEL_BINDING.eval <<~RUBY 16 | class BenchmarkClass#{n} 17 | def initialize 18 | @big_string = SecureRandom.hex(12) * #{n} 19 | end 20 | end 21 | BenchmarkClass#{n} 22 | RUBY 23 | end 24 | 25 | benchmark_methods = (0..NUM_DISTINCT_METHODS).map do |n| 26 | TOPLEVEL_BINDING.eval <<~RUBY 27 | def benchmark_method_#{n}(sc, leak_pit) 28 | benchmark_machine(sc, leak_pit) 29 | end 30 | method(:benchmark_method_#{n}) 31 | RUBY 32 | end 33 | 34 | depth = 0 35 | elements_in_leak_pit = 0 36 | last_method_direction = :call 37 | BENCHMARK_SCENARIO = (0..BENCHMARK_LENGTH).map do |n| 38 | if rand < 0.5 39 | # Call something 40 | pr_call = (last_method_direction == :call ? 0.85 : 0.15) * (1 - depth / MAX_DEPTH) 41 | if (rand < pr_call && depth < MAX_DEPTH) || depth == 0 42 | depth += 1 43 | next [:call, benchmark_methods[rand(0..NUM_DISTINCT_METHODS)]] 44 | else 45 | depth -= 1 46 | next [:ret] 47 | end 48 | elsif rand < 0.55 || elements_in_leak_pit == 0 49 | # Allocate something 50 | elements_in_leak_pit += 1 51 | next [:alloc, benchmark_classes[rand(0..NUM_DISTINCT_CLASSES)]] 52 | else 53 | elements_in_leak_pit -= 1 54 | next [:free] 55 | end 56 | end 57 | 58 | def benchmark_machine(sc, leak_pit) 59 | loop do 60 | cmd = sc.slice! 0 61 | return if cmd.nil? 62 | if cmd[0] == :call 63 | cmd[1].call sc, leak_pit 64 | elsif cmd[0] == :ret 65 | return 66 | elsif cmd[0] == :alloc 67 | leak_pit.push cmd[1].new 68 | elsif cmd[0] == :free 69 | leak_pit.pop 70 | end 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/well_known_types_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.well_known_types_test import * 27 | import os 28 | import unittest 29 | 30 | if os.name == 'nt': 31 | # TODO(b/231335093): This currently trigggers an assertion failure on Windows 32 | # for unknown reasons. 33 | StructTest.__unittest_skip__ = True 34 | 35 | if __name__ == '__main__': 36 | unittest.main(verbosity=2) 37 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/bazel/protobuf.patch: -------------------------------------------------------------------------------- 1 | --- BUILD.bazel 2 | +++ BUILD.bazel 3 | @@ -896,6 +896,10 @@ py_library( 4 | [ 5 | "python/google/protobuf/**/*.py", 6 | ], 7 | + exclude = [ 8 | + "python/google/protobuf/internal/*_test.py", 9 | + "python/google/protobuf/internal/test_util.py", 10 | + ] 11 | ), 12 | imports = ["python"], 13 | srcs_version = "PY2AND3", 14 | 15 | --- python/google/protobuf/internal/test_util.py 16 | +++ python/google/protobuf/internal/test_util.py 17 | @@ -39,6 +39,7 @@ __author__ = 'robinson@google.com (Will Robinson)' 18 | import numbers 19 | import operator 20 | import os.path 21 | +import pathlib 22 | 23 | from google.protobuf import unittest_import_pb2 24 | from google.protobuf import unittest_pb2 25 | @@ -617,17 +618,22 @@ def ExpectAllFieldsSet(test_case, message): 26 | message.default_import_enum) 27 | 28 | 29 | +def _SearchUp(path, filename): 30 | + path = pathlib.Path(path).resolve() 31 | + for parent in [path] + list(path.parents): 32 | + file_path = parent / ('src/google/protobuf/testdata/' + filename) 33 | + if file_path.exists(): 34 | + # Found it. Load the golden file from the testdata directory. 35 | + return file_path.open('rb') 36 | + return None 37 | + 38 | def GoldenFile(filename): 39 | """Finds the given golden file and returns a file object representing it.""" 40 | 41 | # Search up the directory tree looking for the C++ protobuf source code. 42 | - path = '.' 43 | - while os.path.exists(path): 44 | - if os.path.exists(os.path.join(path, 'src/google/protobuf')): 45 | - # Found it. Load the golden file from the testdata directory. 46 | - full_path = os.path.join(path, 'src/google/protobuf/testdata', filename) 47 | - return open(full_path, 'rb') 48 | - path = os.path.join(path, '..') 49 | + f = _SearchUp('.', filename) or _SearchUp(__file__, filename) 50 | + if f: 51 | + return f 52 | 53 | # Search internally. 54 | path = '.' 55 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/.github/workflows/bazel_tests.yml: -------------------------------------------------------------------------------- 1 | name: Bazel Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | workflow_dispatch: 11 | 12 | jobs: 13 | 14 | ubuntu: 15 | runs-on: ${{ matrix.os }} 16 | env: 17 | BAZEL_CACHE: --remote_cache=https://storage.googleapis.com/protobuf-bazel-cache --google_default_credentials 18 | 19 | strategy: 20 | fail-fast: false # Don't cancel all jobs if one fails. 21 | matrix: 22 | include: 23 | - { CC: clang, os: ubuntu-20.04, flags: "" } 24 | - { CC: clang, os: ubuntu-20.04, flags: "-c opt" } # Some warnings only fire with -c opt 25 | - { CC: gcc, os: ubuntu-20.04, flags: "-c opt" } 26 | - { CC: clang, os: ubuntu-20.04, flags: "--//:fasttable_enabled=true -- -cmake:test_generated_files" } 27 | - { CC: clang, os: ubuntu-20.04, flags: "--config=asan -c dbg -- -benchmarks:benchmark -python/..." } 28 | - { CC: clang, os: ubuntu-20.04, flags: "--config=ubsan -c dbg -- -benchmarks:benchmark -python/... -upb/bindings/lua/...", install: "libunwind-dev" } 29 | - { CC: clang, os: ubuntu-20.04, flags: "--copt=-m32 --linkopt=-m32 -- -... benchmarks:benchmark ", install: "g++-multilib" } 30 | - { CC: clang, os: macos-11, flags: "" } 31 | 32 | steps: 33 | - uses: actions/checkout@v2 34 | - name: Set up Cloud SDK 35 | uses: google-github-actions/auth@v0 36 | with: 37 | credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} 38 | export_environment_variables: true 39 | - name: Setup Python venv 40 | run: rm -rf /tmp/venv && python3 -m venv /tmp/venv 41 | - name: Install dependencies 42 | run: sudo apt update && sudo apt install -y ${{ matrix.install }} 43 | if: matrix.install != '' 44 | - name: Run tests 45 | run: cd ${{ github.workspace }} && PATH=/tmp/venv/bin:$PATH CC=${{ matrix.CC }} bazel test --test_output=errors $BAZEL_CACHE ... ${{ matrix.flags }} 46 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | ruby_memprofiler_pprof (0.0.4.dev) 5 | backtracie (= 1.0.0) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | ast (2.4.2) 11 | backtracie (1.0.0) 12 | debase-ruby_core_source (~> 0.10, >= 0.10.12) 13 | bump (0.10.0) 14 | coderay (1.1.3) 15 | debase-ruby_core_source (0.10.16) 16 | e2mmap (0.1.0) 17 | google-protobuf (3.21.5) 18 | json (2.6.2) 19 | method_source (1.0.0) 20 | minitest (5.16.3) 21 | mustermann (2.0.2) 22 | ruby2_keywords (~> 0.0.1) 23 | parallel (1.22.1) 24 | parser (3.1.2.1) 25 | ast (~> 2.4.1) 26 | pry (0.14.1) 27 | coderay (~> 1.1) 28 | method_source (~> 1.0) 29 | rack (2.2.4) 30 | rack-protection (2.2.2) 31 | rack 32 | rainbow (3.1.1) 33 | rake (13.0.6) 34 | rake-compiler (1.2.0) 35 | rake 36 | regexp_parser (2.5.0) 37 | rexml (3.2.5) 38 | rubocop (1.35.0) 39 | json (~> 2.3) 40 | parallel (~> 1.10) 41 | parser (>= 3.1.2.1) 42 | rainbow (>= 2.2.2, < 4.0) 43 | regexp_parser (>= 1.8, < 3.0) 44 | rexml (>= 3.2.5, < 4.0) 45 | rubocop-ast (>= 1.20.1, < 2.0) 46 | ruby-progressbar (~> 1.7) 47 | unicode-display_width (>= 1.4.0, < 3.0) 48 | rubocop-ast (1.21.0) 49 | parser (>= 3.1.1.0) 50 | rubocop-performance (1.14.3) 51 | rubocop (>= 1.7.0, < 2.0) 52 | rubocop-ast (>= 0.4.0) 53 | ruby-progressbar (1.11.0) 54 | ruby2_keywords (0.0.5) 55 | sinatra (2.2.2) 56 | mustermann (~> 2.0) 57 | rack (~> 2.2) 58 | rack-protection (= 2.2.2) 59 | tilt (~> 2.0) 60 | standard (1.16.0) 61 | rubocop (= 1.35.0) 62 | rubocop-performance (= 1.14.3) 63 | thwait (0.2.0) 64 | e2mmap 65 | tilt (2.0.11) 66 | timecop (0.9.5) 67 | unicode-display_width (2.2.0) 68 | 69 | PLATFORMS 70 | ruby 71 | 72 | DEPENDENCIES 73 | bump (~> 0.10) 74 | google-protobuf (~> 3) 75 | minitest (~> 5) 76 | pry (~> 0.14) 77 | rake (~> 13) 78 | rake-compiler (~> 1) 79 | ruby_memprofiler_pprof! 80 | sinatra (~> 2) 81 | standard (~> 1.14) 82 | thwait (~> 0.2) 83 | timecop (~> 0.9) 84 | 85 | BUNDLED WITH 86 | 2.1.4 87 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/json_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef UPB_JSONDECODE_H_ 29 | #define UPB_JSONDECODE_H_ 30 | 31 | #include "upb/def.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | enum { upb_JsonDecode_IgnoreUnknown = 1 }; 38 | 39 | bool upb_JsonDecode(const char* buf, size_t size, upb_Message* msg, 40 | const upb_MessageDef* m, const upb_DefPool* symtab, 41 | int options, upb_Arena* arena, upb_Status* status); 42 | 43 | #ifdef __cplusplus 44 | } /* extern "C" */ 45 | #endif 46 | 47 | #endif /* UPB_JSONDECODE_H_ */ 48 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/docs/style-guide.md: -------------------------------------------------------------------------------- 1 | # C style guide 2 | 3 | 7 | 8 | Since upb is written in pure C, we supplement the 9 | [Google C++ style guide](https://google.github.io/styleguide/cppguide.html) with 10 | some C-specific guidance. 11 | 12 | Everything written here is intended to follow the spirit of the C++ style guide. 13 | 14 | upb is currently inconsistent about following these conventions. It is intended 15 | that all code will be updated to match these guidelines. The priority is 16 | converting public interfaces as these are more difficult to change later. 17 | 18 | ## Naming 19 | 20 | ### Functions and Types 21 | 22 | C does not have namespaces. Anywhere you would normally use a namespace 23 | separator (`::`) in C++, we use an underscore (`_`) in C: 24 | 25 | ```c++ 26 | // C equivalent for upb::Arena::New() 27 | upb_Arena* upb_Arena_New(); 28 | ``` 29 | 30 | Since we rely on `_` to be our namespace separator, we never use it to merely 31 | separate words in function or type names: 32 | 33 | ```c++ 34 | // BAD: this would be interpreted as upb::FieldDef::has::default(). 35 | bool upb_FieldDef_has_default(const upb_FieldDef* f); 36 | 37 | // GOOD: this is equivalent to upb::FieldDef::HasDefault(). 38 | bool upb_FieldDef_HasDefault(const upb_FieldDef* f); 39 | ``` 40 | 41 | For multi-word namespaces, we use `PascalCase`: 42 | 43 | ```c++ 44 | // `PyUpb` is the namespace. 45 | PyObject* PyUpb_CMessage_GetAttr(PyObject* _self, PyObject* attr); 46 | ``` 47 | 48 | ### Private Functions and Members 49 | 50 | Since we do not have `private` in C++, we use a leading underscore convention 51 | to mark internal functions and variables that should only be accessed from 52 | upb: 53 | 54 | ```c++ 55 | // Internal-only function. 56 | int64_t _upb_Int64_FromLL(); 57 | 58 | // Internal-only members. Underscore prefixes are only necessary when the 59 | // structure is defined in a header file. 60 | typedef struct { 61 | const int32_t* _values; // List of values <0 or >63 62 | uint64_t _mask; // Bits are set for acceptable value 0 <= x < 64 63 | int _value_count; 64 | } upb_MiniTable_Enum; 65 | ``` 66 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/fuzz/file_descriptor_parsenew_fuzzer.cc: -------------------------------------------------------------------------------- 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 27 | 28 | #include "google/protobuf/descriptor.upb.h" 29 | #include "upb/def.hpp" 30 | #include "upb/upb.hpp" 31 | 32 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 33 | upb::Arena arena; 34 | google_protobuf_FileDescriptorProto* proto = 35 | google_protobuf_FileDescriptorProto_parse( 36 | reinterpret_cast(data), size, arena.ptr()); 37 | if (proto) { 38 | upb::SymbolTable symtab; 39 | upb::Status status; 40 | symtab.AddFile(proto, &status); 41 | } 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "upb") 2 | 3 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4 | load("//bazel:workspace_deps.bzl", "upb_deps") 5 | 6 | upb_deps() 7 | register_toolchains("@system_python//:python_toolchain") 8 | 9 | load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") 10 | protobuf_deps() 11 | 12 | http_archive( 13 | name = "lua", 14 | build_file = "//bazel:lua.BUILD", 15 | sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b", 16 | strip_prefix = "lua-5.2.4", 17 | urls = [ 18 | "https://mirror.bazel.build/www.lua.org/ftp/lua-5.2.4.tar.gz", 19 | "https://www.lua.org/ftp/lua-5.2.4.tar.gz", 20 | ], 21 | ) 22 | 23 | http_archive( 24 | name = "com_google_googletest", 25 | urls = ["https://github.com/google/googletest/archive/b6cd405286ed8635ece71c72f118e659f4ade3fb.zip"], # 2019-01-07 26 | strip_prefix = "googletest-b6cd405286ed8635ece71c72f118e659f4ade3fb", 27 | sha256 = "ff7a82736e158c077e76188232eac77913a15dac0b22508c390ab3f88e6d6d86", 28 | ) 29 | 30 | http_archive( 31 | name = "com_github_google_benchmark", 32 | urls = ["https://github.com/google/benchmark/archive/0baacde3618ca617da95375e0af13ce1baadea47.zip"], 33 | strip_prefix = "benchmark-0baacde3618ca617da95375e0af13ce1baadea47", 34 | sha256 = "62e2f2e6d8a744d67e4bbc212fcfd06647080de4253c97ad5c6749e09faf2cb0", 35 | ) 36 | 37 | http_archive( 38 | name = "com_google_googleapis", 39 | urls = ["https://github.com/googleapis/googleapis/archive/refs/heads/master.zip"], 40 | build_file = "//benchmarks:BUILD.googleapis", 41 | strip_prefix = "googleapis-master", 42 | patch_cmds = ["find google -type f -name BUILD.bazel -delete"], 43 | ) 44 | 45 | http_archive( 46 | name = "rules_fuzzing", 47 | sha256 = "23bb074064c6f488d12044934ab1b0631e8e6898d5cf2f6bde087adb01111573", 48 | strip_prefix = "rules_fuzzing-0.3.1", 49 | urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.3.1.zip"], 50 | ) 51 | 52 | load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies") 53 | 54 | rules_fuzzing_dependencies() 55 | 56 | load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init") 57 | 58 | rules_fuzzing_init() 59 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/message_factory_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.message_factory_test import * 27 | import unittest 28 | 29 | MessageFactoryTest.testCreatePrototypeOverride.__unittest_expecting_failure__ = True 30 | MessageFactoryTest.testDuplicateExtensionNumber.__unittest_expecting_failure__ = True 31 | MessageFactoryTest.testGetMessages.__unittest_expecting_failure__ = True 32 | MessageFactoryTest.testGetPrototype.__unittest_expecting_failure__ = True 33 | if hasattr(MessageFactoryTest, 'testExtensionValueInDifferentFile'): 34 | MessageFactoryTest.testExtensionValueInDifferentFile.__unittest_expecting_failure__ = True 35 | 36 | if __name__ == '__main__': 37 | unittest.main(verbosity=2) 38 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/test.proto: -------------------------------------------------------------------------------- 1 | 2 | syntax = "proto2"; 3 | 4 | package upb_test; 5 | 6 | message MapTest { 7 | map map_string_double = 1; 8 | } 9 | 10 | message MessageName { 11 | optional int32 field1 = 1; 12 | optional int32 field2 = 2; 13 | } 14 | 15 | message HelloRequest { 16 | optional uint32 id = 1; 17 | optional uint32 random_name_a0 = 2; 18 | optional uint32 random_name_a1 = 3; 19 | optional uint32 random_name_a2 = 4; 20 | optional uint32 random_name_a3 = 5; 21 | optional uint32 random_name_a4 = 6; 22 | optional uint32 random_name_a5 = 7; 23 | optional uint32 random_name_a6 = 8; 24 | optional uint32 random_name_a7 = 9; 25 | optional uint32 random_name_a8 = 10; 26 | optional uint32 random_name_a9 = 11; 27 | optional uint32 random_name_b0 = 12; 28 | optional uint32 random_name_b1 = 13; 29 | optional uint32 random_name_b2 = 14; 30 | optional uint32 random_name_b3 = 15; 31 | optional uint32 random_name_b4 = 16; 32 | optional uint32 random_name_b5 = 17; 33 | optional uint32 random_name_b6 = 18; 34 | optional uint32 random_name_b7 = 19; 35 | optional uint32 random_name_b8 = 20; 36 | optional uint32 random_name_b9 = 21; 37 | optional uint32 random_name_c0 = 22; 38 | optional uint32 random_name_c1 = 23; 39 | optional uint32 random_name_c2 = 24; 40 | optional uint32 random_name_c3 = 25; 41 | optional uint32 random_name_c4 = 26; 42 | optional uint32 random_name_c5 = 27; 43 | optional uint32 random_name_c6 = 28; 44 | optional uint32 random_name_c7 = 29; 45 | optional uint32 random_name_c8 = 30; 46 | optional uint32 random_name_c9 = 31; 47 | optional string version = 32; 48 | } 49 | 50 | message EmptyMessageWithExtensions { 51 | // Reserved for unknown fields/extensions test. 52 | reserved 1000 to max; 53 | } 54 | 55 | message ModelWithExtensions { 56 | optional int32 random_int32 = 3; 57 | optional string random_name = 4; 58 | // Reserved for unknown fields/extensions test. 59 | extensions 1000 to max; 60 | } 61 | 62 | message ModelExtension1 { 63 | extend ModelWithExtensions { 64 | optional ModelExtension1 model_ext = 1547; 65 | } 66 | optional string str = 25; 67 | } 68 | 69 | message ModelExtension2 { 70 | extend ModelWithExtensions { 71 | optional ModelExtension2 model_ext = 4135; 72 | } 73 | optional int32 i = 9; 74 | } 75 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/py_extension.bzl: -------------------------------------------------------------------------------- 1 | """Macro to support py_extension """ 2 | 3 | load("@bazel_skylib//lib:selects.bzl", "selects") 4 | 5 | def py_extension(name, srcs, copts, deps = []): 6 | """Creates a C++ library to extend python 7 | 8 | Args: 9 | name: Name of the target 10 | srcs: List of source files to create the target 11 | copts: List of C++ compile options to use 12 | deps: Libraries that the target depends on 13 | """ 14 | 15 | native.cc_binary( 16 | name = name + "_binary", 17 | srcs = srcs, 18 | copts = copts + ["-fvisibility=hidden"], 19 | linkopts = selects.with_or({ 20 | ("//python/dist:osx-x86_64_cpu", "//python/dist:osx-aarch64_cpu"): ["-undefined", "dynamic_lookup"], 21 | "//conditions:default": [], 22 | }), 23 | linkshared = True, 24 | linkstatic = True, 25 | deps = deps + select({ 26 | "//python:limited_api_3.7": ["@python-3.7.0//:python_headers"], 27 | "//python:full_api_3.7_win32": ["@nuget_python_i686_3.7.0//:python_full_api"], 28 | "//python:full_api_3.7_win64": ["@nuget_python_x86-64_3.7.0//:python_full_api"], 29 | "//python:full_api_3.8_win32": ["@nuget_python_i686_3.8.0//:python_full_api"], 30 | "//python:full_api_3.8_win64": ["@nuget_python_x86-64_3.8.0//:python_full_api"], 31 | "//python:full_api_3.9_win32": ["@nuget_python_i686_3.9.0//:python_full_api"], 32 | "//python:full_api_3.9_win64": ["@nuget_python_x86-64_3.9.0//:python_full_api"], 33 | "//python:limited_api_3.10_win32": ["@nuget_python_i686_3.10.0//:python_limited_api"], 34 | "//python:limited_api_3.10_win64": ["@nuget_python_x86-64_3.10.0//:python_limited_api"], 35 | "//conditions:default": ["@system_python//:python_headers"], 36 | }), 37 | ) 38 | 39 | EXT_SUFFIX = ".abi3.so" 40 | output_file = "google/_upb/" + name + EXT_SUFFIX 41 | 42 | native.genrule( 43 | name = "copy" + name, 44 | srcs = [":" + name + "_binary"], 45 | outs = [output_file], 46 | cmd = "cp $< $@", 47 | visibility = ["//python:__subpackages__"], 48 | ) 49 | 50 | native.py_library( 51 | name = name, 52 | data = [output_file], 53 | imports = ["."], 54 | visibility = ["//python:__subpackages__"], 55 | ) 56 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/bindings/lua/test.proto: -------------------------------------------------------------------------------- 1 | 2 | syntax = "proto2"; 3 | 4 | import "google/protobuf/timestamp.proto"; 5 | 6 | package upb_lua_test; 7 | 8 | message MapTest { 9 | map map_string_double = 1; 10 | } 11 | 12 | message PackedTest { 13 | repeated bool bool_packed = 1 [packed = true]; 14 | repeated int32 i32_packed = 2 [packed = true]; 15 | repeated int64 i64_packed = 3 [packed = true]; 16 | repeated fixed32 f32_packed = 4 [packed = true]; 17 | repeated fixed64 f64_packed = 5 [packed = true]; 18 | } 19 | 20 | message UnpackedTest { 21 | repeated bool bool_packed = 1 [packed = false]; 22 | repeated int32 i32_packed = 2 [packed = false]; 23 | repeated int64 i64_packed = 3 [packed = false]; 24 | repeated fixed32 f32_packed = 4 [packed = false]; 25 | repeated fixed64 f64_packed = 5 [packed = false]; 26 | } 27 | 28 | message TestLargeFieldNumber { 29 | optional int32 i32 = 456214797; 30 | } 31 | 32 | message TestTimestamp { 33 | optional google.protobuf.Timestamp ts = 1; 34 | } 35 | 36 | message HelloRequest { 37 | optional uint32 id = 1; 38 | optional uint32 random_name_a0 = 2; 39 | optional uint32 random_name_a1 = 3; 40 | optional uint32 random_name_a2 = 4; 41 | optional uint32 random_name_a3 = 5; 42 | optional uint32 random_name_a4 = 6; 43 | optional uint32 random_name_a5 = 7; 44 | optional uint32 random_name_a6 = 8; 45 | optional uint32 random_name_a7 = 9; 46 | optional uint32 random_name_a8 = 10; 47 | optional uint32 random_name_a9 = 11; 48 | optional uint32 random_name_b0 = 12; 49 | optional uint32 random_name_b1 = 13; 50 | optional uint32 random_name_b2 = 14; 51 | optional uint32 random_name_b3 = 15; 52 | optional uint32 random_name_b4 = 16; 53 | optional uint32 random_name_b5 = 17; 54 | optional uint32 random_name_b6 = 18; 55 | optional uint32 random_name_b7 = 19; 56 | optional uint32 random_name_b8 = 20; 57 | optional uint32 random_name_b9 = 21; 58 | optional uint32 random_name_c0 = 22; 59 | optional uint32 random_name_c1 = 23; 60 | optional uint32 random_name_c2 = 24; 61 | optional uint32 random_name_c3 = 25; 62 | optional uint32 random_name_c4 = 26; 63 | optional uint32 random_name_c5 = 27; 64 | optional uint32 random_name_c6 = 28; 65 | optional uint32 random_name_c7 = 29; 66 | optional uint32 random_name_c8 = 30; 67 | optional uint32 random_name_c9 = 31; 68 | optional string version = 32; 69 | } 70 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/benchmarks/gen_protobuf_binary_cc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # Copyright (c) 2009-2021, Google LLC 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google LLC nor the 14 | # names of its contributors may be used to endorse or promote products 15 | # derived from this software without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY 21 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | import sys 29 | import re 30 | 31 | include = sys.argv[1] 32 | msg_basename = sys.argv[2] 33 | count = 1 34 | 35 | m = re.search(r'(.*\D)(\d+)$', sys.argv[2]) 36 | if m: 37 | msg_basename = m.group(1) 38 | count = int(m.group(2)) 39 | 40 | print(''' 41 | #include "{include}" 42 | 43 | char buf[1]; 44 | 45 | int main() {{ 46 | '''.format(include=include)) 47 | 48 | def RefMessage(name): 49 | print(''' 50 | {{ 51 | {name} proto; 52 | proto.ParseFromArray(buf, 0); 53 | proto.SerializePartialToArray(&buf[0], 0); 54 | }} 55 | '''.format(name=name)) 56 | 57 | RefMessage(msg_basename) 58 | 59 | for i in range(2, count + 1): 60 | RefMessage(msg_basename + str(i)) 61 | 62 | print(''' 63 | return 0; 64 | }''') 65 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/util/required_fields_test.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | syntax = "proto2"; 29 | 30 | package upb_util_test; 31 | 32 | message EmptyMessage {} 33 | 34 | message HasRequiredField { 35 | required int32 required_int32 = 1; 36 | } 37 | 38 | message TestRequiredFields { 39 | required EmptyMessage required_message = 1; 40 | optional TestRequiredFields optional_message = 2; 41 | repeated HasRequiredField repeated_message = 3; 42 | map map_int32_message = 4; 43 | map map_int64_message = 5; 44 | map map_uint32_message = 6; 45 | map map_uint64_message = 7; 46 | map map_bool_message = 8; 47 | map map_string_message = 9; 48 | } 49 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/descriptor_pool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PYUPB_DESCRIPTOR_POOL_H__ 29 | #define PYUPB_DESCRIPTOR_POOL_H__ 30 | 31 | #include 32 | 33 | #include "protobuf.h" 34 | 35 | // Returns a Python wrapper object for the given symtab. The symtab must have 36 | // been created from a Python DescriptorPool originally. 37 | PyObject* PyUpb_DescriptorPool_Get(const upb_DefPool* symtab); 38 | 39 | // Given a Python DescriptorPool, returns the underlying symtab. 40 | upb_DefPool* PyUpb_DescriptorPool_GetSymtab(PyObject* pool); 41 | 42 | // Returns the default DescriptorPool (a global singleton). 43 | PyObject* PyUpb_DescriptorPool_GetDefaultPool(void); 44 | 45 | // Module-level init. 46 | bool PyUpb_InitDescriptorPool(PyObject* m); 47 | 48 | #endif // PYUPB_DESCRIPTOR_POOL_H__ 49 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/benchmarks/gen_upb_binary_c.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # 3 | # Copyright (c) 2009-2021, Google LLC 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google LLC nor the 14 | # names of its contributors may be used to endorse or promote products 15 | # derived from this software without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY 21 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | import sys 29 | import re 30 | 31 | include = sys.argv[1] 32 | msg_basename = sys.argv[2] 33 | count = 1 34 | 35 | m = re.search(r'(.*\D)(\d+)$', sys.argv[2]) 36 | if m: 37 | msg_basename = m.group(1) 38 | count = int(m.group(2)) 39 | 40 | print(''' 41 | #include "{include}" 42 | 43 | char buf[1]; 44 | 45 | int main() {{ 46 | upb_Arena *arena = upb_Arena_New(); 47 | size_t size; 48 | '''.format(include=include)) 49 | 50 | def RefMessage(name): 51 | print(''' 52 | {{ 53 | {name} *proto = {name}_parse(buf, 1, arena); 54 | {name}_serialize(proto, arena, &size); 55 | }} 56 | '''.format(name=name)) 57 | 58 | RefMessage(msg_basename) 59 | 60 | for i in range(2, count + 1): 61 | RefMessage(msg_basename + str(i)) 62 | 63 | print(''' 64 | return 0; 65 | }''') 66 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/descriptor_pool_test_wrapper.py: -------------------------------------------------------------------------------- 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 | import unittest 27 | from google.protobuf.internal.descriptor_pool_test import * 28 | 29 | # This is testing that certain methods unconditionally throw TypeError. 30 | # In the new extension we simply don't define them at all. 31 | AddDescriptorTest.testAddTypeError.__unittest_expecting_failure__ = True 32 | 33 | SecondaryDescriptorFromDescriptorDB.testErrorCollector.__unittest_expecting_failure__ = True 34 | 35 | # begin:github_only 36 | if __name__ == '__main__': 37 | unittest.main(verbosity=2) 38 | # end:github_only 39 | 40 | # begin:google_only 41 | # CreateDescriptorPoolTest.testComplexNestingWithProtoFileParser.__unittest_expecting_failure__ = True 42 | # from absl import app 43 | # if __name__ == '__main__': 44 | # app.run(lambda argv: unittest.main(verbosity=2)) 45 | # end:google_only 46 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/bazel/BUILD: -------------------------------------------------------------------------------- 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("@bazel_skylib//:bzl_library.bzl", "bzl_library") 27 | 28 | licenses(["notice"]) 29 | 30 | py_binary( 31 | name = "amalgamate", 32 | srcs = ["amalgamate.py"], 33 | visibility = ["//:__pkg__"], 34 | ) 35 | 36 | # py_proto_library() is private rule, only intended for internal use by upb. 37 | # Hopefully py_proto_library() will eventually be availble in rules_proto or 38 | # another upstream package. 39 | bzl_library( 40 | name = "py_proto_library_bzl", 41 | srcs = ["py_proto_library.bzl"], 42 | ) 43 | 44 | bzl_library( 45 | name = "upb_proto_library_bzl", 46 | srcs = ["upb_proto_library.bzl"], 47 | visibility = ["//visibility:public"], 48 | deps = [ 49 | "@bazel_skylib//lib:paths", 50 | "@bazel_tools//tools/cpp:toolchain_utils.bzl", 51 | "@rules_proto//proto:defs", 52 | ], 53 | ) 54 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/cmake/staleness_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright (c) 2009-2021, Google LLC 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # * Neither the name of Google LLC nor the 14 | # names of its contributors may be used to endorse or promote products 15 | # derived from this software without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY 21 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | """The py_test() script for generated_file_staleness_test() rules. 29 | 30 | Note that this file is preprocessed! The INSERT_<...> text below is replaced 31 | with the actual list of files before we actually run the script. 32 | """ 33 | 34 | from __future__ import absolute_import 35 | 36 | from cmake import staleness_test_lib 37 | import unittest 38 | import sys 39 | 40 | file_list = """ 41 | INSERT_FILE_LIST_HERE 42 | """.split() 43 | 44 | config = staleness_test_lib.Config(file_list) 45 | 46 | 47 | class TestFilesMatch(unittest.TestCase): 48 | 49 | def testFilesMatch(self): 50 | errors = staleness_test_lib.CheckFilesMatch(config) 51 | self.assertFalse(errors, errors) 52 | 53 | 54 | if len(sys.argv) > 1 and sys.argv[1] == "--fix": 55 | staleness_test_lib.FixFiles(config) 56 | else: 57 | unittest.main() 58 | -------------------------------------------------------------------------------- /lib/ruby_memprofiler_pprof/atfork.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # A mechanism for adding atfork handlers, so that background profile flushing threads 4 | # can re-create themselves in forked children. 5 | # Mostly ripped off from the Datadog one here: 6 | # https://github.com/DataDog/dd-trace-rb/blob/master/lib/datadog/profiling/ext/forking.rb 7 | 8 | module MemprofilerPprof 9 | module Atfork 10 | class Handler 11 | attr_accessor :block 12 | attr_accessor :stage 13 | 14 | def call 15 | block.call 16 | end 17 | 18 | def remove! 19 | Atfork.at_fork_handlers.reject! { |h| h === self } 20 | end 21 | end 22 | 23 | module_function 24 | 25 | def at_fork_handlers 26 | @@at_fork_handlers ||= [] 27 | end 28 | 29 | def at_fork(stage = :prepare, &block) 30 | handler = Handler.new.tap do |h| 31 | h.block = block 32 | h.stage = stage 33 | end 34 | at_fork_handlers << handler 35 | handler 36 | end 37 | 38 | def fork 39 | # If a block is provided, it must be wrapped to trigger callbacks. 40 | child_block = if block_given? 41 | proc do 42 | # Trigger :child callback 43 | at_fork_handlers.select { |h| h.stage == :child }.each(&:call) 44 | 45 | # Invoke original block 46 | yield 47 | end 48 | end 49 | 50 | # Trigger :prepare callback 51 | at_fork_handlers.select { |h| h.stage == :prepare }.each(&:call) 52 | 53 | # Start fork 54 | # If a block is provided, use the wrapped version. 55 | result = child_block.nil? ? super : super(&child_block) 56 | 57 | # Trigger correct callbacks depending on whether we're in the parent or child. 58 | # If we're in the fork, result = nil: trigger child callbacks. 59 | # If we're in the parent, result = fork PID: trigger parent callbacks. 60 | if result.nil? 61 | # Trigger :child callback 62 | at_fork_handlers.select { |h| h.stage == :child }.each(&:call) 63 | else 64 | # Trigger :parent callback 65 | at_fork_handlers.select { |h| h.stage == :parent }.each(&:call) 66 | end 67 | # rubocop:enable Style/IfInsideElse 68 | 69 | # Return PID from #fork 70 | result 71 | end 72 | end 73 | end 74 | 75 | ::Process.singleton_class.prepend(MemprofilerPprof::Atfork) 76 | ::Kernel.singleton_class.prepend(MemprofilerPprof::Atfork) 77 | TOPLEVEL_BINDING.receiver.class.prepend(MemprofilerPprof::Atfork) 78 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/README.md: -------------------------------------------------------------------------------- 1 | 2 | # μpb: small, fast C protos 3 | 4 | μpb (often written 'upb') is a small 5 | [protobuf](https://github.com/protocolbuffers/protobuf) implementation written 6 | in C. 7 | 8 | upb is the core runtime for protobuf languages extensions in 9 | [Ruby](https://github.com/protocolbuffers/protobuf/tree/master/ruby), 10 | [PHP](https://github.com/protocolbuffers/protobuf/tree/master/php), and (soon) 11 | Python. 12 | 13 | While upb offers a C API, the C API & ABI **are not stable**. For this reason, 14 | upb is not generally offered as a C library for direct consumption, and there 15 | are no releases. 16 | 17 | ## Features 18 | 19 | upb has comparable speed to protobuf C++, but is an order of magnitude smaller 20 | in code size. 21 | 22 | Like the main protobuf implementation in C++, it supports: 23 | 24 | - a generated API (in C) 25 | - reflection 26 | - binary & JSON wire formats 27 | - text format serialization 28 | - all standard features of protobufs (oneofs, maps, unknown fields, extensions, 29 | etc.) 30 | - full conformance with the protobuf conformance tests 31 | 32 | upb also supports some features that C++ does not: 33 | 34 | - **optional reflection:** generated messages are agnostic to whether 35 | reflection will be linked in or not. 36 | - **no global state:** no pre-main registration or other global state. 37 | - **fast reflection-based parsing:** messages loaded at runtime parse 38 | just as fast as compiled-in messages. 39 | 40 | However there are a few features it does not support: 41 | 42 | - text format parsing 43 | - deep descriptor verification: upb's descriptor validation is not as exhaustive 44 | as `protoc`. 45 | 46 | ## Install 47 | 48 | For Ruby, use [RubyGems](https://rubygems.org/gems/google-protobuf): 49 | 50 | ``` 51 | $ gem install google-protobuf 52 | ``` 53 | 54 | For PHP, use [PECL](https://pecl.php.net/package/protobuf): 55 | 56 | ``` 57 | $ sudo pecl install protobuf 58 | ``` 59 | 60 | Alternatively, you can build and install upb using 61 | [vcpkg](https://github.com/microsoft/vcpkg/) dependency manager: 62 | 63 | git clone https://github.com/Microsoft/vcpkg.git 64 | cd vcpkg 65 | ./bootstrap-vcpkg.sh 66 | ./vcpkg integrate install 67 | ./vcpkg install upb 68 | 69 | The upb port in vcpkg is kept up to date by microsoft team members and community 70 | contributors. 71 | 72 | If the version is out of date, please 73 | [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the 74 | vcpkg repository. 75 | 76 | ## Contributing 77 | 78 | Please see [CONTRIBUTING.md](CONTRIBUTING.md). 79 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/mini_table_accessors_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2022, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef UPB_MINI_TABLE_ACCESSORS_INTERNAL_H_ 29 | #define UPB_MINI_TABLE_ACCESSORS_INTERNAL_H_ 30 | 31 | #include "upb/msg_internal.h" 32 | 33 | // Must be last. 34 | #include "upb/port_def.inc" 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | UPB_INLINE bool _upb_MiniTable_Field_InOneOf(const upb_MiniTable_Field* field) { 41 | return field->presence < 0; 42 | } 43 | 44 | UPB_INLINE void _upb_MiniTable_SetPresence(upb_Message* msg, 45 | const upb_MiniTable_Field* field) { 46 | if (field->presence > 0) { 47 | _upb_sethas_field(msg, field); 48 | } else if (_upb_MiniTable_Field_InOneOf(field)) { 49 | *_upb_oneofcase_field(msg, field) = field->number; 50 | } 51 | } 52 | 53 | #ifdef __cplusplus 54 | } /* extern "C" */ 55 | #endif 56 | 57 | #include "upb/port_undef.inc" 58 | 59 | #endif // UPB_MINI_TABLE_ACCESSORS_INTERNAL_H_ 60 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/bindings/lua/upb.lua: -------------------------------------------------------------------------------- 1 | --[[-------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2009-2021, Google LLC 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of Google LLC nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | --]]-------------------------------------------------------------------------- 29 | 30 | local upb = require("lupb") 31 | 32 | upb.generated_pool = upb.SymbolTable() 33 | 34 | local module_metatable = { 35 | __index = function(t, k) 36 | local package = t._filedef:package() 37 | if package then 38 | k = package .. "." .. k 39 | end 40 | local pool = upb.generated_pool 41 | local def = pool:lookup_msg(k) or pool:lookup_enum(k) 42 | local v = nil 43 | if def and def:file():name() == t._filedef:name() then 44 | v = def 45 | t[k] = v 46 | end 47 | return v 48 | end 49 | } 50 | 51 | function upb._generated_module(desc_string) 52 | local file = upb.generated_pool:add_file(desc_string) 53 | local module = {_filedef = file} 54 | setmetatable(module, module_metatable) 55 | return module 56 | end 57 | 58 | return upb 59 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/port_undef.inc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /* See port_def.inc. This should #undef all macros #defined there. */ 29 | 30 | #undef UPB_SIZE 31 | #undef UPB_PTR_AT 32 | #undef UPB_READ_ONEOF 33 | #undef UPB_WRITE_ONEOF 34 | #undef UPB_MAPTYPE_STRING 35 | #undef UPB_INLINE 36 | #undef UPB_ALIGN_UP 37 | #undef UPB_ALIGN_DOWN 38 | #undef UPB_ALIGN_MALLOC 39 | #undef UPB_ALIGN_OF 40 | #undef UPB_LIKELY 41 | #undef UPB_UNLIKELY 42 | #undef UPB_FORCEINLINE 43 | #undef UPB_NOINLINE 44 | #undef UPB_NORETURN 45 | #undef UPB_PRINTF 46 | #undef UPB_MAX 47 | #undef UPB_MIN 48 | #undef UPB_UNUSED 49 | #undef UPB_ASSUME 50 | #undef UPB_ASSERT 51 | #undef UPB_UNREACHABLE 52 | #undef UPB_SETJMP 53 | #undef UPB_LONGJMP 54 | #undef UPB_PTRADD 55 | #undef UPB_MUSTTAIL 56 | #undef UPB_FASTTABLE_SUPPORTED 57 | #undef UPB_FASTTABLE 58 | #undef UPB_FASTTABLE_INIT 59 | #undef UPB_POISON_MEMORY_REGION 60 | #undef UPB_UNPOISON_MEMORY_REGION 61 | #undef UPB_ASAN 62 | #undef UPB_TREAT_PROTO2_ENUMS_LIKE_PROTO3 63 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/reflection_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.reflection_test import * 27 | import unittest 28 | 29 | # These tests depend on a specific iteration order for extensions, which is not 30 | # reasonable to guarantee. 31 | Proto2ReflectionTest.testExtensionIter.__unittest_expecting_failure__ = True 32 | 33 | # These tests depend on a specific serialization order for extensions, which is 34 | # not reasonable to guarantee. 35 | SerializationTest.testCanonicalSerializationOrder.__unittest_expecting_failure__ = True 36 | SerializationTest.testCanonicalSerializationOrderSameAsCpp.__unittest_expecting_failure__ = True 37 | 38 | # This test relies on the internal implementation using Python descriptors. 39 | # This is an implementation detail that users should not depend on. 40 | SerializationTest.testFieldDataDescriptor.__unittest_expecting_failure__ = True 41 | 42 | SerializationTest.testFieldProperties.__unittest_expecting_failure__ = True 43 | 44 | if __name__ == '__main__': 45 | unittest.main(verbosity=2) 46 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/descriptor_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.descriptor_test import * 27 | import unittest 28 | 29 | # Our behavior here matches pure-Python, which does not allow 30 | # foo.enum_values_by_name.get([]). We reject it because we return a true 31 | # dict (like pure Python), which does not allow hashing by a list. 32 | GeneratedDescriptorTest.testDescriptor.__unittest_expecting_failure__ = True 33 | 34 | # These fail because they attempt to add fields with conflicting JSON names. 35 | # We don't want to support this going forward. 36 | MakeDescriptorTest.testCamelcaseName.__unittest_expecting_failure__ = True 37 | MakeDescriptorTest.testJsonName.__unittest_expecting_failure__ = True 38 | 39 | # We pass this test, but the error message is slightly different. 40 | # Our error message is better. 41 | NewDescriptorTest.testImmutableCppDescriptor.__unittest_expecting_failure__ = True 42 | 43 | DescriptorTest.testGetDebugString.__unittest_expecting_failure__ = True 44 | 45 | if __name__ == '__main__': 46 | unittest.main(verbosity=2) 47 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/benchmarks/BUILD.googleapis: -------------------------------------------------------------------------------- 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 | ) 55 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /* 29 | * upb_Encode: parsing into a upb_Message using a upb_MiniTable. 30 | */ 31 | 32 | #ifndef UPB_ENCODE_H_ 33 | #define UPB_ENCODE_H_ 34 | 35 | #include "upb/msg.h" 36 | 37 | /* Must be last. */ 38 | #include "upb/port_def.inc" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | enum { 45 | /* If set, the results of serializing will be deterministic across all 46 | * instances of this binary. There are no guarantees across different 47 | * binary builds. 48 | * 49 | * If your proto contains maps, the encoder will need to malloc()/free() 50 | * memory during encode. */ 51 | kUpb_Encode_Deterministic = 1, 52 | 53 | /* When set, unknown fields are not printed. */ 54 | kUpb_Encode_SkipUnknown = 2, 55 | 56 | /* When set, the encode will fail if any required fields are missing. */ 57 | kUpb_Encode_CheckRequired = 4, 58 | }; 59 | 60 | #define UPB_ENCODE_MAXDEPTH(depth) ((depth) << 16) 61 | 62 | char* upb_Encode(const void* msg, const upb_MiniTable* l, int options, 63 | upb_Arena* arena, size_t* size); 64 | 65 | #include "upb/port_undef.inc" 66 | 67 | #ifdef __cplusplus 68 | } /* extern "C" */ 69 | #endif 70 | 71 | #endif /* UPB_ENCODE_H_ */ 72 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/bazel/python_downloads.bzl: -------------------------------------------------------------------------------- 1 | """Helper methods to download different python versions""" 2 | 3 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4 | 5 | limited_api_build_file = """ 6 | cc_library( 7 | name = "python_headers", 8 | hdrs = glob(["**/Include/**/*.h"]), 9 | strip_include_prefix = "Python-{}/Include", 10 | visibility = ["//visibility:public"], 11 | ) 12 | """ 13 | 14 | def python_source_archive(name, sha256): 15 | """Helper method to create a python_headers target that will work for linux and macos. 16 | 17 | Args: 18 | name: The name of the target, should be in the form python_{VERSION} 19 | sha256: The sha256 of the python package for the specified version 20 | """ 21 | version = name.split("-")[1] 22 | http_archive( 23 | name = name, 24 | urls = [ 25 | "https://www.python.org/ftp/python/{0}/Python-{0}.tgz" 26 | .format(version), 27 | ], 28 | sha256 = sha256, 29 | build_file_content = limited_api_build_file.format(version), 30 | patch_cmds = [ 31 | "echo '#define SIZEOF_WCHAR_T 4' > Python-{}/Include/pyconfig.h" 32 | .format(version), 33 | ], 34 | ) 35 | 36 | nuget_build_file = """ 37 | cc_import( 38 | name = "python_full_api", 39 | hdrs = glob(["**/*.h"]), 40 | shared_library = "python{0}.dll", 41 | interface_library = "libs/python{0}.lib", 42 | visibility = ["@upb//python:__pkg__"], 43 | ) 44 | 45 | cc_import( 46 | name = "python_limited_api", 47 | hdrs = glob(["**/*.h"]), 48 | shared_library = "python{1}.dll", 49 | interface_library = "libs/python{1}.lib", 50 | visibility = ["@upb//python:__pkg__"], 51 | ) 52 | """ 53 | 54 | def python_nuget_package(name, sha256): 55 | """Helper method to create full and limited api dependencies for windows using nuget 56 | 57 | Args: 58 | name: The name of the target, should be in the form nuget_python_{CPU}_{VERSION} 59 | sha256: The sha256 of the nuget package for that version 60 | """ 61 | cpu = name.split("_")[2] 62 | version = name.split("_")[3] 63 | 64 | full_api_lib_number = version.split(".")[0] + version.split(".")[1] 65 | limited_api_lib_number = version.split(".")[0] 66 | 67 | folder_name_dict = { 68 | "i686": "pythonx86", 69 | "x86-64": "python", 70 | } 71 | 72 | http_archive( 73 | name = name, 74 | urls = [ 75 | "https://www.nuget.org/api/v2/package/{}/{}" 76 | .format(folder_name_dict[cpu], version), 77 | ], 78 | sha256 = sha256, 79 | strip_prefix = "tools", 80 | build_file_content = 81 | nuget_build_file.format(full_api_lib_number, limited_api_lib_number), 82 | type = "zip", 83 | patch_cmds = ["cp -r include/* ."], 84 | ) 85 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/json_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef UPB_JSONENCODE_H_ 29 | #define UPB_JSONENCODE_H_ 30 | 31 | #include "upb/def.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | enum { 38 | /* When set, emits 0/default values. TODO(haberman): proto3 only? */ 39 | upb_JsonEncode_EmitDefaults = 1, 40 | 41 | /* When set, use normal (snake_caes) field names instead of JSON (camelCase) 42 | names. */ 43 | upb_JsonEncode_UseProtoNames = 2 44 | }; 45 | 46 | /* Encodes the given |msg| to JSON format. The message's reflection is given in 47 | * |m|. The symtab in |symtab| is used to find extensions (if NULL, extensions 48 | * will not be printed). 49 | * 50 | * Output is placed in the given buffer, and always NULL-terminated. The output 51 | * size (excluding NULL) is returned. This means that a return value >= |size| 52 | * implies that the output was truncated. (These are the same semantics as 53 | * snprintf()). */ 54 | size_t upb_JsonEncode(const upb_Message* msg, const upb_MessageDef* m, 55 | const upb_DefPool* ext_pool, int options, char* buf, 56 | size_t size, upb_Status* status); 57 | 58 | #ifdef __cplusplus 59 | } /* extern "C" */ 60 | #endif 61 | 62 | #endif /* UPB_JSONENCODE_H_ */ 63 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/text_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef UPB_TEXTENCODE_H_ 29 | #define UPB_TEXTENCODE_H_ 30 | 31 | #include "upb/def.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | enum { 38 | /* When set, prints everything on a single line. */ 39 | UPB_TXTENC_SINGLELINE = 1, 40 | 41 | /* When set, unknown fields are not printed. */ 42 | UPB_TXTENC_SKIPUNKNOWN = 2, 43 | 44 | /* When set, maps are *not* sorted (this avoids allocating tmp mem). */ 45 | UPB_TXTENC_NOSORT = 4 46 | }; 47 | 48 | /* Encodes the given |msg| to text format. The message's reflection is given in 49 | * |m|. The symtab in |symtab| is used to find extensions (if NULL, extensions 50 | * will not be printed). 51 | * 52 | * Output is placed in the given buffer, and always NULL-terminated. The output 53 | * size (excluding NULL) is returned. This means that a return value >= |size| 54 | * implies that the output was truncated. (These are the same semantics as 55 | * snprintf()). */ 56 | size_t upb_TextEncode(const upb_Message* msg, const upb_MessageDef* m, 57 | const upb_DefPool* ext_pool, int options, char* buf, 58 | size_t size); 59 | 60 | #ifdef __cplusplus 61 | } /* extern "C" */ 62 | #endif 63 | 64 | #endif /* UPB_TEXTENCODE_H_ */ 65 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/BUILD: -------------------------------------------------------------------------------- 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(":pyproto_test_wrapper.bzl", "pyproto_test_wrapper") 27 | 28 | licenses(["notice"]) 29 | 30 | pyproto_test_wrapper(name = "descriptor_database_test") 31 | 32 | pyproto_test_wrapper(name = "descriptor_pool_test") 33 | 34 | pyproto_test_wrapper(name = "descriptor_test") 35 | 36 | # begin:github_only 37 | pyproto_test_wrapper(name = "generator_test") 38 | # end:github_only 39 | 40 | pyproto_test_wrapper(name = "json_format_test") 41 | 42 | pyproto_test_wrapper(name = "keywords_test") 43 | 44 | pyproto_test_wrapper(name = "message_factory_test") 45 | 46 | pyproto_test_wrapper(name = "message_test") 47 | 48 | pyproto_test_wrapper(name = "proto_builder_test") 49 | 50 | pyproto_test_wrapper(name = "reflection_test") 51 | 52 | pyproto_test_wrapper(name = "service_reflection_test") 53 | 54 | pyproto_test_wrapper(name = "symbol_database_test") 55 | 56 | pyproto_test_wrapper(name = "text_encoding_test") 57 | 58 | pyproto_test_wrapper(name = "text_format_test") 59 | 60 | pyproto_test_wrapper(name = "unknown_fields_test") 61 | 62 | pyproto_test_wrapper(name = "well_known_types_test") 63 | 64 | pyproto_test_wrapper(name = "wire_format_test") 65 | 66 | filegroup( 67 | name = "test_files", 68 | srcs = glob(["*.py"]), 69 | visibility = ["//python/dist:__pkg__"], 70 | ) 71 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "bundler/setup" 4 | require "ruby_memprofiler_pprof" 5 | require_relative "pprof_pb" 6 | require "minitest/autorun" 7 | require "securerandom" 8 | require "zlib" 9 | require "timecop" 10 | 11 | class DecodedProfileData 12 | class Sample 13 | attr_accessor :backtrace, :line_backtrace, :allocations, :allocation_size, :retained_objects, :retained_size 14 | 15 | def backtrace_contains?(stack_segment) 16 | return false if stack_segment.size > backtrace.size 17 | (0..(backtrace.size - stack_segment.size)).any? do |i| 18 | stack_segment.reverse.zip(backtrace[i...(i + stack_segment.size)]).all? do |test_frame, pb_frame| 19 | pb_frame.include? test_frame 20 | end 21 | end 22 | end 23 | end 24 | 25 | attr_reader :samples, :pprof 26 | 27 | def initialize(profile_data) 28 | if profile_data.is_a?(MemprofilerPprof::ProfileData) 29 | @profile_data = profile_data 30 | pprof_data = @profile_data.pprof_data 31 | else 32 | @profile_data = nil 33 | pprof_data = profile_data 34 | end 35 | @pprof = Perftools::Profiles::Profile.decode Zlib.gunzip(pprof_data) 36 | 37 | @fn_map = @pprof.function.to_h { |fn| [fn.id, fn] } 38 | @loc_map = @pprof.location.to_h { |loc| [loc.id, loc] } 39 | 40 | @samples = @pprof.sample.map do |sample_proto| 41 | s = Sample.new 42 | s.line_backtrace = [] 43 | s.backtrace = [] 44 | sample_proto.location_id.map do |loc_id| 45 | fn = @fn_map[@loc_map[loc_id].line[0].function_id] 46 | fn_name = @pprof.string_table[fn.name] 47 | filename = @pprof.string_table[fn.filename] 48 | line_no = @loc_map[loc_id].line[0].line 49 | 50 | s.backtrace << fn_name 51 | s.line_backtrace << "#{filename}:#{line_no} in #{fn_name}" 52 | end 53 | s.retained_objects = sample_proto.value[0] 54 | s.retained_size = sample_proto.value[1] 55 | s 56 | end 57 | end 58 | 59 | def samples_including_stack(stack_segment) 60 | @samples.select { |s| s.backtrace_contains? stack_segment } 61 | end 62 | 63 | def heap_samples_including_stack(stack_segment) 64 | @samples.select { |s| s.backtrace_contains?(stack_segment) && s.retained_objects > 0 } 65 | end 66 | 67 | def total_retained_objects 68 | @samples.reduce(0) { |acc, s| acc + s.retained_objects } 69 | end 70 | 71 | def total_retained_size(under: nil) 72 | @samples.reduce(0) do |acc, s| 73 | if under 74 | next acc unless s.backtrace_contains? [under] 75 | end 76 | acc + s.retained_size 77 | end 78 | end 79 | 80 | if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7") 81 | def method_missing(m, *args, &blk) 82 | @profile_data.send(m, *args, &blk) 83 | end 84 | else 85 | def method_missing(m, *args, **kwargs, &blk) 86 | @profile_data.send(m, *args, **kwargs, &blk) 87 | end 88 | end 89 | end 90 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/util/compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef UPB_UTIL_COMPARE_H_ 29 | #define UPB_UTIL_COMPARE_H_ 30 | 31 | #include "upb/def.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | // Returns true if unknown fields from the two messages are equal when sorted 38 | // and varints are made canonical. 39 | // 40 | // This function is discouraged, as the comparison is inherently lossy without 41 | // schema data: 42 | // 43 | // 1. We don't know whether delimited fields are sub-messages. Unknown 44 | // sub-messages will therefore not have their fields sorted and varints 45 | // canonicalized. 46 | // 2. We don't know about oneof/non-repeated fields, which should semantically 47 | // discard every value except the last. 48 | 49 | typedef enum { 50 | kUpb_UnknownCompareResult_Equal = 0, 51 | kUpb_UnknownCompareResult_NotEqual = 1, 52 | kUpb_UnknownCompareResult_OutOfMemory = 2, 53 | kUpb_UnknownCompareResult_MaxDepthExceeded = 3, 54 | } upb_UnknownCompareResult; 55 | 56 | upb_UnknownCompareResult upb_Message_UnknownFieldsAreEqual(const char* buf1, 57 | size_t size1, 58 | const char* buf2, 59 | size_t size2, 60 | int max_depth); 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | 66 | #endif /* UPB_UTIL_COMPARE_H_ */ 67 | -------------------------------------------------------------------------------- /lib/ruby_memprofiler_pprof/block_flusher.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MemprofilerPprof 4 | class BlockFlusher 5 | attr_reader :collector 6 | 7 | def initialize( 8 | collector, interval: 30, logger: nil, on_flush: nil, priority: nil, 9 | yield_gvl: false, proactively_yield_gvl: false 10 | ) 11 | @collector = collector 12 | @interval = interval 13 | @logger = logger 14 | @thread = nil 15 | @on_flush = on_flush 16 | @status_mutex = Mutex.new 17 | @status_cvar = ConditionVariable.new 18 | @status = :not_started 19 | @priority = priority 20 | @yield_gvl = yield_gvl 21 | @proactively_yield_gvl = proactively_yield_gvl 22 | end 23 | 24 | def start! 25 | stop! 26 | @status = :running 27 | @is_paused = false 28 | @thread = Thread.new { flusher_thread } 29 | if !@priority.nil? 30 | @thread.priority = @priority 31 | end 32 | @atfork_handler = MemprofilerPprof::Atfork.at_fork(:child, &method(:at_fork_in_child)) 33 | end 34 | 35 | def stop! 36 | @status_mutex.synchronize do 37 | @status = :stop 38 | @status_cvar.broadcast 39 | end 40 | @thread&.join 41 | @thread = nil 42 | @atfork_handler&.remove! 43 | @atfork_handler = nil 44 | end 45 | 46 | def run 47 | start! 48 | begin 49 | yield 50 | ensure 51 | stop! 52 | end 53 | end 54 | 55 | def pause 56 | @status_mutex.synchronize do 57 | @is_paused = true 58 | @status_cvar.broadcast 59 | end 60 | end 61 | 62 | def unpause 63 | @status_mutex.synchronize do 64 | @is_paused = false 65 | @status_cvar.broadcast 66 | end 67 | end 68 | 69 | private 70 | 71 | def flusher_thread 72 | prev_flush_duration = 0 73 | loop do 74 | now = Process.clock_gettime(Process::CLOCK_MONOTONIC) 75 | wait_until = now + [0, @interval - prev_flush_duration].max 76 | 77 | @status_mutex.synchronize do 78 | loop do 79 | return if @status != :running 80 | now = Process.clock_gettime(Process::CLOCK_MONOTONIC) 81 | break if now >= wait_until && !@is_paused 82 | @status_cvar.wait(@status_mutex, wait_until - now) 83 | end 84 | end 85 | 86 | t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC) 87 | begin 88 | profile_data = @collector.flush( 89 | yield_gvl: @yield_gvl, proactively_yield_gvl: @proactively_yield_gvl 90 | ) 91 | @on_flush&.call(profile_data) 92 | rescue => e 93 | @logger&.error("BaseFlusher: failed to flush profiling data: #{e.inspect}") 94 | ensure 95 | t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC) 96 | prev_flush_duration = (t2 - t1) 97 | end 98 | end 99 | end 100 | 101 | def at_fork_in_child 102 | start! if @thread && !@thread.alive? 103 | end 104 | end 105 | end 106 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upbc/BUILD: -------------------------------------------------------------------------------- 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 | "//bazel:build_defs.bzl", 28 | "UPB_DEFAULT_CPPOPTS", 29 | ) 30 | 31 | licenses(["notice"]) 32 | 33 | cc_library( 34 | name = "common", 35 | srcs = ["common.cc"], 36 | hdrs = ["common.h"], 37 | copts = UPB_DEFAULT_CPPOPTS, 38 | deps = [ 39 | "@com_google_absl//absl/strings", 40 | "@com_google_protobuf//:protobuf", 41 | ], 42 | ) 43 | 44 | cc_binary( 45 | name = "protoc-gen-upb", 46 | srcs = ["protoc-gen-upb.cc"], 47 | copts = UPB_DEFAULT_CPPOPTS, 48 | visibility = ["//visibility:public"], 49 | deps = [ 50 | ":common", 51 | "//:mini_table", 52 | "//:port", 53 | "//:upb", 54 | "@com_google_absl//absl/base:core_headers", 55 | "@com_google_absl//absl/container:flat_hash_map", 56 | "@com_google_absl//absl/container:flat_hash_set", 57 | "@com_google_absl//absl/strings", 58 | "@com_google_protobuf//:protobuf", 59 | "@com_google_protobuf//:protoc_lib", 60 | ], 61 | ) 62 | 63 | cc_binary( 64 | name = "protoc-gen-upbdefs", 65 | srcs = [ 66 | "protoc-gen-upbdefs.cc", 67 | ], 68 | copts = UPB_DEFAULT_CPPOPTS, 69 | visibility = ["//visibility:public"], 70 | deps = [ 71 | ":common", 72 | "@com_google_absl//absl/base:core_headers", 73 | "@com_google_absl//absl/container:flat_hash_map", 74 | "@com_google_absl//absl/strings", 75 | "@com_google_protobuf//:protobuf", 76 | "@com_google_protobuf//:protoc_lib", 77 | ], 78 | ) 79 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/python_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PYUPB_PYTHON_H__ 29 | #define PYUPB_PYTHON_H__ 30 | 31 | // We restrict ourselves to the limited API, so that a single build can be 32 | // ABI-compatible with a wide range of Python versions. 33 | // 34 | // The build system will define Py_LIMITED_API as appropriate (see BUILD). We 35 | // only want to define it for our distribution packages, since we can do some 36 | // extra assertions when Py_LIMITED_API is not defined. Also Py_LIMITED_API is 37 | // incompatible with Py_DEBUG. 38 | 39 | // #define Py_LIMITED_API // Defined by build system when appropriate. 40 | 41 | #include "Python.h" 42 | 43 | // Ideally we could restrict ourselves to the limited API of 3.7, but this is 44 | // a very important function that was not officially added to the limited API 45 | // until 3.10. Without this function, there is no way of getting data from a 46 | // Python `str` object without a copy. 47 | // 48 | // While this function was not *officially* added to the limited API until 49 | // Python 3.10, In practice it has been stable since Python 3.1. 50 | // https://bugs.python.org/issue41784 51 | // 52 | // On Linux/ELF and macOS/Mach-O, we can get away with using this function with 53 | // the limited API prior to 3.10. 54 | 55 | #if (defined(__linux__) || defined(__APPLE__)) && defined(Py_LIMITED_API) && \ 56 | Py_LIMITED_API < 0x03100000 57 | PyAPI_FUNC(const char*) 58 | PyUnicode_AsUTF8AndSize(PyObject* unicode, Py_ssize_t* size); 59 | #endif 60 | 61 | #endif // PYUPB_PYTHON_H__ 62 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upbc/common.cc: -------------------------------------------------------------------------------- 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 "upbc/common.h" 27 | 28 | #include "absl/strings/str_replace.h" 29 | 30 | namespace upbc { 31 | namespace { 32 | 33 | namespace protobuf = ::google::protobuf; 34 | 35 | } // namespace 36 | 37 | std::string StripExtension(absl::string_view fname) { 38 | size_t lastdot = fname.find_last_of('.'); 39 | if (lastdot == std::string::npos) { 40 | return std::string(fname); 41 | } 42 | return std::string(fname.substr(0, lastdot)); 43 | } 44 | 45 | std::string ToCIdent(absl::string_view str) { 46 | return absl::StrReplaceAll(str, {{".", "_"}, {"/", "_"}}); 47 | } 48 | 49 | std::string ToPreproc(absl::string_view str) { 50 | return absl::AsciiStrToUpper(ToCIdent(str)); 51 | } 52 | 53 | void EmitFileWarning(const protobuf::FileDescriptor* file, Output& output) { 54 | output( 55 | "/* This file was generated by upbc (the upb compiler) from the input\n" 56 | " * file:\n" 57 | " *\n" 58 | " * $0\n" 59 | " *\n" 60 | " * Do not edit -- your changes will be discarded when the file is\n" 61 | " * regenerated. */\n\n", 62 | file->name()); 63 | } 64 | 65 | std::string MessageName(const protobuf::Descriptor* descriptor) { 66 | return ToCIdent(descriptor->full_name()); 67 | } 68 | 69 | std::string FileLayoutName(const google::protobuf::FileDescriptor* file) { 70 | return ToCIdent(file->name()) + "_upb_file_layout"; 71 | } 72 | 73 | std::string HeaderFilename(const google::protobuf::FileDescriptor* file) { 74 | return StripExtension(file->name()) + ".upb.h"; 75 | } 76 | 77 | } // namespace upbc 78 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/pb_unit_tests/message_test_wrapper.py: -------------------------------------------------------------------------------- 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 | from google.protobuf.internal.message_test import * 27 | import unittest 28 | 29 | # We don't want to support extending repeated fields with nothing; this behavior 30 | # is marked for deprecation in the existing library. 31 | MessageTest.testExtendFloatWithNothing_proto2.__unittest_expecting_failure__ = True 32 | MessageTest.testExtendFloatWithNothing_proto3.__unittest_expecting_failure__ = True 33 | MessageTest.testExtendInt32WithNothing_proto2.__unittest_expecting_failure__ = True 34 | MessageTest.testExtendInt32WithNothing_proto3.__unittest_expecting_failure__ = True 35 | MessageTest.testExtendStringWithNothing_proto2.__unittest_expecting_failure__ = True 36 | MessageTest.testExtendStringWithNothing_proto3.__unittest_expecting_failure__ = True 37 | 38 | # Python/C++ customizes the C++ TextFormat to always print trailing ".0" for 39 | # floats. upb doesn't do this, it matches C++ TextFormat. 40 | MessageTest.testFloatPrinting_proto2.__unittest_expecting_failure__ = True 41 | MessageTest.testFloatPrinting_proto3.__unittest_expecting_failure__ = True 42 | 43 | # For these tests we are throwing the correct error, only the text of the error 44 | # message is a mismatch. For technical reasons around the limited API, matching 45 | # the existing error message exactly is not feasible. 46 | Proto3Test.testCopyFromBadType.__unittest_expecting_failure__ = True 47 | Proto3Test.testMergeFromBadType.__unittest_expecting_failure__ = True 48 | 49 | Proto2Test.test_documentation.__unittest_expecting_failure__ = True 50 | 51 | if __name__ == '__main__': 52 | unittest.main(verbosity=2) 53 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/upb_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef UPB_INT_H_ 29 | #define UPB_INT_H_ 30 | 31 | #include "upb/upb.h" 32 | 33 | struct mem_block; 34 | typedef struct mem_block mem_block; 35 | 36 | struct upb_Arena { 37 | _upb_ArenaHead head; 38 | /* Stores cleanup metadata for this arena. 39 | * - a pointer to the current cleanup counter. 40 | * - a boolean indicating if there is an unowned initial block. */ 41 | uintptr_t cleanup_metadata; 42 | 43 | /* Allocator to allocate arena blocks. We are responsible for freeing these 44 | * when we are destroyed. */ 45 | upb_alloc* block_alloc; 46 | uint32_t last_size; 47 | 48 | /* When multiple arenas are fused together, each arena points to a parent 49 | * arena (root points to itself). The root tracks how many live arenas 50 | * reference it. */ 51 | uint32_t refcount; /* Only used when a->parent == a */ 52 | struct upb_Arena* parent; 53 | 54 | /* Linked list of blocks to free/cleanup. */ 55 | mem_block *freelist, *freelist_tail; 56 | }; 57 | 58 | // Encodes a float or double that is round-trippable, but as short as possible. 59 | // These routines are not fully optimal (not guaranteed to be shortest), but are 60 | // short-ish and match the implementation that has been used in protobuf since 61 | // the beginning. 62 | // 63 | // The given buffer size must be at least kUpb_RoundTripBufferSize. 64 | enum { kUpb_RoundTripBufferSize = 32 }; 65 | void _upb_EncodeRoundTripDouble(double val, char* buf, size_t size); 66 | void _upb_EncodeRoundTripFloat(float val, char* buf, size_t size); 67 | 68 | #endif /* UPB_INT_H_ */ 69 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/util/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "//bazel:upb_proto_library.bzl", 3 | "upb_proto_library", 4 | "upb_proto_reflection_library", 5 | ) 6 | 7 | licenses(["notice"]) 8 | 9 | # Def to Proto 10 | 11 | cc_library( 12 | name = "def_to_proto", 13 | srcs = ["def_to_proto.c"], 14 | hdrs = ["def_to_proto.h"], 15 | visibility = ["//visibility:public"], 16 | deps = [ 17 | "//:port", 18 | "//:reflection", 19 | ], 20 | ) 21 | 22 | proto_library( 23 | name = "def_to_proto_test_proto", 24 | srcs = [ 25 | "def_to_proto_public_import_test.proto", 26 | "def_to_proto_regular_import_test.proto", 27 | "def_to_proto_test.proto", 28 | ], 29 | ) 30 | 31 | upb_proto_library( 32 | name = "def_to_proto_test_upb_proto", 33 | deps = ["def_to_proto_test_proto"], 34 | ) 35 | 36 | upb_proto_reflection_library( 37 | name = "def_to_proto_test_upb_proto_reflection", 38 | deps = ["def_to_proto_test_proto"], 39 | ) 40 | 41 | cc_test( 42 | name = "def_to_proto_test", 43 | srcs = ["def_to_proto_test.cc"], 44 | deps = [ 45 | ":def_to_proto", 46 | ":def_to_proto_test_upb_proto", 47 | ":def_to_proto_test_upb_proto_reflection", 48 | "//:descriptor_upb_proto_reflection", 49 | "//:reflection", 50 | "//:upb", 51 | "@com_google_absl//absl/strings", 52 | "@com_google_googletest//:gtest_main", 53 | "@com_google_protobuf//:protobuf", 54 | ], 55 | ) 56 | 57 | # Required fields 58 | 59 | cc_library( 60 | name = "required_fields", 61 | srcs = ["required_fields.c"], 62 | hdrs = ["required_fields.h"], 63 | visibility = ["//visibility:public"], 64 | deps = [ 65 | "//:port", 66 | "//:reflection", 67 | ], 68 | ) 69 | 70 | proto_library( 71 | name = "required_fields_test_proto", 72 | srcs = ["required_fields_test.proto"], 73 | ) 74 | 75 | upb_proto_library( 76 | name = "required_fields_test_upb_proto", 77 | deps = ["required_fields_test_proto"], 78 | ) 79 | 80 | upb_proto_reflection_library( 81 | name = "required_fields_test_upb_proto_reflection", 82 | deps = ["required_fields_test_proto"], 83 | ) 84 | 85 | cc_test( 86 | name = "required_fields_test", 87 | srcs = ["required_fields_test.cc"], 88 | deps = [ 89 | ":required_fields", 90 | ":required_fields_test_upb_proto", 91 | ":required_fields_test_upb_proto_reflection", 92 | "//:json", 93 | "//:reflection", 94 | "//:upb", 95 | "@com_google_absl//absl/strings", 96 | "@com_google_googletest//:gtest_main", 97 | ], 98 | ) 99 | 100 | # Compare 101 | 102 | cc_library( 103 | name = "compare", 104 | srcs = ["compare.c"], 105 | hdrs = ["compare.h"], 106 | visibility = ["//visibility:public"], 107 | deps = [ 108 | "//:port", 109 | "//:reflection", 110 | ], 111 | ) 112 | 113 | cc_test( 114 | name = "compare_test", 115 | srcs = ["compare_test.cc"], 116 | deps = [ 117 | ":compare", 118 | "@com_google_absl//absl/strings", 119 | "@com_google_googletest//:gtest_main", 120 | ], 121 | ) 122 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/util/def_to_proto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef UPB_UTIL_DEF_TO_PROTO_H_ 29 | #define UPB_UTIL_DEF_TO_PROTO_H_ 30 | 31 | #include "upb/def.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | // Functions for converting defs back to the equivalent descriptor proto. 38 | // Ultimately the goal is that a round-trip proto->def->proto is lossless. Each 39 | // function returns a new proto created in arena `a`, or NULL if memory 40 | // allocation failed. 41 | google_protobuf_DescriptorProto* upb_MessageDef_ToProto(const upb_MessageDef* m, 42 | upb_Arena* a); 43 | google_protobuf_EnumDescriptorProto* upb_EnumDef_ToProto(const upb_EnumDef* e, 44 | upb_Arena* a); 45 | google_protobuf_EnumValueDescriptorProto* upb_EnumValueDef_ToProto( 46 | const upb_EnumValueDef* e, upb_Arena* a); 47 | google_protobuf_FieldDescriptorProto* upb_FieldDef_ToProto( 48 | const upb_FieldDef* f, upb_Arena* a); 49 | google_protobuf_OneofDescriptorProto* upb_OneofDef_ToProto( 50 | const upb_OneofDef* o, upb_Arena* a); 51 | google_protobuf_FileDescriptorProto* upb_FileDef_ToProto(const upb_FileDef* f, 52 | upb_Arena* a); 53 | google_protobuf_MethodDescriptorProto* upb_MethodDef_ToProto( 54 | const upb_MethodDef* m, upb_Arena* a); 55 | google_protobuf_ServiceDescriptorProto* upb_ServiceDef_ToProto( 56 | const upb_ServiceDef* s, upb_Arena* a); 57 | 58 | #ifdef __cplusplus 59 | } /* extern "C" */ 60 | #endif 61 | 62 | #endif /* UPB_UTIL_DEF_TO_PROTO_H_ */ 63 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/.bazelrc: -------------------------------------------------------------------------------- 1 | # temporary fix for https://github.com/bazelbuild/bazel/issues/12905 on macOS 2 | build --features=-debug_prefix_map_pwd_is_dot 3 | 4 | build --extra_toolchains=@system_python//:python_toolchain 5 | 6 | # Use our custom-configured c++ toolchain. 7 | 8 | build:m32 --copt=-m32 --linkopt=-m32 9 | build:asan --copt=-fsanitize=address --linkopt=-fsanitize=address 10 | build:msan --copt=-fsanitize=memory --linkopt=-fsanitize=memory 11 | 12 | # For Valgrind, we have to disable checks of "possible" leaks because the Python 13 | # interpreter does the sorts of things that flag Valgrind "possible" leak checks. 14 | # Ideally we could enforce a stricter check for the non-Python tests, but I don't 15 | # know of an easy way to do that. 16 | # 17 | # We also have to disable pymalloc to avoid triggering Valgrind. 18 | build:valgrind --run_under='valgrind --leak-check=full --track-origins=yes --trace-children=yes --show-leak-kinds=all --error-exitcode=1 --num-callers=500 ' --action_env=PYTHONMALLOC=malloc 19 | 20 | build:ubsan --copt=-fsanitize=undefined --linkopt=-fsanitize=undefined --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 21 | # Workaround for the fact that Bazel links with $CC, not $CXX 22 | # https://github.com/bazelbuild/bazel/issues/11122#issuecomment-613746748 23 | build:ubsan --copt=-fno-sanitize=function --copt=-fno-sanitize=vptr 24 | # Workaround for https://bugs.llvm.org/show_bug.cgi?id=16404 25 | build:ubsan --linkopt=--rtlib=compiler-rt --linkopt=-lunwind 26 | 27 | build:Werror --copt=-Werror 28 | build:Werror --per_file_copt=json/parser@-Wno-error 29 | build:Werror --per_file_copt=com_google_protobuf@-Wno-error 30 | 31 | # GCC's -fanalyzer, a deeper static analysis than normal warnings. 32 | build:analyzer --copt=-fanalyzer --copt=-Werror 33 | build:analyzer --per_file_copt=json/parser@-fno-analyzer 34 | build:analyzer --per_file_copt=com_google_protobuf@-fno-analyzer 35 | build:analyzer --per_file_copt=com_github_google_benchmark@-fno-analyzer 36 | 37 | # --config=asan-libfuzzer 38 | build:asan-libfuzzer --action_env=CC=clang 39 | build:asan-libfuzzer --action_env=CXX=clang++ 40 | build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer 41 | build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer 42 | build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan 43 | 44 | # --config=msan-libfuzzer 45 | build:msan-libfuzzer --action_env=CC=clang 46 | build:msan-libfuzzer --action_env=CXX=clang++ 47 | build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer 48 | build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer 49 | build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=msan 50 | 51 | # --config=ubsan-libfuzzer 52 | build:ubsan-libfuzzer --action_env=CC=clang 53 | build:ubsan-libfuzzer --action_env=CXX=clang++ 54 | build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer 55 | build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer 56 | build:ubsan-libfuzzer --copt=-fsanitize=undefined 57 | build:ubsan-libfuzzer --linkopt=-fsanitize=undefined 58 | build:ubsan-libfuzzer --linkopt=-fsanitize-link-c++-runtime 59 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/upb/bindings/lua/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "upb/bindings/lua/upb.h" 34 | 35 | lua_State* L; 36 | 37 | static void interrupt(lua_State* L, lua_Debug* ar) { 38 | (void)ar; 39 | lua_sethook(L, NULL, 0, 0); 40 | luaL_error(L, "SIGINT"); 41 | } 42 | 43 | static void sighandler(int i) { 44 | fprintf(stderr, "Signal!\n"); 45 | signal(i, SIG_DFL); 46 | lua_sethook(L, interrupt, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); 47 | } 48 | 49 | const char* init = 50 | "package.preload['lupb'] = ... " 51 | "package.path = '" 52 | "./?.lua;" 53 | "./third_party/lunit/?.lua;" 54 | "external/com_google_protobuf/?.lua;" 55 | "external/com_google_protobuf/src/?.lua;" 56 | "bazel-bin/?.lua;" 57 | "bazel-bin/external/com_google_protobuf/src/?.lua;" 58 | "bazel-bin/external/com_google_protobuf/?.lua;" 59 | "bazel-bin/external/com_google_protobuf/?.lua;" 60 | "upb/bindings/lua/?.lua" 61 | "'"; 62 | 63 | int main(int argc, char** argv) { 64 | int ret = 0; 65 | L = luaL_newstate(); 66 | luaL_openlibs(L); 67 | lua_pushcfunction(L, luaopen_lupb); 68 | ret = luaL_loadstring(L, init); 69 | lua_pushcfunction(L, luaopen_lupb); 70 | 71 | signal(SIGINT, sighandler); 72 | ret = ret || lua_pcall(L, 1, LUA_MULTRET, 0) || 73 | luaL_dofile(L, "upb/bindings/lua/test_upb.lua"); 74 | signal(SIGINT, SIG_DFL); 75 | 76 | if (ret) { 77 | fprintf(stderr, "error testing Lua: %s\n", lua_tostring(L, -1)); 78 | ret = 1; 79 | } 80 | 81 | lua_close(L); 82 | return ret; 83 | } 84 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PYUPB_MAP_H__ 29 | #define PYUPB_MAP_H__ 30 | 31 | #include 32 | 33 | #include "python/python_api.h" 34 | #include "upb/def.h" 35 | 36 | // Creates a new repeated field stub for field `f` of message object `parent`. 37 | // Precondition: `parent` must be a stub. 38 | PyObject* PyUpb_MapContainer_NewStub(PyObject* parent, const upb_FieldDef* f, 39 | PyObject* arena); 40 | 41 | // Returns a map object wrapping `map`, of field type `f`, which must be on 42 | // `arena`. If an existing wrapper object exists, it will be returned, 43 | // otherwise a new object will be created. The caller always owns a ref on the 44 | // returned value. 45 | PyObject* PyUpb_MapContainer_GetOrCreateWrapper(upb_Map* map, 46 | const upb_FieldDef* f, 47 | PyObject* arena); 48 | 49 | // Reifies a map stub to point to the concrete data in `map`. 50 | // If `map` is NULL, an appropriate empty map will be constructed. 51 | void PyUpb_MapContainer_Reify(PyObject* self, upb_Map* map); 52 | 53 | // Reifies this map object if it is not already reified. 54 | upb_Map* PyUpb_MapContainer_EnsureReified(PyObject* self); 55 | 56 | // Assigns `self[key] = val` for the map `self`. 57 | int PyUpb_MapContainer_AssignSubscript(PyObject* self, PyObject* key, 58 | PyObject* val); 59 | 60 | // Invalidates any existing iterators for the map `obj`. 61 | void PyUpb_MapContainer_Invalidate(PyObject* obj); 62 | 63 | // Module-level init. 64 | bool PyUpb_Map_Init(PyObject* m); 65 | 66 | #endif // PYUPB_MAP_H__ 67 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/convert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PYUPB_CONVERT_H__ 29 | #define PYUPB_CONVERT_H__ 30 | 31 | #include "protobuf.h" 32 | #include "upb/def.h" 33 | #include "upb/reflection.h" 34 | 35 | // Converts `val` to a Python object according to the type information in `f`. 36 | // Any newly-created Python objects that reference non-primitive data from `val` 37 | // will take a reference on `arena`; the caller must ensure that `val` belongs 38 | // to `arena`. If the conversion cannot be performed, returns NULL and sets a 39 | // Python error. 40 | PyObject* PyUpb_UpbToPy(upb_MessageValue val, const upb_FieldDef* f, 41 | PyObject* arena); 42 | 43 | // Converts `obj` to a upb_MessageValue `*val` according to the type information 44 | // in `f`. If `arena` is provided, any string data will be copied into `arena`, 45 | // otherwise the returned value will alias the Python-owned data (this can be 46 | // useful for an ephemeral upb_MessageValue). If the conversion cannot be 47 | // performed, returns false. 48 | bool PyUpb_PyToUpb(PyObject* obj, const upb_FieldDef* f, upb_MessageValue* val, 49 | upb_Arena* arena); 50 | 51 | // Returns true if the given values (of type `f`) are equal. 52 | bool PyUpb_ValueEq(upb_MessageValue val1, upb_MessageValue val2, 53 | const upb_FieldDef* f); 54 | 55 | // Returns true if the given messages (of type `m`) are equal. 56 | bool PyUpb_Message_IsEqual(const upb_Message* msg1, const upb_Message* msg2, 57 | const upb_MessageDef* m); 58 | 59 | // Returns true if the two arrays (with element type `f`) are equal. 60 | bool PyUpb_Array_IsEqual(const upb_Array* arr1, const upb_Array* arr2, 61 | const upb_FieldDef* f); 62 | 63 | #endif // PYUPB_CONVERT_H__ 64 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/benchmarks/build_defs.bzl: -------------------------------------------------------------------------------- 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 = "cc_proto_library") 28 | # 29 | # _is_google3 = True 30 | # end:google_only 31 | 32 | # begin:github_only 33 | _cc_proto_library = native.cc_proto_library 34 | _is_google3 = False 35 | # end:github_only 36 | 37 | def proto_library(**kwargs): 38 | if _is_google3: 39 | kwargs["cc_api_version"] = 2 40 | native.proto_library( 41 | **kwargs 42 | ) 43 | 44 | def tmpl_cc_binary(name, gen, args, replacements = [], **kwargs): 45 | srcs = [name + ".cc"] 46 | native.genrule( 47 | name = name + "_gen_srcs", 48 | tools = [gen], 49 | outs = srcs, 50 | cmd = "$(location " + gen + ") " + " ".join(args) + " > $@", 51 | ) 52 | 53 | if _is_google3: 54 | kwargs["malloc"] = "//base:system_malloc" 55 | kwargs["features"] = ["-static_linking_mode"] 56 | native.cc_binary( 57 | name = name, 58 | srcs = srcs, 59 | **kwargs 60 | ) 61 | 62 | def cc_optimizefor_proto_library(name, srcs, outs, optimize_for): 63 | if len(srcs) != 1: 64 | fail("Currently srcs must have exactly 1 element") 65 | 66 | native.genrule( 67 | name = name + "_gen_proto", 68 | srcs = srcs, 69 | outs = outs, 70 | cmd = "cp $< $@ && chmod a+w $@ && echo 'option optimize_for = " + optimize_for + ";' >> $@", 71 | ) 72 | 73 | proto_library( 74 | name = name + "_proto", 75 | srcs = outs, 76 | ) 77 | 78 | _cc_proto_library( 79 | name = name, 80 | deps = [":" + name + "_proto"], 81 | ) 82 | 83 | def expand_suffixes(vals, suffixes): 84 | ret = [] 85 | for val in vals: 86 | for suffix in suffixes: 87 | ret.append(val + suffix) 88 | return ret 89 | -------------------------------------------------------------------------------- /test/test_profiling.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative "test_helper" 4 | 5 | describe MemprofilerPprof::Collector do 6 | it "captures backtraces for retained objects" do 7 | $bucket = [] 8 | def leak_into_bucket_1 9 | $bucket << SecureRandom.hex(20) 10 | end 11 | 12 | def leak_into_bucket_2 13 | $bucket << SecureRandom.hex(20) 14 | end 15 | 16 | c = MemprofilerPprof::Collector.new(sample_rate: 1.0) 17 | 18 | c.start! 19 | 1000.times { leak_into_bucket_1 } 20 | profile_1_data = c.flush 21 | 1000.times { leak_into_bucket_2 } 22 | profile_2_data = c.flush 23 | $bucket = [] 24 | 1000.times { leak_into_bucket_2 } 25 | 10.times { GC.start } 26 | # At this point, there _should_ be no more objects allocated by leak_into_bucket_1 27 | profile_3_data = c.flush 28 | c.stop! 29 | 30 | profile_1 = DecodedProfileData.new(profile_1_data) 31 | profile_2 = DecodedProfileData.new(profile_2_data) 32 | profile_3 = DecodedProfileData.new(profile_3_data) 33 | 34 | assert_operator profile_1.heap_samples_including_stack(["leak_into_bucket_1"]).size, :>=, 1000 35 | assert_operator profile_2.heap_samples_including_stack(["leak_into_bucket_1"]).size, :>=, 1000 36 | assert_operator profile_3.heap_samples_including_stack(["leak_into_bucket_1"]).size, :<, 10 37 | end 38 | 39 | it "captures allocation sizes" do 40 | def big_allocation_func 41 | SecureRandom.hex(50000) 42 | end 43 | 44 | def medium_allocation_func 45 | SecureRandom.hex(5000) 46 | end 47 | 48 | c = MemprofilerPprof::Collector.new(sample_rate: 1.0) 49 | leak_list = [] 50 | profile_data = c.profile do 51 | leak_list << big_allocation_func 52 | leak_list << medium_allocation_func 53 | end 54 | 55 | pprof = DecodedProfileData.new(profile_data) 56 | big_bytes = pprof.total_retained_size under: "big_allocation_func" 57 | medium_bytes = pprof.total_retained_size under: "medium_allocation_func" 58 | 59 | assert_operator big_bytes, :>=, 50000 60 | assert_operator medium_bytes, :>=, 5000 61 | assert_operator medium_bytes, :<, 20000 62 | end 63 | 64 | it "handles compaction" do 65 | skip "Compaction requires Ruby 2.7+" unless ::GC.respond_to?(:compact) 66 | 67 | def big_array_compacting_method 68 | the_array = Array.new(20000) 69 | 20000.times do |i| 70 | the_array[i] = SecureRandom.hex(10) 71 | if i > 10 && i % 3 == 0 72 | the_array[i - 10] = nil 73 | end 74 | end 75 | the_array 76 | end 77 | 78 | # If we're not handling compaction correctly, this will segfault because we won't notice 79 | # that all the elements of the_array got moved. 80 | c = MemprofilerPprof::Collector.new(sample_rate: 1.0) 81 | keep_live = nil 82 | c.profile do 83 | keep_live = big_array_compacting_method 84 | 2.times { GC.compact } 85 | keep_live = big_array_compacting_method 86 | end 87 | end 88 | 89 | it "respects max heap samples" do 90 | c = MemprofilerPprof::Collector.new(sample_rate: 1.0, max_heap_samples: 20) 91 | retain = [] 92 | profile_data = c.profile do 93 | 100.times { retain << SecureRandom.hex(50) } 94 | end 95 | 96 | pprof = DecodedProfileData.new(profile_data) 97 | assert_operator pprof.dropped_samples_heap_bufsize, :>=, 80 98 | end 99 | end 100 | -------------------------------------------------------------------------------- /test/test_file_flusher.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative "test_helper" 4 | require "fileutils" 5 | require "tmpdir" 6 | require "logger" 7 | 8 | class FakeSleepExtension 9 | end 10 | 11 | describe MemprofilerPprof::FileFlusher do 12 | before do 13 | @dir = Dir.mktmpdir 14 | end 15 | 16 | after do 17 | FileUtils.remove_entry @dir 18 | end 19 | 20 | def alloc_method_1 21 | SecureRandom.hex(10) 22 | end 23 | 24 | def alloc_method_2 25 | SecureRandom.hex(10) 26 | end 27 | 28 | def alloc_method_3 29 | SecureRandom.hex(10) 30 | end 31 | 32 | def wait_for_file_exist(file) 33 | 5000.times do 34 | return if File.exist?(file) 35 | sleep 1 36 | end 37 | raise "File #{file} did not get created" 38 | end 39 | 40 | it "writes profiles to the directory" do 41 | c = MemprofilerPprof::Collector.new(sample_rate: 1.0) 42 | flusher = MemprofilerPprof::FileFlusher.new(c, 43 | pattern: "#{@dir}/%{index}.pprof", 44 | interval: 2, 45 | logger: Logger.new($stderr), 46 | yield_gvl: true, 47 | proactively_yield_gvl: true) 48 | 49 | flusher.run do 50 | leak_list = [] 51 | c.profile do 52 | leak_list << alloc_method_1 53 | wait_for_file_exist "#{@dir}/0.pprof" 54 | leak_list << alloc_method_2 55 | wait_for_file_exist "#{@dir}/1.pprof" 56 | end 57 | end 58 | 59 | assert File.exist?("#{@dir}/0.pprof") 60 | assert File.exist?("#{@dir}/1.pprof") 61 | 62 | profile_1 = DecodedProfileData.new(File.read("#{@dir}/0.pprof")) 63 | profile_2 = DecodedProfileData.new(File.read("#{@dir}/1.pprof")) 64 | 65 | assert profile_1.heap_samples_including_stack(["alloc_method_1"]).size > 0 66 | assert profile_1.heap_samples_including_stack(["alloc_method_2"]).empty? 67 | assert profile_2.heap_samples_including_stack(["alloc_method_2"]).size > 0 68 | end 69 | 70 | it "writes for both parent and child on fork" do 71 | c = MemprofilerPprof::Collector.new(sample_rate: 1.0) 72 | flusher = MemprofilerPprof::FileFlusher.new(c, 73 | pattern: "#{@dir}/%{pid}-%{index}.pprof", 74 | interval: 2, 75 | logger: Logger.new($stderr)) 76 | 77 | flusher.start! 78 | c.start! 79 | 80 | leak_list = [] 81 | leak_list << alloc_method_1 82 | parent_pid = Process.pid 83 | child_pid = fork do 84 | # Child process 85 | leak_list << alloc_method_2 86 | wait_for_file_exist "#{@dir}/#{Process.pid}-0.pprof" 87 | c.stop! 88 | flusher.stop! 89 | exit! 0 90 | end 91 | leak_list << alloc_method_3 92 | wait_for_file_exist "#{@dir}/#{Process.pid}-0.pprof" 93 | 94 | c.stop! 95 | flusher.stop! 96 | 97 | Process.waitpid child_pid 98 | profile_parent = DecodedProfileData.new(File.read("#{@dir}/#{parent_pid}-0.pprof")) 99 | profile_child = DecodedProfileData.new(File.read("#{@dir}/#{child_pid}-0.pprof")) 100 | 101 | assert profile_parent.heap_samples_including_stack(["alloc_method_1"]).size > 0 102 | assert profile_parent.heap_samples_including_stack(["alloc_method_2"]).empty? 103 | assert profile_parent.heap_samples_including_stack(["alloc_method_3"]).size > 0 104 | 105 | assert profile_child.heap_samples_including_stack(["alloc_method_1"]).size > 0 106 | assert profile_child.heap_samples_including_stack(["alloc_method_2"]).size > 0 107 | assert profile_child.heap_samples_including_stack(["alloc_method_3"]).empty? 108 | end 109 | end 110 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/bazel/workspace_deps.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 2 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 3 | load("//bazel:python_downloads.bzl", "python_nuget_package", "python_source_archive") 4 | load("//bazel:system_python.bzl", "system_python") 5 | 6 | def _github_archive(repo, commit, **kwargs): 7 | repo_name = repo.split("/")[-1] 8 | http_archive( 9 | urls = [repo + "/archive/" + commit + ".zip"], 10 | strip_prefix = repo_name + "-" + commit, 11 | **kwargs 12 | ) 13 | 14 | def upb_deps(): 15 | maybe( 16 | http_archive, 17 | name = "com_google_absl", 18 | url = "https://github.com/abseil/abseil-cpp/archive/b9b925341f9e90f5e7aa0cf23f036c29c7e454eb.zip", 19 | strip_prefix = "abseil-cpp-b9b925341f9e90f5e7aa0cf23f036c29c7e454eb", 20 | sha256 = "bb2a0b57c92b6666e8acb00f4cbbfce6ddb87e83625fb851b0e78db581340617", 21 | ) 22 | 23 | maybe( 24 | _github_archive, 25 | name = "com_google_protobuf", 26 | repo = "https://github.com/protocolbuffers/protobuf", 27 | commit = "b180b2809f7e77fdf7dd075d26a7421085bac58f", 28 | patches = ["//bazel:protobuf.patch"], 29 | ) 30 | 31 | rules_python_version = "740825b7f74930c62f44af95c9a4c1bd428d2c53" # Latest @ 2021-06-23 32 | 33 | maybe( 34 | http_archive, 35 | name = "rules_python", 36 | strip_prefix = "rules_python-{}".format(rules_python_version), 37 | url = "https://github.com/bazelbuild/rules_python/archive/{}.zip".format(rules_python_version), 38 | sha256 = "09a3c4791c61b62c2cbc5b2cbea4ccc32487b38c7a2cc8f87a794d7a659cc742", 39 | ) 40 | 41 | maybe( 42 | http_archive, 43 | name = "bazel_skylib", 44 | strip_prefix = "bazel-skylib-main", 45 | urls = ["https://github.com/bazelbuild/bazel-skylib/archive/main.tar.gz"], 46 | ) 47 | 48 | system_python( 49 | name = "system_python", 50 | ) 51 | 52 | #Python Downloads 53 | 54 | python_source_archive( 55 | name = "python-3.7.0", 56 | sha256 = "85bb9feb6863e04fb1700b018d9d42d1caac178559ffa453d7e6a436e259fd0d", 57 | ) 58 | python_nuget_package( 59 | name = "nuget_python_i686_3.7.0", 60 | sha256 = "a8bb49fa1ca62ad55430fcafaca1b58015e22943e66b1a87d5e7cef2556c6a54", 61 | ) 62 | python_nuget_package( 63 | name = "nuget_python_x86-64_3.7.0", 64 | sha256 = "66eb796a5bdb1e6787b8f655a1237a6b6964af2115b7627cf4f0032cf068b4b2", 65 | ) 66 | python_nuget_package( 67 | name = "nuget_python_i686_3.8.0", 68 | sha256 = "87a6481f5eef30b42ac12c93f06f73bd0b8692f26313b76a6615d1641c4e7bca", 69 | ) 70 | python_nuget_package( 71 | name = "nuget_python_x86-64_3.8.0", 72 | sha256 = "96c61321ce90dd053c8a04f305a5f6cc6d91350b862db34440e4a4f069b708a0", 73 | ) 74 | python_nuget_package( 75 | name = "nuget_python_i686_3.9.0", 76 | sha256 = "229abecbe49dc08fe5709e0b31e70edfb3b88f23335ebfc2904c44f940fd59b6", 77 | ) 78 | python_nuget_package( 79 | name = "nuget_python_x86-64_3.9.0", 80 | sha256 = "6af58a733e7dfbfcdd50d55788134393d6ffe7ab8270effbf724bdb786558832", 81 | ) 82 | python_nuget_package( 83 | name = "nuget_python_i686_3.10.0", 84 | sha256 = "e115e102eb90ce160ab0ef7506b750a8d7ecc385bde0a496f02a54337a8bc333", 85 | ) 86 | python_nuget_package( 87 | name = "nuget_python_x86-64_3.10.0", 88 | sha256 = "4474c83c25625d93e772e926f95f4cd398a0abbb52793625fa30f39af3d2cc00", 89 | ) 90 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/python/repeated.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2021, Google LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Google LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef PYUPB_REPEATED_H__ 29 | #define PYUPB_REPEATED_H__ 30 | 31 | #include 32 | 33 | #include "python/python_api.h" 34 | #include "upb/def.h" 35 | 36 | // Creates a new repeated field stub for field `f` of message object `parent`. 37 | // Precondition: `parent` must be a stub. 38 | PyObject* PyUpb_RepeatedContainer_NewStub(PyObject* parent, 39 | const upb_FieldDef* f, 40 | PyObject* arena); 41 | 42 | // Returns a repeated field object wrapping `arr`, of field type `f`, which 43 | // must be on `arena`. If an existing wrapper object exists, it will be 44 | // returned, otherwise a new object will be created. The caller always owns a 45 | // ref on the returned value. 46 | PyObject* PyUpb_RepeatedContainer_GetOrCreateWrapper(upb_Array* arr, 47 | const upb_FieldDef* f, 48 | PyObject* arena); 49 | 50 | // Reifies a repeated field stub to point to the concrete data in `arr`. 51 | // If `arr` is NULL, an appropriate empty array will be constructed. 52 | void PyUpb_RepeatedContainer_Reify(PyObject* self, upb_Array* arr); 53 | 54 | // Reifies this repeated object if it is not already reified. 55 | upb_Array* PyUpb_RepeatedContainer_EnsureReified(PyObject* self); 56 | 57 | // Implements repeated_field.extend(iterable). `_self` must be a repeated 58 | // field (either repeated composite or repeated scalar). 59 | PyObject* PyUpb_RepeatedContainer_Extend(PyObject* _self, PyObject* value); 60 | 61 | // Implements repeated_field.add(initial_values). `_self` must be a repeated 62 | // composite field. 63 | PyObject* PyUpb_RepeatedCompositeContainer_Add(PyObject* _self, PyObject* args, 64 | PyObject* kwargs); 65 | 66 | // Module-level init. 67 | bool PyUpb_Repeated_Init(PyObject* m); 68 | 69 | #endif // PYUPB_REPEATED_H__ 70 | -------------------------------------------------------------------------------- /ext/ruby_memprofiler_pprof_ext/vendor/upb/cmake/build_defs.bzl: -------------------------------------------------------------------------------- 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 | """Bazel support functions related to CMake support.""" 27 | 28 | def generated_file_staleness_test(name, outs, generated_pattern, **kwargs): 29 | """Tests that checked-in file(s) match the contents of generated file(s). 30 | 31 | The resulting test will verify that all output files exist and have the 32 | correct contents. If the test fails, it can be invoked with --fix to 33 | bring the checked-in files up to date. 34 | 35 | Args: 36 | name: Name of the rule. 37 | outs: the checked-in files that are copied from generated files. 38 | generated_pattern: the pattern for transforming each "out" file into a 39 | generated file. For example, if generated_pattern="generated/%s" then 40 | a file foo.txt will look for generated file generated/foo.txt. 41 | **kwargs: Additional keyword arguments to pass through to py_test(). 42 | """ 43 | 44 | script_name = name + ".py" 45 | script_src = ":staleness_test.py" 46 | 47 | # Filter out non-existing rules so Blaze doesn't error out before we even 48 | # run the test. 49 | existing_outs = native.glob(include = outs) 50 | 51 | # The file list contains a few extra bits of information at the end. 52 | # These get unpacked by the Config class in staleness_test_lib.py. 53 | file_list = outs + [generated_pattern, native.package_name() or ".", name] 54 | 55 | native.genrule( 56 | name = name + "_makescript", 57 | outs = [script_name], 58 | srcs = [script_src], 59 | testonly = 1, 60 | cmd = "cat $(location " + script_src + ") > $@; " + 61 | "sed -i.bak -e 's|INSERT_FILE_LIST_HERE|" + "\\\n ".join(file_list) + "|' $@", 62 | ) 63 | 64 | native.py_test( 65 | name = name, 66 | srcs = [script_name], 67 | data = existing_outs + [generated_pattern % file for file in outs], 68 | python_version = "PY3", 69 | deps = [ 70 | ":staleness_test_lib", 71 | ], 72 | **kwargs 73 | ) 74 | -------------------------------------------------------------------------------- /test/pprof_pb.rb: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # source: pprof.proto 3 | 4 | require "google/protobuf" 5 | 6 | Google::Protobuf::DescriptorPool.generated_pool.build do 7 | add_file("pprof.proto", syntax: :proto3) do 8 | add_message "perftools.profiles.Profile" do 9 | repeated :sample_type, :message, 1, "perftools.profiles.ValueType" 10 | repeated :sample, :message, 2, "perftools.profiles.Sample" 11 | repeated :mapping, :message, 3, "perftools.profiles.Mapping" 12 | repeated :location, :message, 4, "perftools.profiles.Location" 13 | repeated :function, :message, 5, "perftools.profiles.Function" 14 | repeated :string_table, :string, 6 15 | optional :drop_frames, :int64, 7 16 | optional :keep_frames, :int64, 8 17 | optional :time_nanos, :int64, 9 18 | optional :duration_nanos, :int64, 10 19 | optional :period_type, :message, 11, "perftools.profiles.ValueType" 20 | optional :period, :int64, 12 21 | repeated :comment, :int64, 13 22 | optional :default_sample_type, :int64, 14 23 | end 24 | add_message "perftools.profiles.ValueType" do 25 | optional :type, :int64, 1 26 | optional :unit, :int64, 2 27 | end 28 | add_message "perftools.profiles.Sample" do 29 | repeated :location_id, :uint64, 1 30 | repeated :value, :int64, 2 31 | repeated :label, :message, 3, "perftools.profiles.Label" 32 | end 33 | add_message "perftools.profiles.Label" do 34 | optional :key, :int64, 1 35 | optional :str, :int64, 2 36 | optional :num, :int64, 3 37 | optional :num_unit, :int64, 4 38 | end 39 | add_message "perftools.profiles.Mapping" do 40 | optional :id, :uint64, 1 41 | optional :memory_start, :uint64, 2 42 | optional :memory_limit, :uint64, 3 43 | optional :file_offset, :uint64, 4 44 | optional :filename, :int64, 5 45 | optional :build_id, :int64, 6 46 | optional :has_functions, :bool, 7 47 | optional :has_filenames, :bool, 8 48 | optional :has_line_numbers, :bool, 9 49 | optional :has_inline_frames, :bool, 10 50 | end 51 | add_message "perftools.profiles.Location" do 52 | optional :id, :uint64, 1 53 | optional :mapping_id, :uint64, 2 54 | optional :address, :uint64, 3 55 | repeated :line, :message, 4, "perftools.profiles.Line" 56 | optional :is_folded, :bool, 5 57 | end 58 | add_message "perftools.profiles.Line" do 59 | optional :function_id, :uint64, 1 60 | optional :line, :int64, 2 61 | end 62 | add_message "perftools.profiles.Function" do 63 | optional :id, :uint64, 1 64 | optional :name, :int64, 2 65 | optional :system_name, :int64, 3 66 | optional :filename, :int64, 4 67 | optional :start_line, :int64, 5 68 | end 69 | end 70 | end 71 | 72 | module Perftools 73 | module Profiles 74 | Profile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Profile").msgclass 75 | ValueType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.ValueType").msgclass 76 | Sample = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Sample").msgclass 77 | Label = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Label").msgclass 78 | Mapping = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Mapping").msgclass 79 | Location = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Location").msgclass 80 | Line = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Line").msgclass 81 | Function = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("perftools.profiles.Function").msgclass 82 | end 83 | end 84 | --------------------------------------------------------------------------------