├── .github ├── scripts │ ├── dcperf_install_django.bash │ ├── dcperf_install_feedsim.bash │ ├── setup_env.bash │ ├── utils_base.bash │ ├── utils_build.bash │ ├── utils_conda.bash │ └── utils_system.bash └── workflows │ ├── dcperf_ci_django.yml │ └── dcperf_ci_feedsim.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── benchpress ├── __init__.py ├── cli │ ├── __init__.py │ ├── commands │ │ ├── __init__.py │ │ ├── clean.py │ │ ├── command.py │ │ ├── info.py │ │ ├── install.py │ │ ├── list.py │ │ ├── report.py │ │ ├── run.py │ │ └── system_check.py │ └── main.py ├── config │ ├── __init__.py │ ├── benchmarks.yml │ ├── benchmarks_wdl.yml │ ├── jobs.yml │ ├── jobs_wdl.yml │ └── toolchain.yml ├── lib │ ├── __init__.py │ ├── baseline.py │ ├── dmidecode.py │ ├── factory.py │ ├── history.py │ ├── hook.py │ ├── hook_factory.py │ ├── job.py │ ├── job_listing.py │ ├── parser.py │ ├── parser_factory.py │ ├── reporter.py │ ├── reporter_factory.py │ ├── sys_specs.py │ └── util.py ├── logging_config.py ├── plugins │ ├── __init__.py │ ├── hooks │ │ ├── __init__.py │ │ ├── copy.py │ │ ├── cpu_limit.py │ │ ├── cpu_mpstat.py │ │ ├── emon.py │ │ ├── fb_stop_dynologd.py │ │ ├── file.py │ │ ├── perf.py │ │ ├── perf_monitors │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── cpufreq_cpuinfo.py │ │ │ ├── cpufreq_scaling.py │ │ │ ├── memstat.py │ │ │ ├── mpstat.py │ │ │ ├── netstat.py │ │ │ ├── perfstat.py │ │ │ ├── power.py │ │ │ └── topdown.py │ │ ├── result.py │ │ ├── shell.py │ │ ├── tao_instruction.py │ │ ├── toplev.py │ │ └── user_script.py │ └── parsers │ │ ├── __init__.py │ │ ├── benchdnn.py │ │ ├── cachebench.py │ │ ├── checkmark.py │ │ ├── clang.py │ │ ├── cloudsuite_graph.py │ │ ├── compression_parser.py │ │ ├── django_workload.py │ │ ├── encryption.py │ │ ├── fb_fiosynth.py │ │ ├── fbgemm.py │ │ ├── feedsim.py │ │ ├── feedsim_autoscale.py │ │ ├── ffmpeg.py │ │ ├── fio.py │ │ ├── gapbs.py │ │ ├── generic.py │ │ ├── graph500.py │ │ ├── health_check.py │ │ ├── iperf.py │ │ ├── ltp.py │ │ ├── mediawiki.py │ │ ├── memcached_bench.py │ │ ├── minebench.py │ │ ├── mlc.py │ │ ├── multichase_fairness.py │ │ ├── multichase_pingpong.py │ │ ├── multichase_pointer.py │ │ ├── nginx_wrk_bench.py │ │ ├── nnpi_net4.py │ │ ├── returncode.py │ │ ├── schbench.py │ │ ├── sigrid.py │ │ ├── silo.py │ │ ├── small_locks_bench.py │ │ ├── spark_standalone.py │ │ ├── spec_cpu2006.py │ │ ├── stream.py │ │ ├── tailbench.py │ │ ├── tao_bench.py │ │ ├── tao_bench_autoscale.py │ │ └── wdl.py └── version.py ├── benchpress_cli.py ├── packages ├── common │ ├── affinitize │ │ ├── affinitize_nic.py │ │ ├── affinitize_nic_lib.py │ │ └── lib │ │ │ └── schedule_lib.py │ ├── certs.tar.gz │ ├── find_java_home.py │ └── os-distro.sh ├── django_workload │ ├── README.md │ ├── alternative_install_django_workload_aws.sh │ ├── cleanup_django_workload.sh │ ├── install_django_workload.sh │ ├── install_django_workload_aarch64.sh │ ├── install_django_workload_aarch64_ubuntu22.sh │ ├── install_django_workload_x86_64_centos9.sh │ ├── install_django_workload_x86_64_ubuntu22.sh │ ├── install_siege.sh │ └── templates │ │ ├── 0002-Memcache-Tuning.patch │ │ ├── 0003-bundle_tray_caching.patch │ │ ├── 0004-del_dup_middleware_classes.patch │ │ ├── 0005-django_middleware_settings.patch │ │ ├── bundle_tray.template │ │ ├── cassandra │ │ ├── cassandra-env.patch │ │ ├── cassandra.yaml │ │ ├── cluster_settings.py │ │ ├── django_genurl.patch │ │ ├── django_libib.patch │ │ ├── django_mlp.patch │ │ ├── feed_timeline.template │ │ ├── gen-urls-file.patch │ │ ├── gen_icache_buster.py │ │ ├── ib.py │ │ ├── inbox.template │ │ ├── jvm-server.options │ │ ├── jvm.options │ │ ├── jvm_options.patch │ │ ├── run-siege │ │ ├── run.sh │ │ ├── seen.template │ │ ├── siege.conf │ │ ├── timeline.template │ │ ├── urls.patch │ │ ├── urls_template.txt │ │ ├── uwsgi.ini │ │ └── views.template ├── feedsim │ ├── README.md │ ├── alternative_install_feedsim_aws.sh │ ├── cleanup_feedsim.sh │ ├── install_feedsim.sh │ ├── install_feedsim_aarch64.sh │ ├── install_feedsim_aarch64_ubuntu.sh │ ├── install_feedsim_x86_64_ubuntu.sh │ ├── patches │ │ ├── centos-9-compatibility │ │ │ ├── folly.diff │ │ │ ├── rsocket-cpp.diff │ │ │ └── wangle.diff │ │ └── ubuntu-22-compatibility │ │ │ ├── folly.diff │ │ │ ├── rsocket-cpp.diff │ │ │ └── wangle.diff │ ├── run-feedsim-multi.sh │ ├── run.sh │ ├── submodules.txt │ └── third_party │ │ └── src │ │ ├── .gitignore │ │ ├── CMake │ │ ├── FindCereal.cmake │ │ ├── FindDoubleConversion.cmake │ │ ├── FindLZ4.cmake │ │ ├── FindLibEvent.cmake │ │ ├── FindLibIberty.cmake │ │ ├── FindSnappy.cmake │ │ ├── FindThrift.cmake │ │ ├── FindZstd.cmake │ │ ├── build-config.cmake │ │ ├── build-fbthrift.cmake │ │ ├── build-fizz.cmake │ │ ├── build-fmt.cmake │ │ ├── build-folly.cmake │ │ ├── build-rsocket.cmake │ │ └── build-wangle.cmake │ │ ├── CMakeLists.txt │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── oldisim │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── oldisim │ │ │ │ ├── Callbacks.h │ │ │ │ ├── ChildConnection.h │ │ │ │ ├── ChildConnectionStats.h │ │ │ │ ├── DriverNode.h │ │ │ │ ├── FanoutManager.h │ │ │ │ ├── LeafNodeServer.h │ │ │ │ ├── LeafNodeStats.h │ │ │ │ ├── Log.h │ │ │ │ ├── LogHistogramSampler.h │ │ │ │ ├── NodeThread.h │ │ │ │ ├── ParentConnection.h │ │ │ │ ├── ParentNodeServer.h │ │ │ │ ├── Query.h │ │ │ │ ├── QueryContext.h │ │ │ │ ├── Response.h │ │ │ │ ├── ResponseContext.h │ │ │ │ ├── TestDriver.h │ │ │ │ └── Util.h │ │ └── src │ │ │ ├── AutoSnapshot.h │ │ │ ├── CerealMapAsJSObject.h │ │ │ ├── ChildConnection.cc │ │ │ ├── ChildConnectionImpl.h │ │ │ ├── ConnectionUtil.cc │ │ │ ├── ConnectionUtil.h │ │ │ ├── DriverNode.cc │ │ │ ├── FanoutManager.cc │ │ │ ├── FanoutManagerImpl.h │ │ │ ├── ForcedEvTimer.h │ │ │ ├── InternalCallbacks.h │ │ │ ├── LeafNodeServer.cc │ │ │ ├── Log.cc │ │ │ ├── NodeThread.cc │ │ │ ├── NodeThreadImpl.h │ │ │ ├── ParentConnection.cc │ │ │ ├── ParentConnectionImpl.cc │ │ │ ├── ParentConnectionImpl.h │ │ │ ├── ParentNodeServer.cc │ │ │ ├── QueryContext.cc │ │ │ ├── ResponseContext.cc │ │ │ ├── TestDriver.cc │ │ │ └── TestDriverImpl.h │ │ ├── patches │ │ ├── 0001-Inline-util-functions-to-make-it-linkable.patch │ │ └── 0002-gapbs-Add-dummy-PageRank-class-for-passing-parameter.patch │ │ ├── scripts │ │ ├── build.sh │ │ ├── install_centos8_deps.sh │ │ ├── search_qps.sh │ │ └── start_leaf_node_rank.sh │ │ ├── third_party │ │ └── CMakeLists.txt │ │ └── workloads │ │ ├── CMakeLists.txt │ │ ├── ranking │ │ ├── CMakeLists.txt │ │ ├── DriverNodeRank.cc │ │ ├── DriverNodeRankCmdline.ggo │ │ ├── LeafNodeRank.cc │ │ ├── LeafNodeRankCmdline.ggo │ │ ├── ParentNodeRank.cc │ │ ├── ParentNodeRankCmdline.ggo │ │ ├── RequestTypes.h │ │ ├── TimekeeperPool.cpp │ │ ├── TimekeeperPool.h │ │ ├── dwarfs │ │ │ ├── pagerank.cpp │ │ │ └── pagerank.h │ │ ├── gen-cpp │ │ │ ├── ranking_constants.cpp │ │ │ ├── ranking_constants.h │ │ │ ├── ranking_types.cpp │ │ │ └── ranking_types.h │ │ ├── generators │ │ │ └── RankingGenerators.h │ │ ├── if │ │ │ ├── CMakeLists.txt │ │ │ ├── gen-cpp2 │ │ │ │ ├── ranking_constants.cpp │ │ │ │ ├── ranking_constants.h │ │ │ │ ├── ranking_data.cpp │ │ │ │ ├── ranking_data.h │ │ │ │ ├── ranking_types.cpp │ │ │ │ ├── ranking_types.h │ │ │ │ ├── ranking_types.tcc │ │ │ │ └── ranking_types_custom_protocol.h │ │ │ └── ranking.thrift │ │ └── utils.h │ │ ├── search │ │ ├── CMakeLists.txt │ │ ├── DriverNode.cc │ │ ├── DriverNodeCmdline.ggo │ │ ├── HistogramRandomSampler.cc │ │ ├── HistogramRandomSampler.h │ │ ├── ICacheBusterTest.cc │ │ ├── ICacheBusterTestCmdline.ggo │ │ ├── LeafKernel.cc │ │ ├── LeafNode.cc │ │ ├── LeafNodeCmdline.ggo │ │ ├── LoadBalancerNode.cc │ │ ├── LoadBalancerNodeCmdline.ggo │ │ ├── NopLoop.cc │ │ ├── ParentNode.cc │ │ ├── ParentNodeCmdline.ggo │ │ ├── PointerChase.cc │ │ ├── PointerChase.h │ │ ├── PointerChaseTest.cc │ │ ├── PointerChaseTestCmdline.ggo │ │ ├── RequestTypes.h │ │ ├── Util.h │ │ └── gen_icache_buster.py │ │ └── simple │ │ ├── CMakeLists.txt │ │ ├── DriverNodeTestFramework.cc │ │ ├── DriverNodeTestFrameworkCmdline.ggo │ │ ├── LeafNodeTestFramework.cc │ │ └── ParentNodeTestFramework.cc ├── health_check │ ├── README.md │ ├── cleanup_health_check.sh │ ├── collect-cpu-util.py │ ├── install_health_check.sh │ ├── run.sh │ └── sleepbench.cpp ├── mediawiki │ ├── 0001-oss-performance-scalable-hhvm.diff │ ├── 0002-memcached-centos9-compat.diff │ ├── 0003-memcached-signal.diff │ ├── 0004-wrk.diff │ ├── BUILD_HHVM_3.30.md │ ├── README.md │ ├── Wrk.php │ ├── WrkStats.php │ ├── alternative_install_mediawiki_aws.sh │ ├── alternative_install_mediawiki_intern.sh │ ├── cleanup_oss_performance_mediawiki.sh │ ├── grant_privileges.sql │ ├── install_oss_performance_mediawiki.sh │ ├── multi-request-txt.lua │ ├── my.cnf │ ├── nginx.repo │ ├── perf-record.sh │ ├── run.sh │ ├── siege.conf │ └── update_mariadb_pwd.sql ├── spark_standalone │ ├── README.md │ ├── cleanup_spark_standalone.sh │ ├── install_spark_standalone.sh │ └── templates │ │ ├── fetch_dataset.py │ │ ├── nvme_tcp │ │ ├── setup_nvmet.py │ │ └── utils.py │ │ ├── proj_root │ │ ├── scripts │ │ │ ├── config_spark.py │ │ │ ├── run_perf_common.py │ │ │ └── utils.py │ │ └── settings │ │ │ ├── metrics.properties │ │ │ ├── spark-env-template.sh │ │ │ └── start-slave-fb.sh │ │ └── runner.py ├── tao_bench │ ├── 0001-tao_bench_memcached.diff │ ├── 0002-tao_bench_memcached_oom_handling.diff │ ├── 0003-tao_bench_thread_pool_naming.diff │ ├── 0004-tao_bench_memcached_1.6.21.diff │ ├── 0005-tao_bench_client_memtier_20230615.diff │ ├── 0006-tao_bench_slow_thread_use_semaphore.diff │ ├── 0007-tao_bench_smart_nanosleep.diff │ ├── 0008-tao_bench_count_nanosleeps.diff │ ├── README.md │ ├── alternative_install_tao_bench_aws.sh │ ├── args_utils.py │ ├── cleanup_tao_bench.sh │ ├── db_items.json │ ├── install_tao_bench.sh │ ├── install_tao_bench_aarch64.sh │ ├── install_tao_bench_x86_64.sh │ ├── leader_sizes.json │ ├── parser.py │ ├── run.py │ ├── run_autoscale.py │ ├── run_standalone.py │ └── tao_bench ├── video_transcode_bench │ ├── 0001-ffmpeg.patch │ ├── 0002-ffmpeg.patch │ ├── README.md │ ├── cleanup_video_transcode_bench.sh │ ├── install_video_transcode_bench.sh │ └── run.sh └── wdl_bench │ ├── 0001-folly.patch │ ├── README.md │ ├── aggregate_result.py │ ├── cleanup_wdl_bench.sh │ ├── convert.py │ ├── install_wdl_bench.sh │ ├── parse_line.py │ └── run.sh └── perfutils ├── README.md ├── collect_amd_perf_counters.sh ├── collect_amd_zen4_perf_counters.sh ├── collect_amd_zen5_perf_counters.sh ├── collect_nvda_neoversev2_perf_counters.sh ├── generate_amd_perf_report.py └── generate_arm_perf_report.py /.github/scripts/dcperf_install_django.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # All rights reserved. 4 | # 5 | # This source code is licensed under the BSD-style license found in the 6 | # LICENSE file in the root directory of this source tree. 7 | 8 | 9 | # shellcheck disable=SC1091,SC2128 10 | . "$( dirname -- "$BASH_SOURCE"; )/utils_base.bash" 11 | 12 | 13 | ################################################################################ 14 | # Django Install Functions 15 | ################################################################################ 16 | 17 | install_django () { 18 | local env_name="$1" 19 | if [ "$env_name" == "" ]; then 20 | echo "Usage: ${FUNCNAME[0]} ENV_NAME" 21 | echo "Example(s):" 22 | echo " ${FUNCNAME[0]} build_env" 23 | return 1 24 | else 25 | echo "################################################################################" 26 | echo "# Install Django" 27 | echo "#" 28 | echo "# [$(date --utc +%FT%T.%3NZ)] + ${FUNCNAME[0]} ${*}" 29 | echo "################################################################################" 30 | echo "" 31 | fi 32 | 33 | echo "[TEST] TODO: Implement This!" 34 | } 35 | -------------------------------------------------------------------------------- /.github/scripts/dcperf_install_feedsim.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # All rights reserved. 4 | # 5 | # This source code is licensed under the BSD-style license found in the 6 | # LICENSE file in the root directory of this source tree. 7 | 8 | 9 | # shellcheck disable=SC1091,SC2128 10 | . "$( dirname -- "$BASH_SOURCE"; )/utils_base.bash" 11 | 12 | 13 | ################################################################################ 14 | # Install FeedSim 15 | ################################################################################ 16 | 17 | install_feedsim () { 18 | local env_name="$1" 19 | if [ "$env_name" == "" ]; then 20 | echo "Usage: ${FUNCNAME[0]} ENV_NAME" 21 | echo "Example(s):" 22 | echo " ${FUNCNAME[0]} build_env" 23 | return 1 24 | else 25 | echo "################################################################################" 26 | echo "# Install FeedSim" 27 | echo "#" 28 | echo "# [$(date --utc +%FT%T.%3NZ)] + ${FUNCNAME[0]} ${*}" 29 | echo "################################################################################" 30 | echo "" 31 | fi 32 | 33 | # shellcheck disable=SC2155 34 | local env_prefix=$(env_name_or_prefix "${env_name}") 35 | 36 | echo "[INSTALL] Installing FeedSim ..." 37 | (print_exec conda run --no-capture-output ${env_prefix} \ 38 | python ./benchpress_cli.py install feedsim_autoscale) || return 1 39 | } 40 | -------------------------------------------------------------------------------- /.github/scripts/setup_env.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # All rights reserved. 4 | # 5 | # This source code is licensed under the BSD-style license found in the 6 | # LICENSE file in the root directory of this source tree. 7 | 8 | # shellcheck disable=SC1091,SC2128 9 | . "$( dirname -- "$BASH_SOURCE"; )/utils_base.bash" 10 | # shellcheck disable=SC1091,SC2128 11 | . "$( dirname -- "$BASH_SOURCE"; )/utils_system.bash" 12 | # shellcheck disable=SC1091,SC2128 13 | . "$( dirname -- "$BASH_SOURCE"; )/utils_build.bash" 14 | # shellcheck disable=SC1091,SC2128 15 | . "$( dirname -- "$BASH_SOURCE"; )/utils_conda.bash" 16 | # shellcheck disable=SC1091,SC2128 17 | . "$( dirname -- "$BASH_SOURCE"; )/dcperf_install_django.bash" 18 | # shellcheck disable=SC1091,SC2128 19 | . "$( dirname -- "$BASH_SOURCE"; )/dcperf_install_feedsim.bash" 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # benchmark output 2 | results/ 3 | 4 | # benchmarks binaries 5 | benchmarks/ 6 | 7 | # Byte-compiled / optimized / DLL files 8 | __pycache__/ 9 | *.py[cod] 10 | *$py.class 11 | 12 | # C extensions 13 | *.so 14 | 15 | # Distribution / packaging 16 | .Python 17 | build/ 18 | develop-eggs/ 19 | dist/ 20 | downloads/ 21 | eggs/ 22 | .eggs/ 23 | lib64/ 24 | parts/ 25 | sdist/ 26 | var/ 27 | wheels/ 28 | *.egg-info/ 29 | .installed.cfg 30 | *.egg 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .coverage 46 | .coverage.* 47 | .cache 48 | nosetests.xml 49 | coverage.xml 50 | *.cover 51 | .hypothesis/ 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # Environments 87 | .env 88 | .venv 89 | env/ 90 | venv/ 91 | ENV/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to DCPerf 2 | We want to make contributing to this project as easy and transparent as 3 | possible. 4 | 5 | ## Pull Requests 6 | We actively welcome your pull requests. 7 | 8 | 1. Fork the repo and create your branch from `v2-beta`. If your PR is about bug fix, please use `main`. 9 | 2. If you've added code that should be tested, add tests. 10 | 3. If you've changed APIs, update the documentation. 11 | 4. Ensure the test suite passes. 12 | 5. Make sure your code lints. 13 | 6. If you haven't already, complete the Contributor License Agreement ("CLA"). 14 | 15 | ## Contributor License Agreement ("CLA") 16 | In order to accept your pull request, we need you to submit a CLA. You only need 17 | to do this once to work on any of Facebook's open source projects. 18 | 19 | Complete your CLA here: 20 | 21 | ## Issues 22 | We use GitHub issues to track public bugs. Please ensure your description is 23 | clear and has sufficient instructions to be able to reproduce the issue. 24 | 25 | Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe 26 | disclosure of security bugs. In those cases, please go through the process 27 | outlined on that page and do not file a public issue. 28 | 29 | ## License 30 | By contributing to DCPerf, you agree that your contributions will be licensed 31 | under the LICENSE file in the root directory of this source tree. 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Facebook, Inc. and its affiliates. 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 | -------------------------------------------------------------------------------- /benchpress/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | from .version import __PROJECT__, __VERSION__ 7 | 8 | PROJECT = __PROJECT__ 9 | VERSION = __VERSION__ 10 | 11 | is_opensource = True 12 | -------------------------------------------------------------------------------- /benchpress/cli/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | -------------------------------------------------------------------------------- /benchpress/cli/commands/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # pyre-unsafe 7 | -------------------------------------------------------------------------------- /benchpress/cli/commands/clean.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import logging 10 | 11 | import click 12 | from benchpress.lib.job import get_target_jobs 13 | from benchpress.lib.util import clean_benchmark, clean_tool 14 | 15 | from .command import BenchpressCommand 16 | 17 | 18 | logger = logging.getLogger(__name__) 19 | 20 | 21 | class CleanCommand(BenchpressCommand): 22 | def populate_parser(self, subparsers): 23 | parser = subparsers.add_parser("clean", help="remove benchmark dependencies") 24 | parser.set_defaults(command=self) 25 | parser.add_argument("jobs", nargs="*", default=[], help="jobs to clean") 26 | 27 | def run(self, args, jobs): 28 | jobs = get_target_jobs(jobs, args.jobs) 29 | 30 | for job in jobs.values(): 31 | # Clean out benchmark dependencies regardless if it's installed or not 32 | if job.cleanup_script != "": 33 | clean_benchmark(job.cleanup_script, job.install_script) 34 | click.echo("Cleaning out dependencies of {} job".format(job.name)) 35 | else: 36 | click.echo( 37 | f"Job {job.name} doesn't have a cleanup script in the jobs.yml file" 38 | ) 39 | # install associated tools 40 | for hook in job.hooks: 41 | if clean_tool(hook[0]) > 0: 42 | click.echo( 43 | "Cleaning out associated tool {} for {}".format( 44 | hook[0], job.name 45 | ) 46 | ) 47 | -------------------------------------------------------------------------------- /benchpress/cli/commands/command.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from abc import ABCMeta, abstractmethod 10 | 11 | # Defines how the table is styled 12 | TABLE_FORMAT = "plain" 13 | 14 | 15 | class BenchpressCommand(object, metaclass=ABCMeta): 16 | @abstractmethod 17 | def populate_parser(self, parser): 18 | pass 19 | 20 | @abstractmethod 21 | def run(self, args, jobs): 22 | pass 23 | -------------------------------------------------------------------------------- /benchpress/cli/commands/list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import click 10 | from benchpress.lib.job_listing import create_job_listing 11 | 12 | from .command import BenchpressCommand, TABLE_FORMAT 13 | 14 | 15 | class ListCommand(BenchpressCommand): 16 | def populate_parser(self, subparsers): 17 | parser = subparsers.add_parser("list", help="list all configured jobs") 18 | parser.set_defaults(command=self) 19 | parser.add_argument( 20 | "-s", 21 | "--by-scope", 22 | action="store_true", 23 | help="list benchmarks by scope, i.e. app, micro, kernel", 24 | ) 25 | parser.add_argument( 26 | "-c", 27 | "--by-component", 28 | action="store_true", 29 | help="list benchmarks by components being tested", 30 | ) 31 | 32 | def run(self, args, jobs): 33 | if args.by_scope: 34 | group_key = "scope" 35 | elif args.by_component: 36 | group_key = "component" 37 | else: 38 | group_key = None 39 | 40 | job_list = [] 41 | for job in jobs.values(): 42 | if not hasattr(job, "config"): 43 | continue 44 | item = { 45 | "name": job.name, 46 | "description": job.description, 47 | "tags": job.tags, 48 | } 49 | job_list.append(item) 50 | click.echo(create_job_listing(job_list, TABLE_FORMAT, group_key)) 51 | -------------------------------------------------------------------------------- /benchpress/config/benchmarks_wdl.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | wdl_bench: 7 | parser: wdl_bench 8 | install_script: ./packages/wdl_bench/install_wdl_bench.sh 9 | cleanup_script: ./packages/wdl_bench/cleanup_wdl_bench.sh 10 | path: ./benchmarks/wdl_bench/run.sh 11 | tags: 12 | scope: 13 | - app 14 | - folly 15 | - fbthrift 16 | component: 17 | - cpu 18 | metrics: [] 19 | -------------------------------------------------------------------------------- /benchpress/config/toolchain.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | clang: 6 | cc: /usr/bin/clang 7 | cxx: /usr/bin/clang++ 8 | ldflags: 9 | - -fuse-ld=lld 10 | 11 | gcc: 12 | cc: /usr/bin/gcc 13 | cxx: /usr/bin/g++ 14 | -------------------------------------------------------------------------------- /benchpress/lib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | try: 7 | # pyre-ignore[21] 8 | from benchpress import is_opensource # @manual 9 | 10 | open_source = is_opensource 11 | except ImportError: 12 | open_source = False 13 | -------------------------------------------------------------------------------- /benchpress/lib/factory.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | 8 | class BaseFactory: 9 | """Factory to construct instances of classes based on name. 10 | 11 | Attributes: 12 | base_class (class): base class that registered classes must subclass 13 | """ 14 | 15 | def __init__(self, base_class): 16 | """Create a BaseFactory with base_class as the supertype.""" 17 | self.base_class = base_class 18 | self.classes = {} 19 | 20 | @property 21 | def registered_names(self): 22 | """list of str: class names registered with the factory.""" 23 | return list(self.classes.keys()) 24 | 25 | def create(self, name): 26 | """Find the subclass with the correct name and instantiates it. 27 | 28 | Args: 29 | name (str): name of the item 30 | """ 31 | if name not in self.classes: 32 | raise KeyError( 33 | 'No type "{}". ' "Did you forget to register() it?".format(name) 34 | ) 35 | return self.classes[name]() 36 | 37 | def register(self, name, subclass): 38 | """Registers a class with the factory. 39 | 40 | Args: 41 | name (str): name of the class 42 | subclass (class): concrete subclass of base_class 43 | """ 44 | assert issubclass(subclass, self.base_class) 45 | self.classes[name] = subclass 46 | -------------------------------------------------------------------------------- /benchpress/lib/hook.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from abc import ABCMeta, abstractmethod 8 | 9 | 10 | class Hook(object, metaclass=ABCMeta): 11 | """Hook allows jobs to run some Python code before/after a job runs.""" 12 | 13 | @abstractmethod 14 | def before_job(self, opts, job): 15 | """Do something to setup before this job. 16 | 17 | Args: 18 | opts (dict): user-defined options for this hook 19 | """ 20 | 21 | @abstractmethod 22 | def after_job(self, opts, job): 23 | """Do something to teardown after this job. 24 | 25 | Args: 26 | opts (dict): user-defined options for this hook 27 | """ 28 | -------------------------------------------------------------------------------- /benchpress/lib/hook_factory.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from benchpress.plugins.hooks import register_hooks 8 | 9 | from .factory import BaseFactory 10 | from .hook import Hook 11 | 12 | HookFactory = BaseFactory(Hook) 13 | 14 | # register third-party hooks with the factory 15 | register_hooks(HookFactory) 16 | -------------------------------------------------------------------------------- /benchpress/lib/parser.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from abc import ABCMeta, abstractmethod 8 | 9 | 10 | class Parser(object, metaclass=ABCMeta): 11 | """Parser is the link between benchmark output and the rest of the system. 12 | A Parser is given the benchmark's stdout and stderr and returns the exported 13 | metrics. 14 | """ 15 | 16 | @abstractmethod 17 | def parse(self, stdout, stderr, returncode): 18 | """Take stdout/stderr and convert it to a dictionary of metrics. 19 | 20 | Args: 21 | stdout (list of str): stdout of benchmark process split on newline 22 | stderr (list of str): stderr of benchmark process split on newline 23 | returncode (int): subprocess return code 24 | 25 | Returns: 26 | (dict): metrics mapping name -> value - keys can be nested or flat 27 | with dot-separated names 28 | """ 29 | pass 30 | -------------------------------------------------------------------------------- /benchpress/lib/parser_factory.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from benchpress.plugins.parsers import register_parsers 8 | 9 | from .factory import BaseFactory 10 | from .parser import Parser 11 | 12 | ParserFactory = BaseFactory(Parser) 13 | 14 | # register third-party parsers with the factory 15 | register_parsers(ParserFactory) 16 | -------------------------------------------------------------------------------- /benchpress/lib/reporter_factory.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | from .factory import BaseFactory 8 | from .reporter import Reporter 9 | 10 | ReporterFactory = BaseFactory(Reporter) 11 | -------------------------------------------------------------------------------- /benchpress/logging_config.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | import logging 6 | import logging.handlers 7 | import os 8 | 9 | 10 | class ConditionalFormatter(logging.Formatter): 11 | def format(self, record): 12 | if hasattr(record, "raw") and record.raw: 13 | return record.getMessage() 14 | else: 15 | return logging.Formatter.format(self, record) 16 | 17 | 18 | handler = logging.handlers.WatchedFileHandler("benchpress.log") 19 | formatter = ConditionalFormatter( 20 | "[%(asctime)s] %(name)-12s %(levelname)-8s: %(message)s" 21 | ) 22 | handler.setFormatter(formatter) 23 | 24 | stream_handler = logging.StreamHandler() 25 | stream_handler.setLevel(logging.WARNING) 26 | 27 | 28 | def create_logger(): 29 | root = logging.getLogger() 30 | root.setLevel(os.environ.get("LOGLEVEL", "INFO")) 31 | root.addHandler(handler) 32 | root.addHandler(stream_handler) 33 | return root 34 | -------------------------------------------------------------------------------- /benchpress/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | -------------------------------------------------------------------------------- /benchpress/plugins/hooks/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from benchpress.lib import open_source 10 | 11 | from .copy import CopyMoveHook 12 | from .cpu_limit import CpuLimit 13 | from .cpu_mpstat import CpuMpstat 14 | from .emon import Emon 15 | from .file import FileHook 16 | from .perf import Perf 17 | from .result import ResultHook 18 | from .shell import ShellHook 19 | from .tao_instruction import TaoInstructionHook 20 | from .toplev import Toplev 21 | from .user_script import UserScript 22 | 23 | if not open_source: 24 | from .fb_chef_off import FBChefOff 25 | from .fb_chef_off_turbo_on import FBChefOffTurboOn 26 | from .fb_stop_dynologd import FBStopDynologd 27 | from .fb_turbo_driver import FBTurboDriver 28 | 29 | 30 | def register_hooks(factory): 31 | factory.register("copymove", CopyMoveHook) 32 | factory.register("cpu-limit", CpuLimit) 33 | factory.register("cpu-mpstat", CpuMpstat) 34 | factory.register("emon", Emon) 35 | factory.register("file", FileHook) 36 | factory.register("perf", Perf) 37 | factory.register("result", ResultHook) 38 | factory.register("shell", ShellHook) 39 | factory.register("tao_instruction", TaoInstructionHook) 40 | factory.register("toplev", Toplev) 41 | factory.register("user-script", UserScript) 42 | 43 | if not open_source: 44 | factory.register("fb_chef_off", FBChefOff) 45 | factory.register("fb_chef_off_turbo_on", FBChefOffTurboOn) 46 | factory.register("fb_turbo_driver", FBTurboDriver) 47 | factory.register("fb_stop_dynologd", FBStopDynologd) 48 | -------------------------------------------------------------------------------- /benchpress/plugins/hooks/cpu_limit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import logging 10 | 11 | from benchpress.lib.hook import Hook 12 | 13 | logger = logging.getLogger(__name__) 14 | 15 | 16 | class CpuLimit(Hook): 17 | """CpuLimit hook allows you to limit the benchmark to a set of CPUs using 18 | `taskset`. The only option is a hex string bitmask that is the CPU mask 19 | passed to `taskset`, for each bit, if there is a 1 the CPU is enabled for 20 | the benchmark process, otherwise it's disabled. 21 | """ 22 | 23 | def before_job(self, opts, job): 24 | mask = str(opts) 25 | # try to parse the mask as a hex string as a basic sanity check 26 | try: 27 | int(mask, 16) 28 | except ValueError: 29 | raise ValueError("{} is not a valid CPU mask".format(mask)) 30 | 31 | # modify the job config to run taskset with the given mask instead of 32 | # directly running the benchmark binary 33 | binary_str = job.binary 34 | job.args = [mask, binary_str] + job.args 35 | job.binary = "taskset" 36 | 37 | def after_job(self, opts, job): 38 | pass 39 | -------------------------------------------------------------------------------- /benchpress/plugins/hooks/fb_stop_dynologd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) 2017-present, Facebook, Inc. 3 | # All rights reserved. 4 | # 5 | # This source code is licensed under the BSD-style license found in the 6 | # LICENSE file in the root directory of this source tree. An additional grant 7 | # of patent rights can be found in the PATENTS file in the same directory. 8 | 9 | # pyre-unsafe 10 | 11 | import logging 12 | import subprocess 13 | 14 | from benchpress.lib.hook import Hook 15 | 16 | 17 | logger = logging.getLogger(__name__) 18 | 19 | 20 | class FBStopDynologd(Hook): 21 | """ 22 | FBStopDynologd is a Facebook infrastructure specific hook that 23 | temporarily stops Dynolog. This is useful 24 | """ 25 | 26 | def exec_cmd(self, cmd): 27 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 28 | try: 29 | outs, errs = proc.communicate(timeout=60) 30 | except subprocess.TimeoutExpired: 31 | proc.kill() 32 | outs, errs = proc.communicate() 33 | logger.debug(outs) 34 | logger.debug(errs) 35 | 36 | def before_job(self, opts, job): 37 | """ 38 | Stop dynologd service 39 | """ 40 | cmd = [ 41 | "/usr/bin/systemctl", 42 | "stop", 43 | "dynologd.service", 44 | ] 45 | logger.info("Stopping dynologd service") 46 | self.exec_cmd(cmd) 47 | 48 | def after_job(self, opts, job): 49 | """ 50 | Start dynologd service after the job is done 51 | """ 52 | cmd = [ 53 | "/usr/bin/systemctl", 54 | "start", 55 | "dynologd.service", 56 | ] 57 | logger.info("Starting dynologd service") 58 | self.exec_cmd(cmd) 59 | -------------------------------------------------------------------------------- /benchpress/plugins/hooks/file.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import errno 10 | import logging 11 | import os 12 | import shutil 13 | 14 | from benchpress.lib.hook import Hook 15 | 16 | logger = logging.getLogger(__name__) 17 | 18 | 19 | class FileHook(Hook): 20 | """FileHook provides the ability to create and delete files/directories. 21 | Options are specified as a list of dictionaries - each dictionary must have 22 | a 'type' and a 'path', 'type' is either 'dir' or 'file', and path is where 23 | it will live on the filesystem. Files/directories are created before the 24 | job runs and destroyed after. 25 | """ 26 | 27 | def before_job(self, opts, job): 28 | for opt in opts: 29 | path = opt["path"] 30 | logger.info('Creating "{}"'.format(path)) 31 | if opt["type"] == "dir": 32 | try: 33 | os.makedirs(path) 34 | except OSError as e: 35 | if e.errno == errno.EEXIST: 36 | logger.warning( 37 | '"{}" already exists, proceeding anyway'.format(path) 38 | ) 39 | else: 40 | # other errors should be fatal 41 | raise 42 | if opt["type"] == "file": 43 | os.mknod(path) 44 | 45 | def after_job(self, opts, job): 46 | for opt in opts: 47 | path = opt["path"] 48 | logger.info('Deleting "{}"'.format(path)) 49 | if opt["type"] == "dir": 50 | shutil.rmtree(path) 51 | if opt["type"] == "file": 52 | os.unlink(path) 53 | -------------------------------------------------------------------------------- /benchpress/plugins/hooks/perf_monitors/cpufreq_cpuinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import os 10 | import threading 11 | import time 12 | 13 | from . import logger, Monitor 14 | 15 | 16 | class CPUFreq(Monitor): 17 | def __init__(self, interval, job_uuid): 18 | super(CPUFreq, self).__init__(interval, "cpufreq_cpuinfo", job_uuid) 19 | self.run_freq_collector = False 20 | self.supported = os.path.exists( 21 | "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq" 22 | ) 23 | self.cpus = os.sched_getaffinity(0) 24 | 25 | def do_collect(self): 26 | if not self.supported: 27 | return 28 | freqs = [] 29 | for cpu in self.cpus: 30 | with open( 31 | f"/sys/devices/system/cpu/cpu{cpu}/cpufreq/cpuinfo_cur_freq", "r" 32 | ) as f: 33 | freqs.append(float(f.read())) 34 | 35 | avg_freq_mhz = sum(freqs) / len(freqs) / 1000 36 | self.res.append( 37 | {"timestamp": time.strftime("%I:%M:%S %p"), "cpufreq_mhz": avg_freq_mhz} 38 | ) 39 | 40 | def collector(self): 41 | while self.supported and self.run_freq_collector: 42 | try: 43 | self.do_collect() 44 | except ValueError: 45 | pass 46 | time.sleep(self.interval) 47 | 48 | def run(self): 49 | if not self.supported: 50 | logger.warning( 51 | "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq is " 52 | + "not found, therefore we cannot monitor CPU frequency" 53 | ) 54 | self.run_freq_collector = True 55 | self.proc = threading.Thread( 56 | target=self.collector, name="cpufreq_cpuinfo", args=() 57 | ) 58 | self.proc.start() 59 | 60 | def terminate(self): 61 | self.run_freq_collector = False 62 | self.proc.join() 63 | -------------------------------------------------------------------------------- /benchpress/plugins/hooks/perf_monitors/cpufreq_scaling.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import os 10 | import threading 11 | import time 12 | 13 | from . import logger, Monitor 14 | 15 | 16 | class CPUFreq(Monitor): 17 | def __init__(self, interval, job_uuid): 18 | super(CPUFreq, self).__init__(interval, "cpufreq_scaling", job_uuid) 19 | self.run_freq_collector = False 20 | self.supported = os.path.exists( 21 | "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" 22 | ) 23 | self.cpus = os.sched_getaffinity(0) 24 | 25 | def do_collect(self): 26 | if not self.supported: 27 | return 28 | freqs = [] 29 | for cpu in self.cpus: 30 | with open( 31 | f"/sys/devices/system/cpu/cpu{cpu}/cpufreq/scaling_cur_freq", "r" 32 | ) as f: 33 | freqs.append(float(f.read())) 34 | 35 | avg_freq_mhz = sum(freqs) / len(freqs) / 1000 36 | self.res.append( 37 | {"timestamp": time.strftime("%I:%M:%S %p"), "cpufreq_mhz": avg_freq_mhz} 38 | ) 39 | 40 | def collector(self): 41 | while self.supported and self.run_freq_collector: 42 | try: 43 | self.do_collect() 44 | except ValueError: 45 | pass 46 | time.sleep(self.interval) 47 | 48 | def run(self): 49 | if not self.supported: 50 | logger.warning( 51 | "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq is " 52 | + "not found, therefore we cannot monitor CPU frequency" 53 | ) 54 | self.run_freq_collector = True 55 | self.proc = threading.Thread( 56 | target=self.collector, name="cpufreq_scaling", args=() 57 | ) 58 | self.proc.start() 59 | 60 | def terminate(self): 61 | self.run_freq_collector = False 62 | self.proc.join() 63 | -------------------------------------------------------------------------------- /benchpress/plugins/hooks/result.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import logging 10 | import os 11 | import shutil 12 | 13 | from benchpress.lib import util 14 | from benchpress.lib.hook import Hook 15 | 16 | logger = logging.getLogger(__name__) 17 | 18 | 19 | class ResultHook(Hook): 20 | """ResultHook provides the ability to save files into metric folder. 21 | Job name will be added as a prefix. 22 | Options are specified as a list of file paths. 23 | """ 24 | 25 | def before_job(self, opts, job): 26 | self.benchmark_metrics_dir = util.create_benchmark_metrics_dir(job.uuid) 27 | 28 | def after_job(self, opts, job): 29 | for opt in opts: 30 | if os.path.exists(opt): 31 | filename = f"{job.name}_{os.path.basename(opt)}" 32 | dst = os.path.join(self.benchmark_metrics_dir, filename) 33 | shutil.copyfile(opt, dst) 34 | -------------------------------------------------------------------------------- /benchpress/plugins/hooks/tao_instruction.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import logging 10 | import os 11 | import sys 12 | import threading 13 | import time 14 | 15 | from benchpress.lib.hook import Hook 16 | 17 | logger = logging.getLogger(__name__) 18 | 19 | 20 | class TaoInstructionHook(Hook): 21 | """ 22 | Prints the client side instructions generated by tao_bench_autoscale 23 | """ 24 | 25 | def __init__(self): 26 | # Path to directory of benchpress_cli.py 27 | self.basepath = os.path.dirname(os.path.abspath(sys.argv[0])) 28 | 29 | def print_instructions(self): 30 | instruction_path = ( 31 | self.basepath + "/benchmarks/tao_bench/client_instructions.txt" 32 | ) 33 | while self.run_thread: 34 | time.sleep(1) 35 | if os.path.exists(instruction_path): 36 | break 37 | time.sleep(1) 38 | with open(instruction_path, "r") as f: 39 | instruction_text = f.read() 40 | logger.warning(instruction_text) 41 | os.remove(instruction_path) 42 | 43 | def before_job(self, opts, job): 44 | self.run_thread = True 45 | self.thread = threading.Thread( 46 | target=self.print_instructions, name="tao-instrux", args=() 47 | ) 48 | self.thread.start() 49 | 50 | def after_job(self, opts, job): 51 | self.run_thread = False 52 | self.thread.join() 53 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/benchdnn.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | 14 | class BenchdnnParser(Parser): 15 | def parse(self, stdout, stderr, returncode): 16 | metrics = {} 17 | for line in stdout: 18 | if re.search("matmul", line): 19 | results = line.split(",") 20 | param = results[3].replace("--", "") 21 | key1 = param + " Gflops" 22 | key2 = param + " running time(ms)" 23 | metrics[key1] = float(results[-1].strip()) 24 | metrics[key2] = float(results[-2].strip()) 25 | return metrics 26 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/cachebench.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | CACHEBENCH_RAWFORMAT_REGEX = r"([\w\s\()]+):(.*)" 14 | CACHEBENCH_RAWFORMAT_MATCHER = re.compile(CACHEBENCH_RAWFORMAT_REGEX) 15 | 16 | 17 | class CacheBenchParser(Parser): 18 | def parse(self, stdout, stderr, returncode): 19 | metrics = {} 20 | max_read_latency = 0 21 | max_write_latency = 0 22 | for line in stdout: 23 | params = re.findall(CACHEBENCH_RAWFORMAT_MATCHER, line) 24 | if params: 25 | param = params[0] 26 | field = param[0] 27 | field = re.sub(" +", " ", field) 28 | field = field.rstrip(" ") 29 | field = re.sub(" ", "_", field) 30 | items = param[1].split() 31 | value = items[0].rstrip("/s,") 32 | metrics[field] = value 33 | if field.startswith("NVM_Write_Latency"): 34 | temp = float(value) 35 | max_write_latency = ( 36 | max_write_latency if max_write_latency >= temp else temp 37 | ) 38 | elif field.startswith("NVM_Read_Latency"): 39 | temp = float(value) 40 | max_read_latency = ( 41 | max_read_latency if max_read_latency >= temp else temp 42 | ) 43 | metrics["NVM_max_read_latency"] = str(max_read_latency) 44 | metrics["NVM_max_write_latency"] = str(max_write_latency) 45 | 46 | return metrics 47 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/checkmark.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from benchpress.lib.parser import Parser 10 | 11 | # Example output from Checkmark (-q, quiet mode) 12 | # 13 | # ./checkmark -q 14 | # 1,60,0,4096,8388608,60.00,29745911,60919625728,36149.505,495765.175,1.215 15 | # 16 | # The fields are 17 | # 1. threads 18 | # 2. duration 19 | # 3. thinktime 20 | # 4. checksum_size 21 | # 5. chunk_size 22 | # 6. elapsed_time 23 | # 7. chunk_ops 24 | # 8. total_checksums 25 | # 9. checksum_ms 26 | # 10. chunk_rate 27 | # 11. chunk_latency 28 | 29 | 30 | class CheckmarkParser(Parser): 31 | def parse(self, stdout, stderr, returncode): 32 | metrics = { 33 | "threads": 0, 34 | "duration": 0, 35 | "thinktime": 0, 36 | "checksum_size": 0, 37 | "chunk_size": 0, 38 | "elapsed_time": 0.0, 39 | "chunk_ops": 0, 40 | "total_checksums": 0, 41 | "checksum_ms": 0.0, 42 | "chunk_rate": 0.0, 43 | "chunk_latency": 0.0, 44 | } 45 | bench_out = stdout[0].strip().split(",") 46 | assert len(bench_out) == len(metrics) 47 | metrics["threads"] = int(bench_out[0]) 48 | metrics["duration"] = int(bench_out[1]) 49 | metrics["thinktime"] = int(bench_out[2]) 50 | metrics["checksum_size"] = int(bench_out[3]) 51 | metrics["chunk_size"] = int(bench_out[4]) 52 | metrics["elapsed_time"] = float(bench_out[5]) 53 | metrics["chunk_ops"] = int(bench_out[6]) 54 | metrics["total_checksums"] = int(bench_out[7]) 55 | metrics["checksum_ms"] = float(bench_out[8]) 56 | metrics["chunk_rate"] = float(bench_out[9]) 57 | metrics["chunk_latency"] = float(bench_out[10]) 58 | return metrics 59 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/cloudsuite_graph.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from benchpress.lib.parser import Parser 10 | 11 | 12 | class CloudSuiteGraphParser(Parser): 13 | def parse(self, stdout, stderr, returncode): 14 | """Extracts cloudsuite graphics analytics results from stdout.""" 15 | metrics = {} 16 | for line in stdout: 17 | if line.startswith("Total PageRank = "): 18 | metrics["pagerank"] = float(line[17:]) 19 | if line.startswith("Running time = "): 20 | metrics["runtime"] = int(line[15:]) 21 | return metrics 22 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/encryption.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | REGEX_VAL_BEFORE_BS = r" (\d+\.?\d+?)B\/s" 14 | 15 | 16 | class EncryptionParser(Parser): 17 | def parse(self, stdout, stderr, returncode): 18 | metrics = {} 19 | rate = [] 20 | for line in stdout: 21 | speed = re.findall(REGEX_VAL_BEFORE_BS, line) 22 | if len(speed) != 0: 23 | rate.append(float(speed[0]) / 1024 / 1024) 24 | product = 1 25 | for k in rate: 26 | product = product * k 27 | geo_mean = product ** (1 / len(rate)) 28 | metrics["geo_mean for encryption rate (MB/s)"] = geo_mean 29 | return metrics 30 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/fb_fiosynth.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | import csv 9 | import io 10 | import logging 11 | 12 | from benchpress.lib.parser import Parser 13 | 14 | logger = logging.getLogger(__name__) 15 | 16 | 17 | class Fiosynth_Parser(Parser): 18 | """Example output: 19 | CSV file with one header and multiple rows: 20 | Jobname,Read_IOPS,Read_BW,Write_IOPS,...,P99.9999_Trim_Latency 21 | RandomRead_QD001_run1,132.419483,529,0.0,0,7524.119594236,...,0.0 22 | """ 23 | 24 | def parse(self, stdout, stderr, returncode): 25 | """Parses the fb_fiosynth benchmark output to extract key metrics""" 26 | 27 | stdout = "\n".join(stdout) 28 | try: 29 | fiosynth_reader = csv.DictReader(io.StringIO(stdout)) 30 | fiosynth_data = [metrics for metrics in fiosynth_reader] 31 | except Exception as e: 32 | logger.error( 33 | "Error thrown while parsing the fb_fiosynth csv file: {}".format(e) 34 | ) 35 | 36 | return fiosynth_data 37 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/fbgemm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | import logging 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | logger = logging.getLogger(__name__) 14 | 15 | 16 | class FbgemmParser(Parser): 17 | def parse(self, stdout, stderr, returncode): 18 | metrics = {} 19 | for line in stdout: 20 | if re.search("GOPS", line) or len(line) == 0: 21 | continue 22 | parameters = line.split(",") 23 | key = "M, N, K, Type (GOPS): " 24 | for i in range(len(parameters) - 1): 25 | key = key + " " + parameters[i].strip() 26 | metrics[key] = float(parameters[-1].strip()) 27 | return metrics 28 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/feedsim_autoscale.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | import json 9 | import logging 10 | 11 | from benchpress.lib.baseline import BASELINES 12 | 13 | from benchpress.lib.parser import Parser 14 | 15 | FEEDSIM_BASELINE = BASELINES["feedsim"] 16 | 17 | logger = logging.getLogger(__name__) 18 | 19 | 20 | class FeedSimAutoscaleParser(Parser): 21 | def parse(self, stdout, stderr, returncode): 22 | """Parse FeedSim AutoScale metrics.""" 23 | output = "" 24 | json_started = False 25 | for line in reversed(stdout): 26 | if line.startswith("{"): 27 | output = "{" + output 28 | break 29 | elif line.startswith("}"): 30 | json_started = True 31 | if json_started: 32 | output = line + output 33 | 34 | try: 35 | metrics = json.loads(output) 36 | if "overall" in metrics and "final_achieved_qps" in metrics["overall"]: 37 | final_qps = metrics["overall"]["final_achieved_qps"] 38 | metrics["score"] = float(final_qps) / FEEDSIM_BASELINE 39 | return metrics 40 | except json.JSONDecodeError as e: 41 | logger.warning("Couldn't parse feedsim_autoscale output: " + str(e)) 42 | logger.warning("Collected output: " + output) 43 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/fio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import json 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | 14 | class FioParser(Parser): 15 | def parse(self, stdout, stderr, returncode): 16 | metrics = {} 17 | 18 | stdout = "".join(stdout) 19 | 20 | results = json.loads(stdout) 21 | results = results["jobs"] 22 | for job in results: 23 | name = job["jobname"] 24 | metrics[name] = job 25 | 26 | return metrics 27 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/gapbs.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # pyre-unsafe 7 | 8 | import re 9 | 10 | from benchpress.lib.parser import Parser 11 | 12 | TIME_REGEX = r"(\w+\sTime):\s+(\d+\.?\d*)" 13 | 14 | 15 | class GAPBSParser(Parser): 16 | def parse(self, stdout, stderr, returncode): 17 | output = " ".join(stdout) 18 | metrics = {} 19 | times = re.findall(TIME_REGEX, output) 20 | for t in times: 21 | key = self.snakeify_name(t[0]) 22 | metrics[key] = float(t[1]) 23 | return metrics 24 | 25 | def snakeify_name(self, s): 26 | return "_".join(s.strip().lower().split()) 27 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/generic.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import json 10 | import logging 11 | import re 12 | 13 | from benchpress.lib.parser import Parser 14 | 15 | JSON_LIKE_REGEX = r"\s*([{\[].*?[}\]]\s*[}\]]*)\s*" 16 | JSON_LIKE_MATCHER = re.compile(JSON_LIKE_REGEX) 17 | 18 | 19 | class JSONParser(Parser): 20 | def parse(self, stdout, stderr, returncode): 21 | """Converts JSON output from either stdout or stderr into a dict. 22 | 23 | Assumes that either stdout or stderr contains a section of valid JSON, 24 | as expected by the `json` module. Returns only first match of JSON. It 25 | will try to scan for JSON-like string sections, REGEX is too simple 26 | could miss some contrived cases. 27 | 28 | Args: 29 | stdout (list[str]): Process's line-by-line stdout output. 30 | stderr (list[str]): Process's line-by-line stderr output. 31 | returncode (int): Process's exit status code. 32 | 33 | Returns: 34 | metrics (dict): Representation of either stdout or stderr. 35 | 36 | Raises: 37 | ValueError: When neither stdout nor stderr could be parsed as JSON. 38 | """ 39 | err_msg = "Failed to parse {1} as JSON: {0}" 40 | for output, kind in [(stdout, "stdout"), (stderr, "stderr")]: 41 | process_output = " ".join(output) 42 | possible_json_matches = JSON_LIKE_MATCHER.findall(process_output) 43 | for m in possible_json_matches: 44 | try: 45 | return json.loads(m) 46 | except ValueError: 47 | pass 48 | else: 49 | logging.warning(err_msg.format(ValueError(), kind)) 50 | 51 | msg = "Couldn't not find or parse JSON from either stdout or stderr" 52 | raise ValueError(msg) 53 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/graph500.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # pyre-unsafe 7 | import re 8 | 9 | from benchpress.lib.parser import Parser 10 | 11 | TEPS_REGEX = r"(\w+_TEPS):\s+(\d+\.?\d*e?[+-]\d*)" 12 | 13 | 14 | class Graph500Parser(Parser): 15 | def parse(self, stdout, stderr, returncode): 16 | output = " ".join(stdout) 17 | metrics = {} 18 | times = re.findall(TEPS_REGEX, output) 19 | for t in times: 20 | metrics[t[0]] = float(t[1]) 21 | return metrics 22 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/iperf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | # any int/fp before string 'Mbits/sec' 14 | REGEX_VAL_BEFORE_MBITS = r"([-+]?\d*\.\d+|\d+) Mbits\/sec" 15 | 16 | # any int/fp before string 'sec' with any length of space 17 | REGEX_VAL_BEFORE_SEC = r"(\d*\.\d+|\d+) +sec" 18 | 19 | 20 | class IperfParser(Parser): 21 | def parse(self, stdout, stderr, returncode): 22 | metrics = {} 23 | for line in stdout: 24 | if re.search("SUM", line) and re.search("Mbits/sec", line): 25 | if re.search("sender", line): 26 | sender_bitrate = re.findall(REGEX_VAL_BEFORE_MBITS, line) 27 | metrics["total_sender_bitrate_mbps"] = float(sender_bitrate[0]) 28 | elif re.search("receiver", line): 29 | receiver_bitrate = re.findall(REGEX_VAL_BEFORE_MBITS, line) 30 | metrics["total_receiver_bitrate_mbps"] = float(receiver_bitrate[0]) 31 | runtime = re.findall(REGEX_VAL_BEFORE_SEC, line) 32 | metrics["runtime_in_secs"] = float(runtime[0]) 33 | else: 34 | continue 35 | return metrics 36 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/ltp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | # : 14 | test_format_re = re.compile("\\w+\\s+\\d+\\s+T(FAIL|PASS|BROK|WARN|INFO).*") 15 | 16 | 17 | class LtpParser(Parser): 18 | def parse(self, stdout, stderr, returncode): 19 | # ltp run in quiet mode produces lines that are mostly a single line per 20 | # test with the test name and a status and optional message 21 | metrics = {} 22 | 23 | for line in stdout: 24 | # make sure that the line matches the format of a test 25 | if not test_format_re.match(line): 26 | continue 27 | 28 | line = line.split() 29 | # combine 0 and 1 because sometimes the first name string isn't 30 | # unique but the following number is 31 | name = line[0] + "_" + line[1] 32 | 33 | status = line[2] 34 | # test failure conditions 35 | if status in ("TFAIL", "TBROK", "TWARN"): 36 | status = False 37 | elif status == "TPASS": 38 | status = True 39 | else: 40 | # if status is not one of these, just skip it 41 | continue # pragma: no cover 42 | 43 | metrics[name] = status 44 | 45 | return metrics 46 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/mediawiki.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from benchpress.lib.baseline import BASELINES 10 | 11 | from .generic import JSONParser 12 | 13 | MEDIAWIKI_MLP_BASELINE = BASELINES["mediawiki"] 14 | 15 | 16 | class MediawikiParser(JSONParser): 17 | def parse(self, stdout, stderr, returncode): 18 | metrics = super().parse(stdout, stderr, returncode) 19 | if "Combined" in metrics: 20 | if "Siege RPS" in metrics["Combined"]: 21 | rps = metrics["Combined"]["Siege RPS"] 22 | metrics["score"] = float(rps) / MEDIAWIKI_MLP_BASELINE 23 | elif "Wrk RPS" in metrics["Combined"]: 24 | rps = metrics["Combined"]["Wrk RPS"] 25 | metrics["score"] = float(rps) / MEDIAWIKI_MLP_BASELINE 26 | return metrics 27 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/memcached_bench.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from benchpress.lib.parser import Parser 10 | 11 | 12 | class MemcachedBenchParser(Parser): 13 | def parse(self, stdout, stderr, returncode): 14 | """Extracts memcached bench results from stdout.""" 15 | metrics = {} 16 | warmup_done = False 17 | exec_done = False 18 | for line in stdout: 19 | items = line.split() 20 | # server metrics 21 | if line.strip().startswith("items:"): 22 | # keep overwriting and get the last one 23 | metrics["role"] = "server" 24 | metrics["hit_latency_us"] = float(items[7].rstrip(",")) 25 | # client metrics 26 | if line.strip().startswith("ALL STATS"): 27 | exec_done = warmup_done 28 | warmup_done = True 29 | metrics["role"] = "client" 30 | if exec_done and line.strip().startswith("Sets"): 31 | metrics["set_qps"] = float(items[1]) 32 | elif exec_done and line.strip().startswith("Gets"): 33 | metrics["qps"] = float(items[1]) 34 | metrics["qps_hit"] = float(items[2]) 35 | metrics["qps_miss"] = float(items[3]) 36 | if metrics["qps"] > 0: 37 | metrics["hit_ratio"] = metrics["qps_hit"] / metrics["qps"] 38 | else: 39 | metrics["hit_ratio"] = 0 40 | return metrics 41 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/nginx_wrk_bench.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | REQUESTS_REGEX = r"(Requests/sec):\s+(\d+\.?\d*)" 14 | 15 | 16 | class NginxWrkParser(Parser): 17 | def parse(self, stdout, stderr, returncode): 18 | output = "".join(stdout) 19 | metrics = {} 20 | requests = re.findall(REQUESTS_REGEX, output)[0] 21 | metrics[requests[0]] = float(requests[1]) 22 | 23 | return metrics 24 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/nnpi_net4.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | # Avg inference per second: 4947.86 14 | # regex_ips = re.compile(r'^Avg inference per second: (\d+\.?\d+?)') 15 | regex_tinf = re.compile(r"^Avg inference duration \(ms\): (\d+(\.\d+)?)") 16 | 17 | 18 | class NNPINet4Parser(Parser): 19 | def parse(self, stdout, stderr, returncode): 20 | metrics = {} 21 | sum = 0.0 22 | n = 0 23 | for line in stdout: 24 | m = regex_tinf.search(line) 25 | if m: 26 | tinf = float(m[1]) 27 | sum += tinf 28 | n += 1 29 | metrics["acc_inf_lat"] = sum 30 | metrics["count"] = n 31 | metrics["IPS"] = 1000 * (n / sum) 32 | return metrics 33 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/returncode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from benchpress.lib.parser import Parser 10 | 11 | 12 | class ReturncodeParser(Parser): 13 | """Returncode parser outputs one metric 'success' that is True if job binary 14 | had a 0 exit code, and False all other times.""" 15 | 16 | def parse(self, stdout, stderr, returncode): 17 | return { 18 | "success": returncode == 0, 19 | } 20 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/schbench.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | import logging 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | REGEX = r"\s*\*?\d\d\.\dth:\s(\d+)\s" 14 | 15 | logger = logging.getLogger(__name__) 16 | 17 | 18 | class SchbenchParser(Parser): 19 | """ 20 | Example output: 21 | 22 | Latency percentiles (usec) runtime 30 (s) (30048 total samples) 23 | 50.0th: 16 (15765 samples) 24 | 75.0th: 22 (7782 samples) 25 | 90.0th: 26 (4389 samples) 26 | 95.0th: 27 (714 samples) 27 | *99.0th: 31 (1166 samples) 28 | 99.5th: 33 (134 samples) 29 | 99.9th: 36 (71 samples) 30 | min=2, max=1029 31 | """ 32 | 33 | def parse(self, stdout, stderr, returncode): 34 | stdout = stderr # schbench writes it output on stderr 35 | metrics = {} 36 | 37 | latency_percs = ["p50", "p75", "p90", "p95", "p99", "p99_5", "p99_9"] 38 | # this is gross - there should be some error handling eventually 39 | # Find last percentile report in output 40 | latest_report_index = -1 41 | for i, l in enumerate(stdout): 42 | if "Latency percentiles" in l: 43 | latest_report_index = i 44 | 45 | if latest_report_index < 0: 46 | # No latency reports that it coudl find 47 | return metrics 48 | 49 | for key, line in zip(latency_percs, stdout[latest_report_index + 1 :]): 50 | match = re.match(REGEX, line) 51 | if match: 52 | key_units = key + "_microsecs" 53 | metrics[key_units] = float(match[1].strip()) 54 | 55 | return metrics 56 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/silo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | 14 | AGG_TPUT_REGEX = r"(agg_throughput):\s+(\d+\.?\d*e?[+-]?\d*)\s+([a-z/]+)" 15 | PER_CORE_TPUT_REGEX = r"(avg_per_core_throughput):\s+(\d+\.?\d*e?[+-]?\d*)\s+([a-z/]+)" 16 | LAT_REGEX = r"(avg_latency):\s+(\d+\.?\d*e?[+-]?\d*)\s+([a-z]+)" 17 | 18 | 19 | class SiloParser(Parser): 20 | def parse(self, stdout, stderr, returncode): 21 | output = "".join(stderr) # Results output in stderr 22 | metrics = {"throughput": {}, "latency": {}} 23 | tput_metrics = [ 24 | re.findall(AGG_TPUT_REGEX, output)[0], 25 | re.findall(PER_CORE_TPUT_REGEX, output)[0], 26 | ] 27 | lat_metrics = [re.findall(LAT_REGEX, output)[0]] 28 | 29 | for tput_metric in tput_metrics: 30 | metrics["throughput"][tput_metric[0]] = float(tput_metric[1]) 31 | 32 | for lat_metric in lat_metrics: 33 | metrics["latency"][lat_metric[0]] = float(lat_metric[1]) 34 | 35 | return metrics 36 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/small_locks_bench.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | # pick up values for different metrics 14 | REGEX_VAL_AFTER_MEAN = r"mean (\d*)" 15 | REGEX_VAL_AFTER_STDDEV = r"stddev (\d*)" 16 | REGEX_VAL_AFTER_MAX = r"max (\d*)" 17 | 18 | 19 | class SmallLocksParser(Parser): 20 | def parse(self, stdout, stderr, returncode): 21 | metrics = {} 22 | lock_name = "" 23 | for line in stdout: 24 | # haven't pick up the name, continue 25 | if re.search("------- ", line): 26 | # pick up name, adding metrics 27 | lock_name = line[8:] 28 | continue 29 | if re.search("mean", line): 30 | mean_val = re.findall(REGEX_VAL_AFTER_MEAN, line)[0] 31 | metrics[lock_name + " mean in us"] = float(mean_val) 32 | stddev_val = re.findall(REGEX_VAL_AFTER_STDDEV, line)[0] 33 | metrics[lock_name + " stddev in us"] = float(stddev_val) 34 | max_val = re.findall(REGEX_VAL_AFTER_MAX, line)[0] 35 | metrics[lock_name + " max in us"] = float(max_val) 36 | print(metrics) 37 | return metrics 38 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/spark_standalone.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from benchpress.lib.baseline import BASELINES 10 | from benchpress.lib.parser import Parser 11 | 12 | SPARK_BASELINE = BASELINES["sparkbench"] 13 | 14 | 15 | class SparkStandaloneParser(Parser): 16 | def parse(self, stdout, stderr, returncode): 17 | """Extracts Spark Standalone results from results.txt.""" 18 | metrics = {} 19 | for line in stdout: 20 | items = line.split(":") 21 | if line.strip().startswith("test-release_test"): 22 | test_name = items[0].strip().replace("test-release_", "") 23 | metrics["execution_time_" + test_name] = float(items[1].strip()) 24 | 25 | if line.strip().startswith("queries-per-hour"): 26 | qph = float(items[1].strip()) 27 | metrics["queries_per_hour"] = qph 28 | metrics["score"] = qph / SPARK_BASELINE 29 | if line.strip().startswith("worker-cores"): 30 | metrics["worker_cores"] = int(items[1].strip()) 31 | if line.strip().startswith("worker-memory"): 32 | metrics["worker_memory"] = f"{items[1].strip()}GB" 33 | if line.strip().startswith("total_iops_read"): 34 | metrics["total_iops_read"] = int(items[1].strip()) 35 | if line.strip().startswith("total_iops_write"): 36 | metrics["total_iops_write"] = int(items[1].strip()) 37 | 38 | return metrics 39 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/spec_cpu2006.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | import logging 9 | import re 10 | 11 | from benchpress.lib.parser import Parser 12 | 13 | SPECCPU_RAWFORMAT_REGEX = r"([\w.]+):\s(.*)" 14 | SPECCPU_RAWFORMAT_MATCHER = re.compile(SPECCPU_RAWFORMAT_REGEX) 15 | 16 | 17 | class SPECCPU2006Parser(Parser): 18 | def parse(self, stdout, stderr, returncode): 19 | """Extracts SPEC CPU2006 results from rawformat report.""" 20 | output = "\n".join(stdout) 21 | metrics = {} 22 | matches = re.findall(SPECCPU_RAWFORMAT_MATCHER, output) 23 | for k, v in matches: 24 | if ( 25 | k.endswith(".base_copies") 26 | or k.endswith(".base_threads") 27 | or k.endswith(".rate") 28 | ): 29 | try: 30 | metrics[k] = int(v) 31 | except ValueError: 32 | err_msg = "Failed to parse value from {} as int. Assuming -1" 33 | logging.warning(err_msg.format(k)) 34 | metrics[k] = -1 35 | elif ( 36 | k.endswith(".basemean") 37 | or k.endswith(".ratio") 38 | or k.endswith(".reported_time") 39 | ): 40 | try: 41 | metrics[k] = float(v) 42 | except ValueError: 43 | err_msg = "Failed to parse value from {} as float. Assuming -1.0" 44 | logging.warning(err_msg.format(k)) 45 | metrics[k] = -1.0 46 | elif k.endswith(".metric") or k.endswith(".name") or k.endswith(".units"): 47 | metrics[k] = v 48 | elif k.rfind("errors") != -1: 49 | metrics[k] = v 50 | 51 | return metrics 52 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/stream.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from benchpress.lib.parser import Parser 10 | 11 | 12 | class StreamParser(Parser): 13 | def parse(self, stdout, stderr, returncode): 14 | metrics = {} 15 | patterns = {"copy": 2, "scale": 2, "add": 3, "triad": 3} 16 | 17 | element_size = 8 18 | array_size = 75000000 19 | for line in stdout: 20 | if line.startswith("This system uses "): 21 | element_size = int(line.split()[3]) 22 | continue 23 | if line.startswith("Array size = "): 24 | array_size = int(line.split()[3]) 25 | continue 26 | for pattern in patterns.keys(): 27 | if line.startswith(pattern.title()): 28 | metrics[f"{pattern}_best_MBps"] = float(line.split()[1]) 29 | # stdout gives best rate using 1e6 as 2^20; 30 | # be consistent when calculating avg & worst rates 31 | num_bytes = element_size * array_size * patterns[pattern] / 1000000 32 | metrics[f"{pattern}_avg_MBps"] = num_bytes / float(line.split()[2]) 33 | metrics[f"{pattern}_worst_MBps"] = num_bytes / float( 34 | line.split()[4] 35 | ) 36 | break 37 | return metrics 38 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/tailbench.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | from benchpress.lib.parser import Parser 10 | 11 | 12 | class TailBenchParser(Parser): 13 | def parse(self, stdout, stderr, returncode): 14 | metrics = {"role": "server"} 15 | for line in stdout: 16 | if "95th percentile latency" in line: 17 | metrics["role"] = "client" 18 | p95_str, max_str = line.split("|") 19 | metrics["P95"] = p95_str[p95_str.rfind(" ", 0, -4) + 1 : -4] 20 | metrics["max"] = max_str[max_str.rfind(" ", 0, -3) + 1 : -3] 21 | elif "99th percentile latency" in line: 22 | metrics["role"] = "client" 23 | p99_str, mean_str = line.split("|") 24 | metrics["P99"] = p99_str[p99_str.rfind(" ", 0, -4) + 1 : -4] 25 | metrics["mean"] = mean_str[mean_str.rfind(" ", 0, -3) + 1 : -3] 26 | if "Optimal QPS =" in line: 27 | metrics["role"] = "qps_search_client" 28 | qps_str, lat_str = line.split(",") 29 | qps = qps_str[qps_str.rfind(" ") + 1 :] # cut of "Optimal QPS =" 30 | lat = lat_str[lat_str.rfind(" ") + 1 :] # cut of "achieving.." 31 | if "QPS" not in metrics.keys(): 32 | metrics["QPS"] = qps 33 | metrics["P95@QPS"] = lat 34 | else: 35 | metrics["QPS"] = ",".join([metrics["QPS"], qps]) 36 | metrics["P95@QPS"] = ",".join([metrics["P95@QPS"], lat]) 37 | return metrics 38 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/tao_bench_autoscale.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import json 10 | 11 | from benchpress.lib.baseline import BASELINES 12 | 13 | from benchpress.lib.parser import Parser 14 | 15 | TAO_BENCH_BASELINE = BASELINES["taobench"] 16 | 17 | 18 | class TaoBenchAutoscaleParser(Parser): 19 | def parse(self, stdout, stderr, returncode): 20 | """Extracts TAO bench results from stdout.""" 21 | metrics = {} 22 | jsontext = "" 23 | met_json = False 24 | for line in stdout: 25 | if line.strip() == "{": 26 | met_json = True 27 | if met_json: 28 | jsontext += line 29 | if line.strip() == "}": 30 | break 31 | try: 32 | metrics = json.loads(jsontext) 33 | if "total_qps" in metrics: 34 | metrics["score"] = float(metrics["total_qps"]) / TAO_BENCH_BASELINE 35 | except Exception: 36 | pass 37 | 38 | return metrics 39 | -------------------------------------------------------------------------------- /benchpress/plugins/parsers/wdl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | import json 10 | import re 11 | 12 | from benchpress.lib.parser import Parser 13 | 14 | 15 | class WDLParser(Parser): 16 | def parse(self, stdout, stderr, returncode): 17 | metrics = {} 18 | benchmarks = [] 19 | for line in stdout: 20 | if re.search("benchmark results", line): 21 | benchmarks = line.split(":")[1].split() 22 | break 23 | 24 | for benchmark in benchmarks: 25 | out_file = "benchmarks/wdl_bench/out_" + benchmark + ".json" 26 | 27 | with open(out_file, "r") as out_f: 28 | out = json.load(out_f) 29 | for k, v in out.items(): 30 | metrics[benchmark + k] = v 31 | 32 | if len(metrics.keys()) >= 20: 33 | metrics = {} 34 | metrics["results in each out_benchmark_name.json file"] = benchmarks 35 | 36 | return metrics 37 | -------------------------------------------------------------------------------- /benchpress/version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | __PROJECT__ = "DCPerf" 8 | __VERSION__ = "1.0" 9 | -------------------------------------------------------------------------------- /benchpress_cli.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # pyre-unsafe 8 | 9 | # main functionality is actually provided in cli/main.py 10 | from benchpress.cli.main import main 11 | from benchpress.lib.reporter import JSONFileReporter, StdoutReporter 12 | from benchpress.lib.reporter_factory import ReporterFactory 13 | 14 | 15 | def invoke_main() -> None: 16 | # register a default class for reporting metrics 17 | ReporterFactory.register("default", StdoutReporter) 18 | ReporterFactory.register("json_file", JSONFileReporter) 19 | main() 20 | 21 | 22 | if __name__ == "__main__": 23 | invoke_main() # pragma: no cover 24 | -------------------------------------------------------------------------------- /packages/common/certs.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookresearch/DCPerf/7d69129b3a82edcbec8d2043d11ca27dfd222780/packages/common/certs.tar.gz -------------------------------------------------------------------------------- /packages/common/find_java_home.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import os 8 | import pathlib 9 | import platform 10 | import subprocess 11 | 12 | 13 | def find_java_home() -> str: 14 | # Try finding a home path for java 8 15 | candidates = [ 16 | "/usr/lib/jvm/java-1.8.0-openjdk", 17 | "/usr/lib/jvm/java-1.8.0-jre", 18 | "/usr/lib/jvm/java-8-openjdk", 19 | "/usr/lib/jvm/java-8-jre", 20 | "/usr/lib/jvm/openjdk-8", 21 | "/usr/lib/jvm/jre-1.8.0", 22 | "/usr/lib/jvm/jre-1.8.0-openjdk", 23 | ] 24 | archname = platform.machine() 25 | if archname == "x86_64": 26 | archname = "amd64" 27 | elif archname == "aarch64": 28 | archname = "arm64" 29 | for path in candidates: 30 | if os.path.exists(f"{path}/bin/java"): 31 | return path 32 | path_with_arch = f"{path}-{archname}" 33 | if os.path.exists(f"{path_with_arch}/bin/java"): 34 | return path_with_arch 35 | # If none of the candidate exists, try find through `java` command 36 | try: 37 | java_path = subprocess.check_output(["which", "java"], text=True).strip() 38 | java_home = str(pathlib.Path(os.path.realpath(java_path)).parents[1]) 39 | except subprocess.CalledProcessError: 40 | java_home = "" 41 | 42 | return java_home 43 | 44 | 45 | if __name__ == "__main__": 46 | print(find_java_home()) 47 | -------------------------------------------------------------------------------- /packages/common/os-distro.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | OS_DISTRO_ID="$(grep -oP '^ID=\"?\K\w+' /etc/os-release)" 8 | OS_DISTRO_ID_LIKE="$(grep -oP '^ID_LIKE=\"?\K[a-z0-9 ]+' /etc/os-release || true)" 9 | 10 | 11 | function get_os_distro_id() { 12 | echo "$OS_DISTRO_ID" 13 | } 14 | 15 | function get_os_distro_family() { 16 | echo "$OS_DISTRO_ID $OS_DISTRO_ID_LIKE" 17 | } 18 | 19 | function distro_is_like() { 20 | LIKE="$1" 21 | # shellcheck disable=SC2206 22 | OS_DISTROS=($OS_DISTRO_ID $OS_DISTRO_ID_LIKE) 23 | for DIST in "${OS_DISTROS[@]}"; do 24 | if [ "$LIKE" = "$DIST" ]; then 25 | return 0 26 | fi 27 | done 28 | return 1 29 | } 30 | -------------------------------------------------------------------------------- /packages/django_workload/cleanup_django_workload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | DJANGO_PKG_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) 8 | BENCHPRESS_ROOT="$(readlink -f "${DJANGO_PKG_ROOT}/../..")" 9 | DJANGO_BENCHMARKS_DIR="${BENCHPRESS_ROOT}/benchmarks/django_workload" 10 | 11 | # TODO: Uninstall siege here! 12 | rm -rf "${DJANGO_BENCHMARKS_DIR}" 13 | # Kill Cassandra process 14 | pkill java || true 15 | # Kill memcache processes 16 | pkill memcache || true 17 | # Kill uWSGI master process 18 | kill $(ps aux | grep -i '[u]wsgi master' | awk '{print $2}') || true 19 | -------------------------------------------------------------------------------- /packages/django_workload/install_siege.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | set -e 7 | set -x 8 | 9 | SIEGE_GIT_REPO='https://github.com/JoeDog/siege.git' 10 | SIEGE_GIT_RELEASE_TAG='v4.0.7' 11 | 12 | DJANGO_PKG_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) 13 | BENCHPRESS_ROOT="$(readlink -f "${DJANGO_PKG_ROOT}/../..")" 14 | BENCHMARKS_DIR="${BENCHPRESS_ROOT}/benchmarks" 15 | mkdir -p "$BENCHMARKS_DIR" 16 | 17 | LINUX_DIST_ID="$(awk -F "=" '/^ID=/ {print $2}' /etc/os-release | tr -d '"')" 18 | 19 | if [ "$LINUX_DIST_ID" = "centos" ]; then 20 | dnf install -y autoconf automake zlib-devel 21 | elif [ "$LINUX_DIST_ID" = "ubuntu" ]; then 22 | apt install -y autoconf automake zlib1g-dev 23 | fi 24 | 25 | SIEGE_INSTALLATION_PREFIX="${BENCHMARKS_DIR}/siege" 26 | SIEGE_BINARY_PATH="${SIEGE_INSTALLATION_PREFIX}/bin/siege" 27 | if [[ -f "$SIEGE_BINARY_PATH" && -x "$SIEGE_BINARY_PATH" ]]; then 28 | echo "siege is already installed into ${SIEGE_INSTALLATION_PREFIX}" 29 | exit 0 30 | fi 31 | 32 | rm -rf build 33 | mkdir -p build 34 | cd build/ 35 | 36 | # shellcheck disable=SC2046 37 | git clone "$SIEGE_GIT_REPO" 38 | cd siege/ 39 | git checkout "$SIEGE_GIT_RELEASE_TAG" 40 | ./utils/bootstrap 41 | ./configure 42 | make -j4 43 | make install 44 | cd ../../ 45 | 46 | rm -rf build/ 47 | 48 | # copy siege config file 49 | mkdir -p "${HOME}/.siege" 50 | if [ -f "${HOME}/.siege/siege.conf" ]; then 51 | mv -f "${HOME}/.siege/siege.conf" "${HOME}/.siege/siege.conf.bak" 52 | fi 53 | cp "${DJANGO_PKG_ROOT}/templates/siege.conf" "${HOME}/.siege/siege.conf" 54 | 55 | echo "siege installed into ${SIEGE_INSTALLATION_PREFIX}" 56 | -------------------------------------------------------------------------------- /packages/django_workload/templates/0002-Memcache-Tuning.patch: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/django-workload/django_workload/inbox.py b/django-workload/django_workload/inbox.py 6 | index d6a97ec..c966e41 100644 7 | --- a/django-workload/django_workload/inbox.py 8 | +++ b/django-workload/django_workload/inbox.py 9 | @@ -137,5 +137,5 @@ class Inbox(object): 10 | 11 | entries = self.load_inbox_entries() 12 | result = {'items': self.aggregate(entries)} 13 | - cache.set(key, result, 15) 14 | + cache.set(key, result, 24 * 60 * 60) #15 15 | return result 16 | 17 | -------------------------------------------------------------------------------- /packages/django_workload/templates/0004-del_dup_middleware_classes.patch: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/django-workload/django_workload/middleware.py b/django-workload/django_workload/middleware.py 6 | index 0399a71..11baaa6 100644 7 | --- a/django-workload/django_workload/middleware.py 8 | +++ b/django-workload/django_workload/middleware.py 9 | @@ -13,17 +13,6 @@ from django_statsd.middleware import ( 10 | # Used for sample-based profiling 11 | SAMPLE_COUNT = 0 12 | 13 | - 14 | -# Update django_statsd middleware to newer Django requirements 15 | -class GraphiteMiddleware(MiddlewareMixin, GraphiteMiddleware): 16 | - pass 17 | - 18 | - 19 | -class GraphiteRequestTimingMiddleware( 20 | - MiddlewareMixin, GraphiteRequestTimingMiddleware): 21 | - pass 22 | - 23 | - 24 | # We need access to request metadata from within patched support code. Store 25 | # the request in a thread global 26 | def global_request_middleware(get_response): 27 | -------------------------------------------------------------------------------- /packages/django_workload/templates/0005-django_middleware_settings.patch: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/django-workload/django_workload/settings.py b/django-workload/django_workload/settings.py 6 | index 676c66f..5d1d0a3 100644 7 | --- a/django-workload/django_workload/settings.py 8 | +++ b/django-workload/django_workload/settings.py 9 | @@ -42,11 +42,11 @@ INSTALLED_APPS = [ 10 | 11 | MIDDLEWARE = [ 12 | # 'django.middleware.security.SecurityMiddleware', 13 | -# 'django.contrib.sessions.middleware.SessionMiddleware', 14 | + 'django.contrib.sessions.middleware.SessionMiddleware', 15 | 'django.middleware.common.CommonMiddleware', 16 | # 'django.middleware.csrf.CsrfViewMiddleware', 17 | -# 'django.contrib.auth.middleware.AuthenticationMiddleware', 18 | -# 'django.contrib.messages.middleware.MessageMiddleware', 19 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', 20 | + 'django.contrib.messages.middleware.MessageMiddleware', 21 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 22 | 23 | 'django_workload.middleware.global_request_middleware', 24 | -------------------------------------------------------------------------------- /packages/django_workload/templates/bundle_tray.template: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | @require_user 8 | def bundle_tray{IDX}(request): 9 | # Fetch bundles of content from followers to show 10 | MLP.run(random.randint(50000, 100000), 5) 11 | bundle = BundleTray(request) 12 | result = bundle.get_bundle() 13 | result = bundle.post_process(result) 14 | return HttpResponse(json.dumps(result), content_type='text/json') 15 | 16 | -------------------------------------------------------------------------------- /packages/django_workload/templates/cassandra: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # NOTICE: See also /etc/cassandra/cassandra-env.sh 7 | 8 | # EXTRA_CLASSPATH provides the means to extend Cassandra's classpath with 9 | # additional libraries. It is formatted as a colon-delimited list of 10 | # class directories and/or jar files. For example, to enable the 11 | # JMX-to-web bridge install libmx4j-java and uncomment the following. 12 | #EXTRA_CLASSPATH="/usr/share/java/mx4j-tools.jar" 13 | JAVA_HOME='/usr/local/fb-jdk-8.72' 14 | -------------------------------------------------------------------------------- /packages/django_workload/templates/cassandra-env.patch: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/benchmarks/django_workload/apache-cassandra/conf/cassandra-env.sh b/benchmarks/django_workload/apache-cassandra/conf/cassandra-env.sh 6 | index a640847..135f4b3 100644 7 | --- a/benchmarks/django_workload/apache-cassandra/conf/cassandra-env.sh 8 | +++ b/benchmarks/django_workload/apache-cassandra/conf/cassandra-env.sh 9 | @@ -127,7 +127,7 @@ if [ "x$CASSANDRA_LOG_DIR" = "x" ] ; then 10 | fi 11 | 12 | #GC log path has to be defined here because it needs to access CASSANDRA_HOME 13 | -JVM_OPTS="$JVM_OPTS -Xloggc:${CASSANDRA_LOG_DIR}/gc.log" 14 | +# JVM_OPTS="$JVM_OPTS -Xloggc:${CASSANDRA_LOG_DIR}/gc.log" 15 | 16 | # Here we create the arguments that will get passed to the jvm when 17 | # starting cassandra. 18 | -------------------------------------------------------------------------------- /packages/django_workload/templates/cluster_settings.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | # Template file to configure the cluster. 8 | # Copy this file to cluster_settings.py before starting the WSGI server 9 | # and adjust as needed. 10 | from django_workload.settings import * # noqa F403 11 | 12 | # Security settings 13 | SECRET_KEY = "()2uyyko+p=dv*nmu$b5my9px!e0=6r5unm19or$02$-c62%gb" 14 | DEBUG = False 15 | ALLOWED_HOSTS = ["localhost", "ip6-localhost", "127.0.0.1", "::1", "*"] 16 | 17 | # Cassandra database 18 | DATABASES["default"]["HOST"] = "__CASSANDRA_DB_ADDR__" 19 | 20 | # Monitoring server 21 | STATSD_HOST = "localhost" 22 | STATSD_PORT = 8125 23 | 24 | # Memcached connection 25 | CACHES["default"]["LOCATION"] = "127.0.0.1:11811" 26 | 27 | # Sample rate for profiling 28 | SAMPLE_RATE = 1000 29 | 30 | # Enable/disable profiling 31 | PROFILING = False 32 | 33 | if not PROFILING: 34 | MIDDLEWARE.remove("django_workload.middleware.memory_cpu_stats_middleware") 35 | MIDDLEWARE.remove("django_workload.middleware.GraphiteRequestTimingMiddleware") 36 | MIDDLEWARE.remove("django_workload.middleware.GraphiteMiddleware") 37 | -------------------------------------------------------------------------------- /packages/django_workload/templates/django_genurl.patch: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | From a713b52a2754572478edf99181d5300b7ae49a5d Mon Sep 17 00:00:00 2001 6 | From: bambowu 7 | Date: Fri, 31 Jul 2020 08:14:49 -0700 8 | Subject: [PATCH] Randomize url generation 9 | 10 | --- 11 | client/gen-urls-file | 16 ++++++++-------- 12 | 1 file changed, 8 insertions(+), 8 deletions(-) 13 | 14 | diff --git a/client/gen-urls-file b/client/gen-urls-file 15 | index 006dcfd..42141d9 100755 16 | --- a/client/gen-urls-file 17 | +++ b/client/gen-urls-file 18 | @@ -55,17 +55,17 @@ def parse_urls(): 19 | url_dict[request] = repeat 20 | line_no = line_no + 1 21 | 22 | + # build a random list of URLs with their own repeats 23 | + url_list = [] 24 | + for request, repeat in url_dict.items(): 25 | + for i in range(repeat): 26 | + url_list.append(request) 27 | + random.shuffle(url_list) 28 | + 29 | # write to URL input file for Siege 30 | with open(URLS_OUT, 'w') as url_file: 31 | - while (total > 0): 32 | - current_url = random.sample(list(url_dict), 1)[0] 33 | - remaining = url_dict[current_url] 34 | - if remaining > 1: 35 | - url_dict[current_url] = remaining - 1 36 | - else: 37 | - del url_dict[current_url] 38 | + for current_url in url_list: 39 | url_file.write(current_url + "\n") 40 | - total = total - 1 41 | 42 | print ("File " + URLS_OUT + " generated successfully\n") 43 | 44 | -- 45 | 2.24.1 46 | 47 | -------------------------------------------------------------------------------- /packages/django_workload/templates/feed_timeline.template: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | @require_user 8 | def feed_timeline{IDX}(request): 9 | # Produce a JSON response containing the 'timeline' for a given user 10 | MLP.run(random.randint(50000, 100000), 5) 11 | feed_timeline = FeedTimeline(request) 12 | result = feed_timeline.get_timeline() 13 | # sort by timestamp and do some more "meaningful" work 14 | result = feed_timeline.post_process(result) 15 | return HttpResponse(json.dumps(result), content_type='text/json') 16 | -------------------------------------------------------------------------------- /packages/django_workload/templates/gen-urls-file.patch: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/benchmarks/django_workload/django-workload/client/gen-urls-file b/benchmarks/django_workload/django-workload/client/gen-urls-file 6 | index 006dcfd..a88eb95 100755 7 | --- a/benchmarks/django_workload/django-workload/client/gen-urls-file 8 | +++ b/benchmarks/django_workload/django-workload/client/gen-urls-file 9 | @@ -4,7 +4,7 @@ 10 | # LICENSE file in the root directory of this source tree. 11 | 12 | import sys 13 | -import parser 14 | +#import parser 15 | import optparse 16 | import os 17 | import random 18 | -------------------------------------------------------------------------------- /packages/django_workload/templates/inbox.template: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | @require_user 8 | def inbox{IDX}(request): 9 | # produce an inbox from different sources of information 10 | MLP.run(random.randint(50000, 100000), 5) 11 | inbox = Inbox(request) 12 | result = inbox.results() 13 | result = inbox.post_process(result) 14 | return HttpResponse(json.dumps(result), content_type='text/json') 15 | 16 | -------------------------------------------------------------------------------- /packages/django_workload/templates/jvm-server.options: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | Note: Make sure -Djava.net.preferIPv4Stack=true is not set or is set to false. Otherwise Cassandra won't bind to the IPv6 address 6 | -Xms65536M 7 | -Xmx65536M 8 | -Xmn16384M 9 | 10 | -XX:+HeapDumpOnOutOfMemoryError 11 | -Xss256k 12 | -XX:StringTableSize=1000003 13 | 14 | # CMS settings 15 | -XX:+UseParNewGC 16 | -XX:+UseConcMarkSweepGC 17 | -XX:+CMSParallelRemarkEnabled 18 | -XX:SurvivorRatio=4 19 | -XX:MaxTenuringThreshold=1 20 | -XX:CMSInitiatingOccupancyFraction=60 21 | -XX:+UseCMSInitiatingOccupancyOnly 22 | 23 | -XX:+CMSScavengeBeforeRemark 24 | -XX:CMSMaxAbortablePrecleanTime=60000 25 | 26 | -XX:CMSWaitDuration=30000 27 | -XX:+CMSParallelInitialMarkEnabled 28 | -XX:+CMSEdenChunksRecordAlways 29 | -XX:+CMSClassUnloadingEnabled 30 | 31 | # Additional settings 32 | -XX:+UseCondCardMark 33 | -XX:MaxTenuringThreshold=2 34 | -XX:-UseBiasedLocking 35 | -XX:+UseTLAB 36 | -XX:+ResizeTLAB 37 | -XX:+PerfDisableSharedMem 38 | -XX:+AlwaysPreTouch 39 | -XX:+UnlockDiagnosticVMOptions 40 | -XX:ParGCCardsPerStrideChunk=4096 41 | 42 | -------------------------------------------------------------------------------- /packages/django_workload/templates/jvm.options: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | # Note: Make sure -Djava.net.preferIPv4Stack=true is not set or is set to false. Otherwise Cassandra won't bind to the IPv6 address 6 | 7 | -Xms16G 8 | -Xmx24G 9 | -Xmn4G 10 | 11 | -XX:+HeapDumpOnOutOfMemoryError 12 | -Xss256k 13 | -XX:StringTableSize=1000003 14 | 15 | # CMS settings 16 | -XX:+UseParNewGC 17 | -XX:+UseConcMarkSweepGC 18 | -XX:+CMSParallelRemarkEnabled 19 | -XX:SurvivorRatio=4 20 | -XX:MaxTenuringThreshold=1 21 | -XX:CMSInitiatingOccupancyFraction=60 22 | -XX:+UseCMSInitiatingOccupancyOnly 23 | 24 | -XX:+CMSScavengeBeforeRemark 25 | -XX:CMSMaxAbortablePrecleanTime=60000 26 | 27 | -XX:CMSWaitDuration=30000 28 | -XX:+CMSParallelInitialMarkEnabled 29 | -XX:+CMSEdenChunksRecordAlways 30 | -XX:+CMSClassUnloadingEnabled 31 | 32 | # Additional settings 33 | -XX:+UseCondCardMark 34 | -XX:MaxTenuringThreshold=2 35 | -XX:-UseBiasedLocking 36 | -XX:+UseTLAB 37 | -XX:+ResizeTLAB 38 | -XX:+PerfDisableSharedMem 39 | -XX:+AlwaysPreTouch 40 | -XX:+UnlockDiagnosticVMOptions 41 | -XX:ParGCCardsPerStrideChunk=4096 42 | -------------------------------------------------------------------------------- /packages/django_workload/templates/jvm_options.patch: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/benchmarks/django_workload/apache-cassandra/conf/jvm.options b/benchmarks/django_workload/apache-cassandra/conf/jvm.options 6 | index cbdb2dd..3ef6b37 100644 7 | --- a/benchmarks/django_workload/apache-cassandra/conf/jvm.options 8 | +++ b/benchmarks/django_workload/apache-cassandra/conf/jvm.options 9 | @@ -8,23 +8,6 @@ 10 | -Xss256k 11 | -XX:StringTableSize=1000003 12 | 13 | -# CMS settings 14 | --XX:+UseParNewGC 15 | --XX:+UseConcMarkSweepGC 16 | --XX:+CMSParallelRemarkEnabled 17 | --XX:SurvivorRatio=4 18 | --XX:MaxTenuringThreshold=1 19 | --XX:CMSInitiatingOccupancyFraction=60 20 | --XX:+UseCMSInitiatingOccupancyOnly 21 | - 22 | --XX:+CMSScavengeBeforeRemark 23 | --XX:CMSMaxAbortablePrecleanTime=60000 24 | - 25 | --XX:CMSWaitDuration=30000 26 | --XX:+CMSParallelInitialMarkEnabled 27 | --XX:+CMSEdenChunksRecordAlways 28 | --XX:+CMSClassUnloadingEnabled 29 | - 30 | # Additional settings 31 | -XX:+UseCondCardMark 32 | -XX:MaxTenuringThreshold=2 33 | -------------------------------------------------------------------------------- /packages/django_workload/templates/seen.template: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | @require_http_methods(['POST']) 8 | @require_user 9 | def seen{IDX}(request): 10 | # Record stats for items marked as seen on a mobile device 11 | # For workload purposes we ignore the posted data, and instead generate 12 | # some random data of our own, cached in memcached 13 | global SAMPLE_COUNT 14 | should_profile = False 15 | MLP.run(random.randint(50000, 100000), 5) 16 | 17 | if settings.PROFILING: 18 | SAMPLE_COUNT += 1 19 | if SAMPLE_COUNT >= settings.SAMPLE_RATE: 20 | SAMPLE_COUNT = 0 21 | should_profile = True 22 | 23 | bundleids = cache.get('bundleids') 24 | if bundleids is None: 25 | bundleids = [uuid.uuid4() for _ in range(1000)] 26 | cache.set('bundleids', bundleids, 24 * 60 * 60) 27 | entryids = cache.get('entryids') 28 | if entryids is None: 29 | entryids = [uuid.uuid4() for _ in range(10000)] 30 | cache.set('entryids', entryids, 24 * 60 * 60) 31 | 32 | with statsd.pipeline() as pipe, BatchQuery() as b: 33 | for bundleid in random.sample(bundleids, random.randrange(3)): 34 | if should_profile: 35 | pipe.incr('workloadoutput.bundle.{}.seen'.format(bundleid.hex)) 36 | for entryid in random.sample(entryids, random.randrange(5)): 37 | if should_profile: 38 | pipe.incr('workloadoutput.bundle.{}.{}.seen'.format( 39 | bundleid.hex, entryid.hex)) 40 | BundleSeenModel( 41 | userid=request.user.id, bundleid=bundleid, entryid=entryid 42 | ).save() 43 | 44 | return HttpResponse(json.dumps({}), content_type='text/json') 45 | 46 | -------------------------------------------------------------------------------- /packages/django_workload/templates/siege.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | verbose = true 6 | color = on 7 | quiet = false 8 | json_output = false 9 | show-logfile = true 10 | logging = true 11 | gmethod = HEAD 12 | parser = true 13 | nofollow = ad.doubleclick.net 14 | nofollow = pagead2.googlesyndication.com 15 | nofollow = ads.pubsqrd.com 16 | nofollow = ib.adnxs.com 17 | limit = 1024 18 | protocol = HTTP/1.1 19 | chunked = true 20 | cache = false 21 | connection = close 22 | concurrent = 25 23 | delay = 0.0 24 | internet = false 25 | benchmark = false 26 | accept-encoding = gzip, deflate 27 | url-escaping = true 28 | unique = true 29 | -------------------------------------------------------------------------------- /packages/django_workload/templates/timeline.template: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | 7 | @require_user 8 | def timeline{IDX}(request): 9 | # Produce a JSON response containing the feed of entries for a user 10 | MLP.run(random.randint(50000, 100000), 5) 11 | feed = Feed(request) 12 | result = feed.feed_page() 13 | return HttpResponse(json.dumps(result), content_type='text/json') 14 | 15 | -------------------------------------------------------------------------------- /packages/django_workload/templates/urls.patch: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/django-workload/django_workload/urls.py b/django-workload/django_workload/urls.py 6 | index fffad1c..45f4694 100644 7 | --- a/django-workload/django_workload/urls.py 8 | +++ b/django-workload/django_workload/urls.py 9 | @@ -4,7 +4,7 @@ 10 | # This source code is licensed under the license found in the 11 | # LICENSE file in the root directory of this source tree. 12 | 13 | -from django.conf.urls import url 14 | +from django.urls import re_path as url 15 | 16 | from . import views 17 | 18 | -------------------------------------------------------------------------------- /packages/django_workload/templates/urls_template.txt: -------------------------------------------------------------------------------- 1 | http://localhost:8000/feed_timeline 30 2 | http://localhost:8000/timeline 30 3 | http://localhost:8000/bundle_tray 15 4 | http://localhost:8000/inbox 20 5 | http://localhost:8000/seen POST Welcome to the Django workload! 37 | 38 |

Welcome to the Django workload!

39 | 40 |

The following views are being tested

41 | 42 |
43 |
feed_timeline
44 |
A simple per-user feed of entries in time
45 | 46 |
timeline
47 |
A ranked feed of entries from other users
48 | 49 |
bundle_tray
50 |
A feed of current bundles, with nested content, from other users
51 | 52 |
inbox
53 |
The inbox view in a mobile app for the current user
54 | 55 |
/seen (POST only endpoint)
56 |
A view to increase counters and last-seen timestamps
57 |
58 | 59 | 60 | 61 | ''') 62 | 63 | 64 | @require_user 65 | def mlp(request): 66 | vals = MLP.run(10000, 5) 67 | return HttpResponse(json.dumps(vals), content_type='text/json') 68 | -------------------------------------------------------------------------------- /packages/feedsim/cleanup_feedsim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | FEEDSIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) 8 | BENCHPRESS_ROOT="$(readlink -f "$FEEDSIM_ROOT/../..")" 9 | FEEDSIM_BENCHMARKS_DIR="${BENCHPRESS_ROOT}/benchmarks/feedsim" 10 | 11 | rm -rf "${FEEDSIM_BENCHMARKS_DIR}" 12 | -------------------------------------------------------------------------------- /packages/feedsim/patches/centos-9-compatibility/rsocket-cpp.diff: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/yarpl/Refcounted.h b/yarpl/Refcounted.h 6 | index e88886f1..ac0a4950 100644 7 | --- a/yarpl/Refcounted.h 8 | +++ b/yarpl/Refcounted.h 9 | @@ -42,7 +42,7 @@ std::shared_ptr atomic_exchange( 10 | auto refptr = ar->ref.lock(); 11 | auto old = std::move(*refptr); 12 | *refptr = std::move(r); 13 | - return std::move(old); 14 | + return old; 15 | } 16 | 17 | template 18 | -------------------------------------------------------------------------------- /packages/feedsim/patches/centos-9-compatibility/wangle.diff: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/wangle/ssl/SSLUtil.h b/wangle/ssl/SSLUtil.h 6 | index 1636a35e..b64fb78a 100644 7 | --- a/wangle/ssl/SSLUtil.h 8 | +++ b/wangle/ssl/SSLUtil.h 9 | @@ -106,11 +106,7 @@ class SSLUtil { 10 | using ex_data_dup_from_arg_t = CRYPTO_EX_DATA*; 11 | #endif 12 | 13 | -#ifdef OPENSSL_IS_BORINGSSL 14 | using ex_data_dup_ptr_arg_t = void**; 15 | -#else 16 | - using ex_data_dup_ptr_arg_t = void*; 17 | -#endif 18 | 19 | public: 20 | // ex data string dup func 21 | -------------------------------------------------------------------------------- /packages/feedsim/patches/ubuntu-22-compatibility/folly.diff: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/folly/fibers/FiberManager.cpp b/folly/fibers/FiberManager.cpp 6 | index 23452d2..7b09742 100644 7 | --- a/folly/fibers/FiberManager.cpp 8 | +++ b/folly/fibers/FiberManager.cpp 9 | @@ -323,7 +323,8 @@ namespace { 10 | 11 | // SIGSTKSZ (8 kB on our architectures) isn't always enough for 12 | // folly::symbolizer, so allocate 32 kB. 13 | -constexpr size_t kAltStackSize = folly::constexpr_max(SIGSTKSZ, 32 * 1024); 14 | +// constexpr size_t kAltStackSize = folly::constexpr_max(SIGSTKSZ, 32 * 1024); 15 | +constexpr size_t kAltStackSize = 32 * 1024; 16 | 17 | bool hasAlternateStack() { 18 | stack_t ss; 19 | diff --git a/folly/TimeoutQueue.cpp b/folly/TimeoutQueue.cpp 20 | index 706715f..48ab1af 100644 21 | --- a/folly/TimeoutQueue.cpp 22 | +++ b/folly/TimeoutQueue.cpp 23 | @@ -17,6 +17,7 @@ 24 | #include 25 | #include 26 | #include 27 | +#include 28 | 29 | namespace folly { 30 | 31 | diff --git a/folly/detail/AtFork.cpp b/folly/detail/AtFork.cpp 32 | index eb6daac00..81d661961 100644 33 | --- a/folly/detail/AtFork.cpp 34 | +++ b/folly/detail/AtFork.cpp 35 | @@ -18,6 +18,7 @@ 36 | 37 | #include 38 | #include 39 | +#include 40 | 41 | #include 42 | #include 43 | -------------------------------------------------------------------------------- /packages/feedsim/patches/ubuntu-22-compatibility/rsocket-cpp.diff: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/CMakeLists.txt b/CMakeLists.txt 6 | index 79750f7b..6eb9186c 100644 7 | --- a/CMakeLists.txt 8 | +++ b/CMakeLists.txt 9 | @@ -170,7 +170,7 @@ if (COMPILER_HAS_W_NOEXCEPT_TYPE) 10 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-noexcept-type") 11 | endif() 12 | 13 | -if (NOT MSVC) 14 | +if (NOT MSVC AND NOT (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13)) 15 | set(EXTRA_CXX_FLAGS ${EXTRA_CXX_FLAGS} -Werror) 16 | endif() 17 | 18 | diff --git a/yarpl/Refcounted.h b/yarpl/Refcounted.h 19 | index e88886f..ac0a495 100644 20 | --- a/yarpl/Refcounted.h 21 | +++ b/yarpl/Refcounted.h 22 | @@ -42,7 +42,7 @@ std::shared_ptr atomic_exchange( 23 | auto refptr = ar->ref.lock(); 24 | auto old = std::move(*refptr); 25 | *refptr = std::move(r); 26 | - return std::move(old); 27 | + return old; 28 | } 29 | 30 | template 31 | -------------------------------------------------------------------------------- /packages/feedsim/patches/ubuntu-22-compatibility/wangle.diff: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/wangle/ssl/SSLUtil.h b/wangle/ssl/SSLUtil.h 6 | index 1636a35..7be2ea6 100644 7 | --- a/wangle/ssl/SSLUtil.h 8 | +++ b/wangle/ssl/SSLUtil.h 9 | @@ -109,7 +109,7 @@ class SSLUtil { 10 | #ifdef OPENSSL_IS_BORINGSSL 11 | using ex_data_dup_ptr_arg_t = void**; 12 | #else 13 | - using ex_data_dup_ptr_arg_t = void*; 14 | + using ex_data_dup_ptr_arg_t = void**; 15 | #endif 16 | 17 | public: 18 | -------------------------------------------------------------------------------- /packages/feedsim/submodules.txt: -------------------------------------------------------------------------------- 1 | https://github.com/USCiLab/cereal 81ec2714ea969bbf01330bf84917022473cff032 third_party/cereal 2 | https://github.com/facebook/fbthrift 773f9a846f3d3cf720b94fcb2807deb871e36607 third_party/fbthrift 3 | https://github.com/facebookincubator/fizz 724529f926bf6045d0bb005e37342a1393133c19 third_party/fizz 4 | https://github.com/fmtlib/fmt 6793ffc1d64fe91ac66a0b4e4d93505f5b74e1d9 third_party/fmt 5 | https://github.com/facebook/folly cc3f054a35dec6d6385ed62738b479b879904293 third_party/folly 6 | https://github.com/sbeamer/gapbs 120cd01448d7ccf86235f9c2d0e25d563ac596cd third_party/gapbs 7 | https://github.com/rsocket/rsocket-cpp 68193f9c1ad85b50534880e22c4c8636c5229be3 third_party/rsocket-cpp 8 | https://github.com/facebook/wangle d2cb4e370892320882c96deb5878109793bb6111 third_party/wangle 9 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/.gitignore: -------------------------------------------------------------------------------- 1 | # Configuration 2 | /config.log 3 | /oldisim/config.h 4 | /.sconf_temp 5 | /.sconsign.dblite 6 | 7 | # Build directories 8 | /debug 9 | /release 10 | /build 11 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/FindCereal.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | find_path(Cereal_INCLUDE_DIR 7 | NAMES cereal/cereal.hpp 8 | PATHS "${CMAKE_SOURCE_DIR}/third_party/cereal" 9 | PATH_SUFFIXES 10 | include) 11 | 12 | mark_as_advanced(Cereal_INCLUDE_DIR) 13 | 14 | 15 | include(FindPackageHandleStandardArgs) 16 | find_package_handle_standard_args(Cereal 17 | REQUIRED_VARS Cereal_INCLUDE_DIR 18 | ) 19 | 20 | if(Cereal_FOUND AND NOT TARGET Cereal::Cereal) 21 | add_library(Cereal::Cereal INTERFACE IMPORTED) 22 | 23 | set_target_properties(Cereal::Cereal PROPERTIES 24 | INTERFACE_INCLUDE_DIRECTORIES "${Cereal_INCLUDE_DIR}" 25 | ) 26 | endif() 27 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/FindDoubleConversion.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | find_path(DOUBLE_CONVERSION_INCLUDE_DIR 7 | NAMES 8 | double-conversion.h 9 | PATHS 10 | /usr/include/double-conversion 11 | /usr/local/include/double-conversion) 12 | find_library(DOUBLE_CONVERSION_LIBRARY NAMES double-conversion) 13 | 14 | include(FindPackageHandleStandardArgs) 15 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 16 | DOUBLE_CONVERSION DEFAULT_MSG 17 | DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR) 18 | 19 | if (NOT DOUBLE_CONVERSION_FOUND) 20 | message(STATUS "Using third-party bundled double-conversion") 21 | else() 22 | message(STATUS "Found double-conversion: ${DOUBLE_CONVERSION_LIBRARY}") 23 | endif () 24 | 25 | mark_as_advanced(DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARY) 26 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/FindLZ4.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | find_path(LZ4_INCLUDE_DIR NAMES lz4.h) 7 | find_library(LZ4_LIBRARY NAMES lz4) 8 | 9 | include(FindPackageHandleStandardArgs) 10 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 11 | LZ4 DEFAULT_MSG 12 | LZ4_LIBRARY LZ4_INCLUDE_DIR) 13 | 14 | if (NOT LZ4_FOUND) 15 | message(STATUS "Using third-party bundled LZ4") 16 | else() 17 | message(STATUS "Found LZ4: ${LZ4_LIBRARY}") 18 | endif (NOT LZ4_FOUND) 19 | 20 | mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY) 21 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/FindLibEvent.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # - Find LibEvent (a cross event library) 7 | # This module defines 8 | # LIBEVENT_INCLUDE_DIR, where to find LibEvent headers 9 | # LIBEVENT_LIB, LibEvent libraries 10 | # LibEvent_FOUND, If false, do not try to use libevent 11 | 12 | set(LibEvent_EXTRA_PREFIXES /usr/local /opt/local "$ENV{HOME}") 13 | foreach(prefix ${LibEvent_EXTRA_PREFIXES}) 14 | list(APPEND LibEvent_INCLUDE_PATHS "${prefix}/include") 15 | list(APPEND LibEvent_LIB_PATHS "${prefix}/lib") 16 | endforeach() 17 | 18 | find_path(LIBEVENT_INCLUDE_DIR event.h PATHS ${LibEvent_INCLUDE_PATHS}) 19 | find_library(LIBEVENT_LIB NAMES event PATHS ${LibEvent_LIB_PATHS}) 20 | find_library(LIBEVENT_PTHREAD_LIB NAMES event_pthreads PATHS ${LibEvent_LIB_PATHS}) 21 | 22 | if (LIBEVENT_LIB AND LIBEVENT_INCLUDE_DIR AND LIBEVENT_PTHREAD_LIB) 23 | set(LibEvent_FOUND TRUE) 24 | set(LIBEVENT_LIB ${LIBEVENT_LIB} ${LIBEVENT_PTHREAD_LIB}) 25 | else () 26 | set(LibEvent_FOUND FALSE) 27 | endif () 28 | 29 | if (LibEvent_FOUND) 30 | if (NOT LibEvent_FIND_QUIETLY) 31 | message(STATUS "Found libevent: ${LIBEVENT_LIB}") 32 | endif () 33 | else () 34 | if (LibEvent_FIND_REQUIRED) 35 | message(FATAL_ERROR "Could NOT find libevent and libevent_pthread.") 36 | endif () 37 | message(STATUS "libevent and libevent_pthread NOT found.") 38 | endif () 39 | 40 | mark_as_advanced( 41 | LIBEVENT_LIB 42 | LIBEVENT_INCLUDE_DIR 43 | ) 44 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/FindLibIberty.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | FIND_LIBRARY(IBERTY_LIBRARIES 7 | NAMES iberty_pic iberty) 8 | 9 | IF (IBERTY_LIBRARIES) 10 | 11 | # show which libiberty was found only if not quiet 12 | MESSAGE( STATUS "Found libiberty: ${IBERTY_LIBRARIES}") 13 | 14 | SET(IBERTY_FOUND TRUE) 15 | 16 | ELSE (IBERTY_LIBRARIES) 17 | 18 | IF ( IBERTY_FIND_REQUIRED) 19 | MESSAGE(FATAL_ERROR "Could not find libiberty. Try to install binutil-devel?") 20 | ELSE() 21 | MESSAGE(STATUS "Could not find libiberty; downloading binutils and building PIC libiberty.") 22 | ENDIF (IBERTY_FIND_REQUIRED) 23 | 24 | ENDIF (IBERTY_LIBRARIES) 25 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/FindSnappy.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | find_path(SNAPPY_INCLUDE_DIR NAMES snappy.h) 7 | find_library(SNAPPY_LIBRARY NAMES snappy) 8 | 9 | include(FindPackageHandleStandardArgs) 10 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 11 | SNAPPY DEFAULT_MSG 12 | SNAPPY_LIBRARY SNAPPY_INCLUDE_DIR) 13 | 14 | if (NOT SNAPPY_FOUND) 15 | message(STATUS "Using third-party bundled Snappy") 16 | else() 17 | message(STATUS "Found Snappy: ${SNAPPY_LIBRARY}") 18 | endif (NOT SNAPPY_FOUND) 19 | 20 | mark_as_advanced(SNAPPY_INCLUDE_DIR SNAPPY_LIBRARY) 21 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/FindZstd.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | find_path(ZSTD_INCLUDE_DIR zstd.h) 7 | 8 | find_library(ZSTD_LIBRARY NAMES zstd) 9 | 10 | if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY) 11 | set(ZSTD_FOUND TRUE) 12 | message(STATUS "Found ZSTD library: ${ZSTD_LIBRARY}") 13 | endif () 14 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/build-config.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | set(OLDISIM_STAGING_DIR "${oldisim_BINARY_DIR}/staging/usr/local") 7 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/build-fizz.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | set(FIZZ_ROOT_DIR ${oldisim_SOURCE_DIR}/third_party/fizz/fizz) 7 | 8 | include(ExternalProject) 9 | 10 | ExternalProject_Add(fizz 11 | PREFIX fizz 12 | SOURCE_DIR "${FIZZ_ROOT_DIR}" 13 | BUILD_ALWAYS OFF 14 | DOWNLOAD_COMMAND "" 15 | INSTALL_DIR ${OLDISIM_STAGING_DIR} 16 | CMAKE_ARGS 17 | -DCMAKE_BUILD_TYPE:STRING=Release 18 | -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} 19 | -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} 20 | -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE} 21 | -DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} 22 | -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=True 23 | -DCMAKE_PREFIX_PATH:PATH= 24 | -DCMAKE_INSTALL_PREFIX:PATH= 25 | -DBUILD_TESTS:BOOL=OFF 26 | BINARY_DIR ${oldisim_BINARY_DIR}/third_party/fizz 27 | BUILD_BYPRODUCTS /lib/libfizz.a 28 | BUILD_COMMAND 29 | cmake --build . 30 | ) 31 | 32 | 33 | ExternalProject_Add_StepDependencies(fizz configure folly) 34 | 35 | ExternalProject_Get_Property(fizz SOURCE_DIR) 36 | ExternalProject_Get_Property(fizz INSTALL_DIR) 37 | 38 | set(FIZZ_LIBRARIES 39 | ${INSTALL_DIR}/lib/libfizz.a) 40 | 41 | message(STATUS "Fizz Library: ${FIZZ_LIBRARIES}") 42 | 43 | mark_as_advanced( 44 | FIZZ_ROOT_DIR 45 | FIZZ_LIBRARIES 46 | ) 47 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/build-fmt.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | include(ExternalProject) 7 | 8 | ExternalProject_Add(fmt 9 | SOURCE_DIR "${oldisim_SOURCE_DIR}/third_party/fmt" 10 | DOWNLOAD_COMMAND "" 11 | BUILD_ALWAYS OFF 12 | INSTALL_DIR ${OLDISIM_STAGING_DIR} 13 | CMAKE_ARGS 14 | -DCMAKE_BUILD_TYPE:STRING=Release 15 | -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=True 16 | -DCMAKE_CXX_STANDARD:BOOL=17 17 | -DCMAKE_INSTALL_PREFIX:PATH= 18 | -DFMT_TEST:BOOL=OFF 19 | BINARY_DIR ${oldisim_BINARY_DIR}/third_party/fmt 20 | BUILD_BYPRODUCTS /lib64/libfmt.a 21 | ) 22 | 23 | # Specify include dir 24 | ExternalProject_Get_Property(fmt INSTALL_DIR) 25 | 26 | set(FMT_LIBRARIES 27 | ${INSTALL_DIR}/lib64/libfmt.a 28 | ) 29 | message(STATUS "fmt Library: ${FMT_LIBRARIES}") 30 | 31 | mark_as_advanced( 32 | FMT_LIBRARIES 33 | ) 34 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/build-folly.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | set(FOLLY_ROOT_DIR ${oldisim_SOURCE_DIR}/third_party/folly) 7 | 8 | include(ExternalProject) 9 | 10 | if(thriftpy3) 11 | set(_folly_cmake_extra_opts "-DPYTHON_EXTENSIONS=True") 12 | endif() 13 | 14 | 15 | ExternalProject_Add(folly 16 | SOURCE_DIR "${FOLLY_ROOT_DIR}" 17 | BUILD_ALWAYS OFF 18 | DOWNLOAD_COMMAND "" 19 | INSTALL_DIR ${OLDISIM_STAGING_DIR} 20 | CMAKE_ARGS 21 | -DCMAKE_BUILD_TYPE:STRING=Release 22 | -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} 23 | -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} 24 | -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE} 25 | -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=True 26 | -DCXX_STD:STRING=gnu++17 27 | -DCMAKE_CXX_STANDARD:STRING=17 28 | -DCMAKE_INSTALL_PREFIX:PATH= 29 | BINARY_DIR ${oldisim_BINARY_DIR}/third_party/folly 30 | BUILD_BYPRODUCTS /lib/libfolly.a 31 | BUILD_COMMAND 32 | cmake --build . 33 | ) 34 | add_dependencies(folly fmt) 35 | 36 | ExternalProject_Get_Property(folly SOURCE_DIR) 37 | ExternalProject_Get_Property(folly INSTALL_DIR) 38 | 39 | set(FOLLY_LIBRARIES 40 | ${INSTALL_DIR}/lib/libfolly.a) 41 | set(FOLLY_BENCHMARK_LIBRARIES 42 | ${INSTALL_DIR}/lib/folly/libfollybenchmark.a) 43 | set(FOLLY_TEST_UTIL_LIBRARIES 44 | ${INSTALL_DIR}/lib/libfolly_test_util.a) 45 | 46 | set(FOLLY_INCLUDE_DIR ${INSTALL_DIR}/include) 47 | message(STATUS "Folly Library: ${FOLLY_LIBRARIES}") 48 | message(STATUS "Folly Benchmark: ${FOLLY_BENCHMARK_LIBRARIES}") 49 | message(STATUS "Folly Includes: ${FOLLY_INCLUDE_DIR}") 50 | 51 | mark_as_advanced( 52 | FOLLY_ROOT_DIR 53 | FOLLY_LIBRARIES 54 | FOLLY_BENCHMARK_LIBRARIES 55 | FOLLY_INCLUDE_DIR 56 | ) 57 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/build-rsocket.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | set(RSOCKET_ROOT_DIR "${oldisim_SOURCE_DIR}/third_party/rsocket-cpp") 7 | 8 | include(ExternalProject) 9 | 10 | ExternalProject_Add(rsocket 11 | SOURCE_DIR "${RSOCKET_ROOT_DIR}" 12 | BUILD_ALWAYS OFF 13 | DOWNLOAD_COMMAND "" 14 | INSTALL_DIR ${OLDISIM_STAGING_DIR} 15 | CMAKE_ARGS 16 | -DCMAKE_BUILD_TYPE:STRING=Release 17 | -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=True 18 | -DCMAKE_PREFIX_PATH:PATH= 19 | -DCMAKE_INSTALL_PREFIX:PATH= 20 | -DBUILD_TESTS:BOOL=OFF 21 | -DBUILD_BENCHMARKS:BOOL=OFF 22 | -DBUILD_EXAMPLES:BOOL=OFF 23 | -DCMAKE_CXX_STANDARD:STRING=17 24 | BINARY_DIR ${oldisim_BINARY_DIR}/third_party/rsocket-cpp 25 | BUILD_BYPRODUCTS 26 | /lib/libReactiveSocket.a 27 | /lib/libyarpl.a 28 | ) 29 | 30 | # Specify include dir 31 | ExternalProject_Get_Property(rsocket INSTALL_DIR) 32 | ExternalProject_Add_StepDependencies(rsocket configure fizz folly fmt) 33 | 34 | set(RSOCKET_LIBRARIES 35 | ${INSTALL_DIR}/lib/libReactiveSocket.a 36 | ${INSTALL_DIR}/lib/libyarpl.a 37 | ) 38 | 39 | message(STATUS "Rsocket Library: ${RSOCKET_LIBRARIES}") 40 | 41 | mark_as_advanced( 42 | RSOCKET_LIBRARIES 43 | ) 44 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CMake/build-wangle.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | set(WANGLE_ROOT_DIR ${oldisim_SOURCE_DIR}/third_party/wangle/wangle) 7 | 8 | include(ExternalProject) 9 | 10 | ExternalProject_Add(wangle 11 | SOURCE_DIR "${WANGLE_ROOT_DIR}" 12 | DOWNLOAD_COMMAND "" 13 | CMAKE_ARGS 14 | -DCMAKE_BUILD_TYPE:STRING=Release 15 | -DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH} 16 | -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} 17 | -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} 18 | -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE} 19 | -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=True 20 | -DCMAKE_INSTALL_PREFIX:PATH=${OLDISIM_STAGING_DIR} 21 | -DBUILD_TESTS=OFF 22 | BINARY_DIR ${oldisim_BINARY_DIR}/third_party/wangle 23 | BUILD_BYPRODUCTS ${OLDISIM_STAGING_DIR}/lib/libwangle.a 24 | BUILD_COMMAND 25 | cmake --build . 26 | ) 27 | 28 | ExternalProject_Get_Property(wangle BINARY_DIR) 29 | 30 | ExternalProject_Add_StepDependencies(wangle configure fizz folly) 31 | 32 | set(WANGLE_LIBRARIES 33 | ${OLDISIM_STAGING_DIR}/lib/libwangle.a) 34 | 35 | message(STATUS "Wangle Library: ${WANGLE_LIBRARIES}") 36 | 37 | mark_as_advanced( 38 | WANGLE_ROOT_DIR 39 | WANGLE_LIBRARIES 40 | WANGLE_BENCHMARK_LIBRARIES 41 | WANGLE_INCLUDE_DIR 42 | ) 43 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! First, read this page (including the small print at the end). 2 | 3 | ### Before you contribute 4 | Before we can use your code, you must sign the 5 | [Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1) 6 | (CLA), which you can do online. The CLA is necessary mainly because you own the 7 | copyright to your changes, even after your contribution becomes part of our 8 | codebase, so we need your permission to use and distribute your code. We also 9 | need to be sure of various other things—for instance that you'll tell us if you 10 | know that your code infringes on other people's patents. You don't have to sign 11 | the CLA until after you've submitted your code for review and a member has 12 | approved it, but you must do it before we can put your code into our codebase. 13 | Before you start working on a larger contribution, you should get in touch with 14 | us first through the issue tracker with your idea so that we can help out and 15 | possibly guide you. Coordinating up front makes it much easier to avoid 16 | frustration later on. 17 | 18 | ### Code reviews 19 | All submissions, including submissions by project members, require review. We 20 | use Github pull requests for this purpose. 21 | 22 | ### The small print 23 | Contributions made by corporations are covered by a different agreement than 24 | the one above, the Software Grant and Corporate Contributor License Agreement. 25 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/include/oldisim/Callbacks.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OLDISIM_CALLBACKS_H 16 | #define OLDISIM_CALLBACKS_H 17 | 18 | #include 19 | #include 20 | 21 | namespace oldisim { 22 | 23 | class ChildConnection; 24 | class FanoutManager; 25 | class NodeThread; 26 | class ParentConnection; 27 | class QueryContext; 28 | class ResponseContext; 29 | class TestDriver; 30 | 31 | typedef std::function AcceptCallback; 32 | 33 | typedef std::function LeafNodeThreadStartupCallback; 34 | typedef std::function LeafNodeQueryCallback; 35 | 36 | typedef std::function 37 | ParentNodeThreadStartupCallback; 38 | typedef std::function 39 | ParentNodeQueryCallback; 40 | 41 | typedef std::function 42 | DriverNodeThreadStartupCallback; 43 | typedef std::function 44 | DriverNodeResponseCallback; 45 | typedef std::function 46 | DriverNodeMakeRequestCallback; 47 | } // namespace oldisim 48 | 49 | #endif // OLDISIM_CALLBACKS_H 50 | 51 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/include/oldisim/ChildConnection.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OLDISIM_CHILD_CONNECTION_H 16 | #define OLDISIM_CHILD_CONNECTION_H 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include "oldisim/ChildConnectionStats.h" 27 | 28 | namespace oldisim { 29 | 30 | class ConnectionUtil; 31 | class Query; 32 | 33 | /** 34 | * This classes represents one part of a bi-directional connection between 35 | * two nodes in the fanout tree. Specifically, this class is owned by the 36 | * parent node in the tree and represents the connection established to the 37 | * child node by the parent node of the tree. This class allows the parent to 38 | * send requests to the child node. 39 | */ 40 | class ChildConnection { 41 | friend ConnectionUtil; 42 | 43 | public: 44 | ~ChildConnection(); 45 | 46 | void IssueRequest(uint32_t type, uint64_t request_id, const void* payload, 47 | uint32_t length); 48 | void Reset(); 49 | 50 | void set_priority(int pri); 51 | int GetNumOutstandingRequests() const; 52 | 53 | private: 54 | class ChildConnectionImpl; 55 | const std::unique_ptr impl_; 56 | explicit ChildConnection(std::unique_ptr impl); 57 | }; 58 | } // namespace oldisim 59 | 60 | #endif // OLDISIM_CHILD_CONNECTION_H 61 | 62 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/include/oldisim/Log.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | enum log_level_t { DEBUG, VERBOSE, INFO, WARN, QUIET }; 19 | extern log_level_t log_level; 20 | 21 | void log_file_line(log_level_t level, const char* file, int line, 22 | const char* format, ...); 23 | #define L(level, args...) log_file_line(level, __FILE__, __LINE__, args) 24 | 25 | #define D(args...) L(DEBUG, args) 26 | #define V(args...) L(VERBOSE, args) 27 | #define I(args...) L(INFO, args) 28 | #define W(args...) L(WARN, args) 29 | 30 | #define DIE(args...) \ 31 | do { \ 32 | W(args); \ 33 | exit(-1); \ 34 | } while (0) 35 | 36 | #define NOLOG(x) \ 37 | do { \ 38 | log_level_t old = log_level; \ 39 | log_level = QUIET; \ 40 | (x); \ 41 | log_level = old; \ 42 | } while (0) 43 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/include/oldisim/NodeThread.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OLDISIM_NODE_THREAD_H 16 | #define OLDISIM_NODE_THREAD_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace oldisim { 25 | 26 | class ChildConnection; 27 | class LeafNodeServer; 28 | class ParentNodeServer; 29 | class DriverNode; 30 | 31 | class NodeThread { 32 | friend LeafNodeServer; 33 | friend ParentNodeServer; 34 | friend DriverNode; 35 | 36 | public: 37 | int get_thread_num() const; 38 | pthread_t get_pthread() const; 39 | event_base* get_event_base() const; 40 | 41 | private: 42 | struct NodeThreadImpl; 43 | std::unique_ptr impl_; 44 | 45 | NodeThread(); 46 | }; 47 | } // namespace oldisim 48 | 49 | #endif // OLDISIM_NODE_THREAD_H 50 | 51 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/include/oldisim/QueryContext.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OLDISIM_QUERY_CONTEXT_H 16 | #define OLDISIM_QUERY_CONTEXT_H 17 | 18 | #include 19 | #include 20 | 21 | #include "oldisim/ParentConnection.h" 22 | 23 | namespace oldisim { 24 | 25 | class ParentConnection; 26 | class LeafNodeServer; 27 | class ParentNodeServer; 28 | 29 | class QueryContext { 30 | friend ParentConnection; 31 | friend LeafNodeServer; 32 | friend ParentNodeServer; 33 | 34 | public: 35 | QueryContext(QueryContext&& other); 36 | QueryContext(const QueryContext& other) = delete; 37 | ~QueryContext(); 38 | 39 | const uint32_t type; 40 | const uint64_t request_id; 41 | const uint64_t start_time; 42 | const uint64_t received_time; 43 | const uint32_t payload_length; 44 | const uint32_t packet_length; 45 | void* const payload; 46 | void SendResponse(const void* data, uint32_t data_length); 47 | 48 | private: 49 | ParentConnection& connection; 50 | bool response_sent; 51 | bool is_active; 52 | bool is_payload_heap; 53 | std::function logger; 54 | 55 | QueryContext(ParentConnection& _connection, uint32_t _type, 56 | uint64_t _request_id, uint64_t start_time, 57 | uint32_t _payload_length, uint32_t _packet_length, 58 | void* _payload, bool _is_payload_heap); 59 | }; 60 | } // namespace oldisim 61 | 62 | #endif // OLDISIM_QUERY_CONTEXT_H 63 | 64 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/include/oldisim/ResponseContext.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OLDISIM_RESPONSE_CONTEXT_H 16 | #define OLDISIM_RESPONSE_CONTEXT_H 17 | 18 | #include 19 | 20 | #include 21 | 22 | namespace oldisim { 23 | 24 | class ChildConnection; 25 | 26 | class ResponseContext { 27 | friend ChildConnection; 28 | 29 | public: 30 | uint32_t type; 31 | uint64_t request_id; 32 | uint32_t payload_length; 33 | uint32_t packet_length; 34 | const void* payload; 35 | bool timed_out; 36 | uint64_t request_timestamp; 37 | uint64_t response_timestamp; 38 | 39 | private: 40 | ResponseContext(uint32_t _type, uint64_t _request_id, 41 | uint32_t _payload_length, uint32_t _packet_length, 42 | const void* _payload, bool _timed_out, 43 | uint64_t _request_timestamp, uint64_t _response_timestamp); 44 | }; 45 | } // namespace oldisim 46 | 47 | #endif // OLDISIM_RESPONSE_CONTEXT_H 48 | 49 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/include/oldisim/TestDriver.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OLDISIM_TEST_DRIVER_H 16 | #define OLDISIM_TEST_DRIVER_H 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include "oldisim/Callbacks.h" 23 | 24 | namespace oldisim { 25 | 26 | class ChildConnectionStats; 27 | class DriverNode; 28 | 29 | class TestDriver { 30 | friend DriverNode; 31 | 32 | public: 33 | void Start(); 34 | void SendRequest(uint32_t type, const void* payload, uint32_t payload_length, 35 | uint64_t next_request_delay_us); 36 | const ChildConnectionStats& GetConnectionStats() const; 37 | 38 | private: 39 | struct TestDriverImpl; 40 | std::unique_ptr impl_; 41 | TestDriver(); 42 | }; 43 | } // namespace oldisim 44 | 45 | #endif // OLDISIM_TEST_DRIVER_H 46 | 47 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/src/CerealMapAsJSObject.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef CEREAL_MAP_AS_JS_OBJECT_H 16 | #define CEREAL_MAP_AS_JS_OBJECT_H 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | // Clever hack to make cereal serialize a map as a JavaScript object 23 | // Answer adopted from 24 | // https://stackoverflow.com/questions/22569832/is-there-a-way-to-specify-a-simpler-json-de-serialization-for-stdmap-using-c 25 | namespace cereal { 26 | //! Saving for std::map 27 | template 28 | inline void save(Archive& ar, const std::map& map) { 29 | for (const auto& i : map) { 30 | ar(cereal::make_nvp(i.first, i.second)); 31 | } 32 | } 33 | 34 | //! Saving for std::map 35 | template 36 | inline void save(Archive& ar, const std::map& map) { 37 | for (const auto& i : map) { 38 | std::stringstream ss; 39 | ss << i.first; 40 | ar(cereal::make_nvp(ss.str(), i.second)); 41 | } 42 | } 43 | } // namespace cereal 44 | 45 | #endif // CEREAL_MAP_AS_JS_OBJECT_H 46 | 47 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/src/ForcedEvTimer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | namespace oldisim { 19 | 20 | class ForcedEvTimer { 21 | public: 22 | explicit ForcedEvTimer(event_base* base) { 23 | timer_event_ = evtimer_new(base, TimerHandler, this); 24 | AddTimer(*this); 25 | } 26 | 27 | ~ForcedEvTimer() { event_free(timer_event_); } 28 | 29 | void SetPriority(int priority) { event_priority_set(timer_event_, priority); } 30 | 31 | static void TimerHandler(evutil_socket_t listener, int16_t flags, void* arg) { 32 | ForcedEvTimer* self = reinterpret_cast(arg); 33 | 34 | // Re-add the timer 35 | AddTimer(*self); 36 | } 37 | 38 | static void AddTimer(ForcedEvTimer& timer) { 39 | timeval t = {1000000, 0}; // Something large, hopefully never hits 40 | evtimer_add(timer.timer_event_, &t); 41 | } 42 | 43 | private: 44 | event* timer_event_; 45 | }; 46 | } // namespace oldisim 47 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/src/InternalCallbacks.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #pragma once 15 | 16 | #include 17 | #include 18 | 19 | namespace oldisim { 20 | 21 | class ChildConnection; 22 | class NodeThread; 23 | class ParentConnection; 24 | class QueryContext; 25 | class ResponseContext; 26 | 27 | typedef std::function RequestCallback; 28 | typedef std::function 29 | ParentConnectionReceivedCallback; 30 | typedef std::function ResponseCallback; 31 | typedef std::function 32 | ParentConnectionClosedCallback; 33 | typedef std::function 34 | ChildConnectionClosedCallback; 35 | } // namespace oldisim 36 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/src/Log.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "oldisim/Log.h" 16 | 17 | #include 18 | #include 19 | 20 | log_level_t log_level = INFO; 21 | 22 | void log_file_line(log_level_t level, const char *file, int line, 23 | const char *format, ...) { 24 | if (level < log_level) { 25 | return; 26 | } 27 | 28 | va_list args; 29 | char new_format[512]; 30 | 31 | snprintf(new_format, sizeof(new_format), "%s(%d): %s\n", file, line, format); 32 | 33 | va_start(args, format); 34 | vfprintf(stderr, new_format, args); 35 | va_end(args); 36 | } 37 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/src/NodeThread.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "oldisim/NodeThread.h" 16 | 17 | #include "NodeThreadImpl.h" 18 | #include "oldisim/ChildConnection.h" 19 | 20 | namespace oldisim { 21 | 22 | NodeThread::NodeThread() : impl_(new NodeThreadImpl()) {} 23 | 24 | int NodeThread::get_thread_num() const { return impl_->thread_num; } 25 | 26 | pthread_t NodeThread::get_pthread() const { return impl_->pt; } 27 | 28 | event_base* NodeThread::get_event_base() const { return impl_->base; } 29 | } // namespace oldisim 30 | 31 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/src/NodeThreadImpl.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // -*- c++-mode -*- 16 | 17 | #ifndef NODE_THREAD_IMPL_H 18 | #define NODE_THREAD_IMPL_H 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace oldisim { 27 | 28 | class ChildConnection; 29 | 30 | struct NodeThread::NodeThreadImpl { 31 | pthread_t pt; // pthread handle 32 | event_base* base; // Event base handle 33 | int thread_num; // Numbered starting from 0 34 | }; 35 | } 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/src/ParentConnectionImpl.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // -*- c++-mode -*- 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "oldisim/Callbacks.h" 27 | #include "InternalCallbacks.h" 28 | #include "oldisim/NodeThread.h" 29 | #include "oldisim/ParentConnection.h" 30 | 31 | namespace oldisim { 32 | 33 | struct ParentConnection::ParentConnectionImpl { 34 | const ParentConnectionReceivedCallback request_handler; 35 | 36 | bufferevent* const bev; 37 | 38 | typedef std::function ClosedCallback; 39 | ClosedCallback closed_cb; 40 | 41 | enum class ReadState { 42 | INIT_READ, 43 | WAITING, 44 | CLOSED, 45 | }; 46 | ReadState read_state; 47 | 48 | std::mutex sending_lock; 49 | bool use_locking; 50 | 51 | ParentConnectionImpl(const ParentConnectionReceivedCallback& _request_handler, 52 | const ClosedCallback& _closed_cb, bufferevent* _bev, 53 | bool _use_locking); 54 | ~ParentConnectionImpl(); 55 | 56 | static void bev_event_cb(struct bufferevent* bev, int16_t events, void* ptr); 57 | static void bev_read_cb(struct bufferevent* bev, void* ptr); 58 | static void bev_write_cb(struct bufferevent* bev, void* ptr); 59 | }; 60 | } // namespace oldisim 61 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/oldisim/src/ResponseContext.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "oldisim/ResponseContext.h" 16 | 17 | namespace oldisim { 18 | 19 | ResponseContext::ResponseContext(uint32_t _type, uint64_t _request_id, 20 | uint32_t _payload_length, 21 | uint32_t _packet_length, const void* _payload, 22 | bool _timed_out, uint64_t _request_timestamp, 23 | uint64_t _response_timestamp) 24 | : type(_type), 25 | request_id(_request_id), 26 | payload_length(_payload_length), 27 | payload(_payload), 28 | timed_out(_timed_out), 29 | request_timestamp(_request_timestamp), 30 | response_timestamp(_response_timestamp) {} 31 | } // namespace oldisim 32 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/patches/0001-Inline-util-functions-to-make-it-linkable.patch: -------------------------------------------------------------------------------- 1 | From b88b8f800bd60b75ae67a6e91c9317bd445a26bd Mon Sep 17 00:00:00 2001 2 | From: "Carlos L. Torres" 3 | Date: Thu, 7 Nov 2019 15:22:50 -0800 4 | Subject: [PATCH] Inline util functions to make it linkable 5 | 6 | --- 7 | src/util.h | 10 +++++----- 8 | 1 file changed, 5 insertions(+), 5 deletions(-) 9 | 10 | diff --git a/src/util.h b/src/util.h 11 | index d335ec5..4cd345b 100644 12 | --- a/src/util.h 13 | +++ b/src/util.h 14 | @@ -22,26 +22,26 @@ Miscellaneous helpers that don't fit into classes 15 | static const int64_t kRandSeed = 27491095; 16 | 17 | 18 | -void PrintLabel(const std::string &label, const std::string &val) { 19 | +inline void PrintLabel(const std::string &label, const std::string &val) { 20 | printf("%-21s%7s\n", (label + ":").c_str(), val.c_str()); 21 | } 22 | 23 | -void PrintTime(const std::string &s, double seconds) { 24 | +inline void PrintTime(const std::string &s, double seconds) { 25 | printf("%-21s%3.5lf\n", (s + ":").c_str(), seconds); 26 | } 27 | 28 | -void PrintStep(const std::string &s, int64_t count) { 29 | +inline void PrintStep(const std::string &s, int64_t count) { 30 | printf("%-14s%14" PRId64 "\n", (s + ":").c_str(), count); 31 | } 32 | 33 | -void PrintStep(int step, double seconds, int64_t count = -1) { 34 | +inline void PrintStep(int step, double seconds, int64_t count = -1) { 35 | if (count != -1) 36 | printf("%5d%11" PRId64 " %10.5lf\n", step, count, seconds); 37 | else 38 | printf("%5d%23.5lf\n", step, seconds); 39 | } 40 | 41 | -void PrintStep(const std::string &s, double seconds, int64_t count = -1) { 42 | +inline void PrintStep(const std::string &s, double seconds, int64_t count = -1) { 43 | if (count != -1) 44 | printf("%5s%11" PRId64 " %10.5lf\n", s.c_str(), count, seconds); 45 | else 46 | -- 47 | 2.17.1 48 | 49 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/patches/0002-gapbs-Add-dummy-PageRank-class-for-passing-parameter.patch: -------------------------------------------------------------------------------- 1 | From 5b05bcdb4e2a2cbb1b0a68d2f9cd4819cf8fe1e1 Mon Sep 17 00:00:00 2001 2 | From: "Carlos L. Torres" 3 | Date: Fri, 8 Nov 2019 14:32:24 -0800 4 | Subject: [PATCH] [gapbs] Add dummy PageRank class for passing parameters 5 | 6 | --- 7 | src/command_line.h | 26 ++++++++++++++++++++++++++ 8 | 1 file changed, 26 insertions(+) 9 | 10 | diff --git a/src/command_line.h b/src/command_line.h 11 | index a719977..6942c85 100644 12 | --- a/src/command_line.h 13 | +++ b/src/command_line.h 14 | @@ -188,6 +188,32 @@ class CLPageRank : public CLApp { 15 | double tolerance() const { return tolerance_; } 16 | }; 17 | 18 | +class CLPageRankDummy : public CLBase { 19 | + bool do_analysis_ = false; 20 | + int num_trials_ = 16; 21 | + int64_t start_vertex_ = -1; 22 | + bool do_verify_ = false; 23 | + 24 | + int max_iters_; 25 | + double tolerance_; 26 | + 27 | + public: 28 | + CLPageRankDummy( 29 | + int scale, int degree, bool uniform, int num_trials, 30 | + double tolerance, int max_iters) : CLBase(0, nullptr, "pagerankdummy") { 31 | + tolerance_ = tolerance; 32 | + max_iters_ = max_iters; 33 | + num_trials_ = num_trials; 34 | + scale_ = scale; 35 | + degree_ = degree; 36 | + symmetrize_ = false; 37 | + uniform_ = uniform; 38 | + } 39 | + 40 | + bool ParseArgs() { return true; }; 41 | + 42 | +}; 43 | + 44 | 45 | 46 | template 47 | -- 48 | 2.17.1 49 | 50 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | function clean_up { 8 | # Clean up before exiting script 9 | kill %socat 10 | unset HTTPS_PROXY 11 | unset HTTP_PROXY 12 | unset no_proxy 13 | } 14 | trap clean_up EXIT 15 | 16 | export no_proxy=".fbcdn.net,.facebook.com,.thefacebook.com,.tfbnw.net,.fb.com,.fburl.com,.facebook.net,.sb.fbsbx.com,localhost" 17 | 18 | # Set up the fwdproxy for devservers 19 | socat tcp-listen:9876,fork \ 20 | openssl-connect:fwdproxy:8082,cert=/var/facebook/x509_identities/server.pem,cafile=/var/facebook/rootcanal/ca.pem,commonname=svc:fwdproxy & 21 | 22 | set -e 23 | HTTPS_PROXY='http://localhost:9876' HTTP_PROXY='http://localhost:9876' cmake ../ -G "Ninja" -DCMAKE_BUILD_TYPE=Release 24 | ninja 25 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/scripts/start_leaf_node_rank.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | MALLOC_CONF=narenas:20,dirty_decay_ms:5000 build/workloads/ranking/LeafNodeRank \ 8 | --graph_scale=20 \ 9 | --graph_subset=1572864 \ 10 | --threads=36 \ 11 | --cpu_threads=22 \ 12 | --timekeeper_threads=2 \ 13 | --io_threads=4 \ 14 | --srv_threads=8 \ 15 | --srv_io_threads=36 \ 16 | --num_objects=2000 \ 17 | --graph_max_iters=1 \ 18 | --noaffinity \ 19 | --min_icache_iterations=1600000 20 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | cmake_minimum_required(VERSION 3.12) 7 | project(oldisim_workloads) 8 | 9 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 10 | 11 | add_subdirectory(simple) 12 | add_subdirectory(search) 13 | add_subdirectory(ranking) 14 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/DriverNodeRankCmdline.ggo: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All Rights Reserved. 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | package "DriverNodeRank" 17 | version "0.1" 18 | usage "DriverNodeRank [options]" 19 | description "Test driving node for search" 20 | 21 | args "-c cc --show-required -C --default-optional -l" 22 | 23 | option "verbose" v "Verbosity. Repeat for more verbose." multiple 24 | option "quiet" - "Disable log messages." 25 | 26 | option "threads" - "Number of threads to spawn." int default="1" 27 | option "server" - "Address of parent node hostname[:port]." string 28 | option "connections" - "Connections to establish per thread." int default="1" 29 | option "depth" - "Maximum depth to pipeline requests per thread." int default="1" 30 | option "qps" - "Rate to send requests at. 0 means send as fast as it can." float default="0" 31 | 32 | option "monitor_port" - "Port to run monitoring server on." int default="7777" 33 | 34 | option "affinity" - "Set distinct CPU affinity for threads, round-robin" 35 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/ParentNodeRankCmdline.ggo: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All Rights Reserved. 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | package "ParentNodeRank" 17 | version "0.1" 18 | usage "ParentNodeRank [options]" 19 | description "Sample ranking workload: parent node" 20 | 21 | args "-c cc --show-required -C --default-optional -l" 22 | 23 | option "verbose" v "Verbosity. Repeat for more verbose." multiple 24 | option "quiet" - "Disable log messages." 25 | 26 | option "max_response_size" - "Maximum response size in bytes returned by the Parent." int default="8192" 27 | option "threads" - "Number of threads to use for serving." int default="1" 28 | option "port" - "Port to run server on." int default="11333" 29 | option "leaf" - "search leaf server hostname[:port]. Repeat to specify multiple servers." string multiple 30 | option "monitor_port" - "Port to run monitoring server on." int default="9999" 31 | option "connections" - "Number of connections per thread per leaf." int default="1" 32 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/RequestTypes.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef REQUEST_TYPES_H 16 | #define REQUEST_TYPES_H 17 | 18 | namespace ranking { 19 | 20 | static const int kPageRankRequestType = 0; 21 | } // namespace ranking 22 | 23 | #endif // REQUEST_TYPES_H 24 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/TimekeeperPool.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "TimekeeperPool.h" 16 | 17 | namespace ranking { 18 | TimekeeperPool::TimekeeperPool(int numTimekeepers) { 19 | for (int i = 0; i < numTimekeepers; i++) { 20 | timekeepers_.push_back(std::make_shared()); 21 | } 22 | } 23 | 24 | std::shared_ptr 25 | TimekeeperPool::getTimekeeper() const { 26 | if (timekeepers_.size() > 1) { 27 | static thread_local int64_t numCalls{0}; 28 | return timekeepers_[numCalls++ % timekeepers_.size()]; 29 | } else { 30 | return timekeepers_.front(); 31 | } 32 | } 33 | } // namespace ranking 34 | 35 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/TimekeeperPool.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #pragma once 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | namespace ranking { 22 | 23 | class TimekeeperPool { 24 | public: 25 | explicit TimekeeperPool(int numTimekeepers); 26 | ~TimekeeperPool() = default; 27 | 28 | TimekeeperPool(const TimekeeperPool &) = delete; 29 | TimekeeperPool &operator=(const TimekeeperPool &) = delete; 30 | 31 | std::shared_ptr getTimekeeper() const; 32 | 33 | private: 34 | std::vector> timekeepers_; 35 | }; 36 | 37 | } // namespace ranking 38 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_constants.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Thrift Compiler (0.13.0) 3 | * 4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | * @generated 6 | */ 7 | #include "ranking_constants.h" 8 | 9 | namespace ranking { 10 | 11 | const rankingConstants g_ranking_constants; 12 | 13 | rankingConstants::rankingConstants() { 14 | } 15 | 16 | } // namespace 17 | 18 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/gen-cpp/ranking_constants.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Thrift Compiler (0.13.0) 3 | * 4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | * @generated 6 | */ 7 | #ifndef ranking_CONSTANTS_H 8 | #define ranking_CONSTANTS_H 9 | 10 | #include "ranking_types.h" 11 | 12 | namespace ranking { 13 | 14 | class rankingConstants { 15 | public: 16 | rankingConstants(); 17 | 18 | }; 19 | 20 | extern const rankingConstants g_ranking_constants; 21 | 22 | } // namespace 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/if/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | thrift_library( 2 | "ranking" 3 | "" # services 4 | "cpp2" # Language generator 5 | "" # Options 6 | "${CMAKE_CURRENT_LIST_DIR}" # Directory where thrift file lives 7 | "${CMAKE_CURRENT_LIST_DIR}" # Directory where thrift objects will be built 8 | "ranking/if" 9 | ) 10 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/if/gen-cpp2/ranking_constants.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Thrift 3 | * 4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | * @generated 6 | */ 7 | 8 | #include "ranking/if/gen-cpp2/ranking_constants.h" 9 | 10 | #include 11 | 12 | 13 | namespace ranking { 14 | 15 | } // ranking 16 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/if/gen-cpp2/ranking_constants.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Thrift 3 | * 4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | * @generated 6 | */ 7 | #pragma once 8 | 9 | #include 10 | 11 | #include "ranking/if/gen-cpp2/ranking_types.h" 12 | 13 | namespace ranking { 14 | 15 | struct ranking_constants { 16 | 17 | }; 18 | 19 | } // ranking 20 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/if/gen-cpp2/ranking_data.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Thrift 3 | * 4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | * @generated 6 | */ 7 | 8 | #include "ranking/if/gen-cpp2/ranking_data.h" 9 | 10 | #include 11 | 12 | namespace ranking { 13 | 14 | constexpr const std::size_t _RankingStoryTypeEnumDataStorage::size; 15 | constexpr const std::array _RankingStoryTypeEnumDataStorage::values; 16 | constexpr const std::array _RankingStoryTypeEnumDataStorage::names; 17 | 18 | } // ranking 19 | 20 | namespace ranking { 21 | 22 | constexpr const std::size_t _RankingObjectTypeEnumDataStorage::size; 23 | constexpr const std::array _RankingObjectTypeEnumDataStorage::values; 24 | constexpr const std::array _RankingObjectTypeEnumDataStorage::names; 25 | 26 | } // ranking 27 | 28 | 29 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/if/gen-cpp2/ranking_types_custom_protocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Autogenerated by Thrift 3 | * 4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | * @generated 6 | */ 7 | #pragma once 8 | 9 | 10 | /** 11 | * This header file includes the tcc files of the corresponding header file 12 | * and the header files of its dependent types. Include this header file 13 | * only when you need to use custom protocols (e.g. DebugProtocol, 14 | * VirtualProtocol) to read/write thrift structs. 15 | */ 16 | 17 | #include "ranking/if/gen-cpp2/ranking_types.tcc" 18 | 19 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/ranking/utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | // 3 | // This source code is licensed under the MIT license found in the 4 | // LICENSE file in the root directory of this source tree. 5 | 6 | #ifndef UTILS_H 7 | #define UTILS_H 8 | 9 | #include 10 | #include 11 | 12 | namespace ranking { 13 | namespace utils { 14 | std::pair parseHostnameAndPort(const std::string &address) { 15 | std::stringstream s_stream{address}; 16 | std::string hostname; 17 | if (!s_stream.good()) { 18 | DIE("Failed to parse %s", address.c_str()); 19 | } 20 | std::getline(s_stream, hostname, ':'); 21 | int port = 11222; 22 | if (s_stream.good()) { 23 | std::string s; 24 | std::getline(s_stream, s, ':'); 25 | port = std::strtol(s.c_str(), NULL, 10); 26 | } 27 | return std::make_pair(hostname, port); 28 | } 29 | } // namespace utils 30 | } // namespace ranking 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/DriverNodeCmdline.ggo: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All Rights Reserved. 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | package "DriverNode" 17 | version "0.1" 18 | usage "DriverNode [options]" 19 | description "Test driving node for search" 20 | 21 | args "-c cc --show-required -C --default-optional -l" 22 | 23 | option "verbose" v "Verbosity. Repeat for more verbose." multiple 24 | option "quiet" - "Disable log messages." 25 | 26 | option "threads" - "Number of threads to spawn." int default="1" 27 | option "server" - "Address of parent node hostname[:port]." string 28 | option "connections" - "Connections to establish per thread." int default="1" 29 | option "depth" - "Maximum depth to pipeline requests per thread." int default="1" 30 | option "qps" - "Rate to send requests at. 0 means send as fast as it can." float default="0" 31 | 32 | option "monitor_port" - "Port to run monitoring server on." int default="7777" 33 | 34 | option "affinity" - "Set distinct CPU affinity for threads, round-robin" 35 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/HistogramRandomSampler.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "HistogramRandomSampler.h" 21 | 22 | HistogramRandomSampler::HistogramRandomSampler() : count_sum_(0) { InitRNG(); } 23 | 24 | HistogramRandomSampler::HistogramRandomSampler(std::string histogram_file) 25 | : count_sum_(0) { 26 | // Initialize RNG seed 27 | InitRNG(); 28 | 29 | // Read the file, which is a tab delimited file of 30 | // START END COUNT 31 | std::ifstream input_file(histogram_file.c_str()); 32 | std::string line; 33 | 34 | while (std::getline(input_file, line)) { 35 | int start, end, count; 36 | std::istringstream ss(line); 37 | ss >> start >> end >> count; 38 | 39 | AddBin(start, end, count); 40 | } 41 | } 42 | 43 | void HistogramRandomSampler::AddBin(int start, int end, int count) { 44 | bins_.push_back(Bin({start, end, count})); 45 | count_sum_ += count; 46 | } 47 | 48 | int HistogramRandomSampler::Sample() { 49 | int r = rng_() % count_sum_; 50 | // Locate the bin to use 51 | for (const auto& bin : bins_) { 52 | if (r < bin.count) { 53 | return (rng_() % (bin.end - bin.start)) + bin.start; 54 | } else { 55 | r -= bin.count; 56 | } 57 | } 58 | 59 | assert(false); 60 | return -1; 61 | } 62 | 63 | void HistogramRandomSampler::InitRNG() { 64 | unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); 65 | rng_.seed(seed); 66 | } 67 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/HistogramRandomSampler.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #pragma once 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | class HistogramRandomSampler { 21 | public: 22 | HistogramRandomSampler(); 23 | explicit HistogramRandomSampler(std::string histogram_file); 24 | void AddBin(int start, int end, int count); 25 | int Sample(); 26 | 27 | private: 28 | void InitRNG(); 29 | struct Bin { 30 | int start; 31 | int end; 32 | int count; 33 | }; 34 | std::vector bins_; 35 | int count_sum_; 36 | std::default_random_engine rng_; 37 | }; 38 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/ICacheBusterTest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "oldisim/Util.h" 18 | #include "ICacheBusterTestCmdline.h" 19 | #include "ICacheBuster.h" 20 | 21 | static gengetopt_args_info args; 22 | 23 | int main(int argc, char** argv) { 24 | // Parse arguments 25 | if (cmdline_parser(argc, argv, &args) != 0) { 26 | DIE("cmdline_parser failed"); 27 | } 28 | 29 | // Create i cache chaser 30 | ICacheBuster buster(args.size_arg); 31 | 32 | uint64_t start_time = GetTimeAccurateNano(); 33 | for (int i = 0; i < args.iterations_arg; i++) { 34 | buster.RunNextMethod(); 35 | } 36 | uint64_t end_time = GetTimeAccurateNano(); 37 | 38 | std::cout << "Time per call: " 39 | << static_cast(end_time - start_time) / 40 | (static_cast(args.iterations_arg)) 41 | << " ns" << std::endl; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/ICacheBusterTestCmdline.ggo: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package "ICacheBusterTest" 16 | version "0.1" 17 | usage "ICacheBusterTest [options]" 18 | description "Test program for icache busting" 19 | 20 | args "-c cc --show-required -C --default-optional -l" 21 | 22 | option "size" - "Number of methods to run through." int default="1" 23 | option "iterations" - "Number of iterations to run." int default="1000000" 24 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/LeafKernel.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "oldisim/Util.h" 18 | #include "PointerChase.h" 19 | #include "ICacheBuster.h" 20 | 21 | const int kPointerChaseSize = 10000000; 22 | const int kICacheBusterSize = 100000; 23 | const int kNumNops = 6; 24 | const int kNumNopIterations = 60; 25 | const int kNumIterations = 100000000; 26 | 27 | int main(int argc, char** argv) { 28 | // Create pointer chaser 29 | search::PointerChase chaser(kPointerChaseSize); 30 | 31 | // Create i cache chaser 32 | ICacheBuster buster(kICacheBusterSize); 33 | 34 | uint64_t start_time = GetTimeAccurateNano(); 35 | for (int i = 0; i < kNumIterations; i++) { 36 | buster.RunNextMethod(); 37 | chaser.Chase(1); 38 | for (int j = 0; j < kNumNopIterations; j++) { 39 | for (int k = 0; k < kNumNops; k++) { 40 | asm volatile("nop"); 41 | } 42 | } 43 | } 44 | uint64_t end_time = GetTimeAccurateNano(); 45 | 46 | std::cout << "Time per iteration: " 47 | << static_cast(end_time - start_time) / 48 | (static_cast(kNumIterations)) 49 | << " ns" << std::endl; 50 | 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/LeafNodeCmdline.ggo: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package "LeafNode" 16 | version "0.1" 17 | usage "LeafNode [options]" 18 | description "Sample web search workload: leaf node" 19 | 20 | args "-c cc --show-required -C --default-optional -l" 21 | 22 | option "verbose" v "Verbosity. Repeat for more verbose." multiple 23 | option "quiet" - "Disable log messages." 24 | 25 | option "threads" - "Number of threads to use for serving." int default="1" 26 | option "port" - "Port to run server on." int default="11222" 27 | option "monitor_port" - "Port to run monitoring server on." int default="8888" 28 | option "noaffinity" - "Specify to disable thread pinning" 29 | option "noloadbalance" - "Specify to disable thread load balancing" 30 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/LoadBalancerNodeCmdline.ggo: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package "LoadBalancerNode" 16 | version "0.1" 17 | usage "LoadBalancerNode [options]" 18 | description "Sample web search workload: load balancer node" 19 | 20 | args "-c cc --show-required -C --default-optional -l" 21 | 22 | option "verbose" v "Verbosity. Repeat for more verbose." multiple 23 | option "quiet" - "Disable log messages." 24 | 25 | option "threads" - "Number of threads to use for serving." int default="1" 26 | option "port" - "Port to run server on." int default="11222" 27 | option "parent" - "search parent server hostname[:port]. Repeat to specify multiple servers." string multiple 28 | option "monitor_port" - "Port to run monitoring server on." int default="8888" 29 | option "connections" - "Number of connections per thread per leaf." int default="1" 30 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/NopLoop.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | 18 | #include "oldisim/Util.h" 19 | 20 | const int kNumNops = 6; 21 | const uint64_t kNumIterations = 100000000; 22 | 23 | int main(int argc, char** argv) { 24 | uint64_t start_time = GetTimeAccurateNano(); 25 | for (uint64_t i = 0; i < kNumIterations; i++) { 26 | for (int j = 0; j < kNumNops; j++) { 27 | asm volatile("nop"); 28 | } 29 | } 30 | uint64_t end_time = GetTimeAccurateNano(); 31 | 32 | std::cout << "Time per iteration: " 33 | << static_cast(end_time - start_time) / 34 | (static_cast(kNumIterations)) 35 | << " ns" << std::endl; 36 | 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/ParentNodeCmdline.ggo: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All Rights Reserved. 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | package "ParentNode" 17 | version "0.1" 18 | usage "ParentNode [options]" 19 | description "Sample web search workload: parent node" 20 | 21 | args "-c cc --show-required -C --default-optional -l" 22 | 23 | option "verbose" v "Verbosity. Repeat for more verbose." multiple 24 | option "quiet" - "Disable log messages." 25 | 26 | option "threads" - "Number of threads to use for serving." int default="1" 27 | option "port" - "Port to run server on." int default="11333" 28 | option "leaf" - "search leaf server hostname[:port]. Repeat to specify multiple servers." string multiple 29 | option "monitor_port" - "Port to run monitoring server on." int default="9999" 30 | option "connections" - "Number of connections per thread per leaf." int default="1" 31 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/PointerChase.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "PointerChase.h" 21 | 22 | namespace search { 23 | 24 | PointerChase::PointerChase(size_t num_elems) 25 | : data_(num_elems), current_index_(0) { 26 | // Fill data with [0, num_elems) 27 | std::iota(data_.begin(), data_.end(), 0); 28 | 29 | // Make a random permutation over data 30 | unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); 31 | std::shuffle(data_.begin(), data_.end(), std::default_random_engine(seed)); 32 | } 33 | 34 | void PointerChase::Chase(size_t num_iterations) { 35 | for (size_t i = 0; i < num_iterations; i++) { 36 | current_index_ = data_[current_index_]; 37 | } 38 | } 39 | } // namespace search 40 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/PointerChase.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | #pragma once 15 | 16 | #include 17 | 18 | #include 19 | 20 | namespace search { 21 | 22 | class PointerChase { 23 | public: 24 | explicit PointerChase(size_t num_elems); 25 | void Chase(size_t num_iterations); 26 | 27 | private: 28 | std::vector data_; 29 | size_t current_index_; 30 | }; 31 | } // namespace search 32 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/PointerChaseTest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "oldisim/Util.h" 18 | #include "PointerChaseTestCmdline.h" 19 | #include "PointerChase.h" 20 | 21 | static gengetopt_args_info args; 22 | 23 | int main(int argc, char** argv) { 24 | // Parse arguments 25 | if (cmdline_parser(argc, argv, &args) != 0) { 26 | DIE("cmdline_parser failed"); 27 | } 28 | 29 | // Create pointer chaser 30 | search::PointerChase chaser(args.size_arg); 31 | 32 | uint64_t start_time = GetTimeAccurateNano(); 33 | for (int i = 0; i < args.iterations_arg; i++) { 34 | chaser.Chase(args.length_arg); 35 | } 36 | uint64_t end_time = GetTimeAccurateNano(); 37 | 38 | std::cout << "Time per access: " 39 | << static_cast(end_time - start_time) / 40 | (static_cast(args.iterations_arg) * args.length_arg) 41 | << " ns" << std::endl; 42 | 43 | return 0; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/PointerChaseTestCmdline.ggo: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package "PointerChaseTest" 16 | version "0.1" 17 | usage "PointerChaseTest [options]" 18 | description "Test program for pointer chasing" 19 | 20 | args "-c cc --show-required -C --default-optional -l" 21 | 22 | option "size" - "Number of elements to allocate." int default="1" 23 | option "iterations" - "Number of iterations to run." int default="1000000" 24 | option "length" - "Number of elements to chase each iteration." int default="1" 25 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/RequestTypes.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef REQUEST_TYPES_H 16 | #define REQUEST_TYPES_H 17 | 18 | namespace search { 19 | 20 | static const int kSearchRequestType = 0; 21 | } // namespace search 22 | 23 | #endif // REQUEST_TYPES_H 24 | 25 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/search/Util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef UTIL_H 16 | #define UTIL_H 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "oldisim/Log.h" 26 | 27 | namespace search { 28 | 29 | /** 30 | * Parse a server address specification of the form host[:port] and 31 | * returns the host name and the port. If no port is specified, the default 32 | * port of 11222 is used. 33 | */ 34 | void ParseServerAddress(const std::string& server_address, 35 | std::string& out_host, int& out_port) { 36 | std::unique_ptr s_copy(new char[server_address.length() + 1]); 37 | snprintf(s_copy.get(), sizeof(char) * (server_address.length() + 1), "%s", 38 | server_address.c_str()); 39 | 40 | char* saveptr = NULL; // For reentrant strtok(). 41 | 42 | const char* host_ptr = strtok_r(s_copy.get(), ":", &saveptr); 43 | const char* port_ptr = strtok_r(NULL, ":", &saveptr); 44 | 45 | // Check to see if host could be parsed 46 | if (host_ptr == NULL) { 47 | DIE("strtok(.., \":\") failed to parse %s", server_address.c_str()); 48 | } 49 | 50 | out_host = std::string(host_ptr); 51 | 52 | // Assign default port if no port specified 53 | if (port_ptr == NULL) { 54 | out_port = 11222; 55 | } else { 56 | out_port = std::strtol(port_ptr, NULL, 10); 57 | } 58 | } 59 | } // namespace search 60 | 61 | #endif // UTIL_H 62 | -------------------------------------------------------------------------------- /packages/feedsim/third_party/src/workloads/simple/DriverNodeTestFrameworkCmdline.ggo: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | package "DriverNodeTestFramework" 16 | version "0.1" 17 | usage "DriverNodeTestFramework [options]" 18 | description "Sample program to demonstrate a test driving node" 19 | 20 | args "-c cc --show-required -C --default-optional -l" 21 | 22 | option "verbose" v "Verbosity. Repeat for more verbose." multiple 23 | option "quiet" - "Disable log messages." 24 | 25 | option "threads" - "Number of threads to spawn." int default="1" 26 | option "server" - "Hostname of service to test." string 27 | option "port" - "Port of service to test on." int default="46645" 28 | option "connections" - "Connections to establish per thread." int default="1" 29 | option "depth" - "Maximum depth to pipeline requests per thread." int default="1" 30 | 31 | option "affinity" - "Set distinct CPU affinity for threads, round-robin" 32 | -------------------------------------------------------------------------------- /packages/health_check/cleanup_health_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | BPKGS_HEATH_ROOT="$(dirname "$(readlink -f "$0")")" # Path to dir with this file. 8 | BENCHPRESS_ROOT="$(readlink -f "$BPKGS_HEATH_ROOT/../..")" 9 | HEALTH_ROOT="${BENCHPRESS_ROOT}/benchmarks/health_check" 10 | 11 | rm -rf "$HEALTH_ROOT" 12 | -------------------------------------------------------------------------------- /packages/health_check/collect-cpu-util.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | import subprocess 8 | import sys 9 | import threading 10 | import time 11 | 12 | 13 | keys = ["user", "nice", "sys", "idle", "iowait", "irq", "softirq", "steal", "guest"] 14 | cpu_util = {} 15 | 16 | 17 | def get_cpu_ticks(): 18 | with open("/proc/stat", "r") as f: 19 | cpu = f.readline() 20 | curr_ticks = [int(x) for x in cpu.split()[1:]] 21 | return curr_ticks 22 | 23 | 24 | def calc_cpu_util(end_ticks, start_ticks): 25 | diff_ticks = [] 26 | cpu_util = {} 27 | for i in range(len(keys)): 28 | diff_ticks.append(end_ticks[i] - start_ticks[i]) 29 | for category, tick in zip(keys, diff_ticks): 30 | cpu_util[category] = 100.0 * tick / sum(diff_ticks) 31 | return cpu_util 32 | 33 | 34 | if __name__ == "__main__": 35 | start_ticks = get_cpu_ticks() 36 | p = subprocess.Popen(sys.argv[1:]) 37 | ret = p.wait() 38 | end_ticks = get_cpu_ticks() 39 | cpu_util = calc_cpu_util(end_ticks, start_ticks) 40 | result = [] 41 | for key in keys: 42 | result.append(f"{cpu_util[key]:.2f}") 43 | print(",".join(result)) 44 | sys.exit(ret) 45 | -------------------------------------------------------------------------------- /packages/health_check/install_health_check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | set -Eeuo pipefail 7 | 8 | ##################### SYS CONFIG AND DEPS ######################### 9 | 10 | BPKGS_HEATH_ROOT="$(dirname "$(readlink -f "$0")")" # Path to dir with this file. 11 | BENCHPRESS_ROOT="$(readlink -f "$BPKGS_HEATH_ROOT/../..")" 12 | HEALTH_ROOT="${BENCHPRESS_ROOT}/benchmarks/health_check" 13 | 14 | # Determine OS version 15 | LINUX_DIST_ID="$(awk -F "=" '/^ID=/ {print $2}' /etc/os-release | tr -d '"')" 16 | 17 | if [ "$LINUX_DIST_ID" = "ubuntu" ]; then 18 | sudo apt install -y iperf3 19 | elif [ "$LINUX_DIST_ID" = "centos" ]; then 20 | sudo dnf install -y iperf3 21 | fi 22 | 23 | cd "$HEALTH_ROOT" 24 | # mm-mem: memory latency and bandwidth benchmark 25 | git clone "https://github.com/pkuwangh/mm-mem.git" 26 | cd mm-mem 27 | ./scripts/install_deps.py 28 | make 29 | cd .. 30 | 31 | # loaded-latency: memory latency and bandwidth benchmark for ARM 32 | git clone "https://github.com/ARM-software/infra-microbenchmarks" 33 | pushd infra-microbenchmarks/loaded-latency 34 | make 35 | popd 36 | 37 | # sleepbench: nanosleep overhead benchmark 38 | mkdir "$HEALTH_ROOT/sleepbench" 39 | cp "${BENCHPRESS_ROOT}/packages/health_check/sleepbench.cpp" "${HEALTH_ROOT}/sleepbench" 40 | cp "${BENCHPRESS_ROOT}/packages/health_check/collect-cpu-util.py" "${HEALTH_ROOT}/sleepbench" 41 | cd "$HEALTH_ROOT/sleepbench" 42 | g++ -o sleepbench -O2 -lpthread sleepbench.cpp 43 | cp "${BENCHPRESS_ROOT}/packages/health_check/run.sh" "${HEALTH_ROOT}/run.sh" 44 | -------------------------------------------------------------------------------- /packages/mediawiki/0002-memcached-centos9-compat.diff: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | diff --git a/hash.c b/hash.c 6 | index a0c3036..b5ff28a 100644 7 | --- a/hash.c 8 | +++ b/hash.c 9 | @@ -4,6 +4,8 @@ 10 | #include "jenkins_hash.h" 11 | #include "murmur3_hash.h" 12 | 13 | +hash_func hash; 14 | + 15 | int hash_init(enum hashfunc_type type) { 16 | switch(type) { 17 | case JENKINS_HASH: 18 | diff --git a/hash.h b/hash.h 19 | index 059d1e2..3b2a984 100644 20 | --- a/hash.h 21 | +++ b/hash.h 22 | @@ -2,7 +2,7 @@ 23 | #define HASH_H 24 | 25 | typedef uint32_t (*hash_func)(const void *key, size_t length); 26 | -hash_func hash; 27 | +extern hash_func hash; 28 | 29 | enum hashfunc_type { 30 | JENKINS_HASH=0, MURMUR3_HASH 31 | -------------------------------------------------------------------------------- /packages/mediawiki/WrkStats.php: -------------------------------------------------------------------------------- 1 | ' 18 | $matches = array(); 19 | $match_res = preg_match('/([0-9A-Za-z ]+)\s*:\s*([0-9.]+)/', $line, &$matches); 20 | if ($match_res !== 1 || count($matches) < 3) { 21 | continue; 22 | } 23 | 24 | $key = trim($matches[1]); 25 | $value = trim($matches[2]); 26 | $value = preg_replace('/[^\d\.]/', '', $value); 27 | if (strpos($value, ".") !== false) { 28 | $value = (float)$value; 29 | } else { 30 | $value = (int)$value; 31 | } 32 | $result[$key] = $value; 33 | } 34 | return $result; 35 | } 36 | 37 | public function collectStats(): Map> { 38 | $stats = $this->extractKeysAndValues(file_get_contents($this->getLogFilePath())); 39 | return Map { 40 | 'Combined' => Map { 41 | 'Wrk requests' => (int) $stats['Transactions'], 42 | 'Wrk wall sec' => (float) $stats['Elapsed time'], 43 | 'Wrk RPS' => (float) $stats['Transaction rate'], 44 | 'Wrk successful requests' => (int) $stats['Successful transactions'], 45 | 'Wrk failed requests' => (int) $stats['Failed transactions'], 46 | }, 47 | }; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/mediawiki/cleanup_oss_performance_mediawiki.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | # 7 | MW_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) 8 | BENCHPRESS_ROOT="$(readlink -f "$MW_ROOT/../..")" 9 | 10 | sudo systemctl stop mariadb 11 | rm -rf "${BENCHPRESS_ROOT}/oss-performance" 12 | rm -rf "${BENCHPRESS_ROOT}/benchmarks/oss_performance_mediawiki" 13 | -------------------------------------------------------------------------------- /packages/mediawiki/grant_privileges.sql: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Meta Platforms, Inc. and affiliates. 2 | This source code is licensed under the MIT license found in the 3 | LICENSE file in the root directory of this source tree. 4 | */ 5 | GRANT ALL PRIVILEGES on *.* to 'root'@'localhost' IDENTIFIED BY 'password'; 6 | FLUSH PRIVILEGES; 7 | -------------------------------------------------------------------------------- /packages/mediawiki/my.cnf: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | # 6 | # This group is read both both by the client and the server 7 | # use it for options that affect everything 8 | # 9 | [client-server] 10 | 11 | # 12 | # include all files from the config directory 13 | # 14 | !includedir /etc/my.cnf.d 15 | 16 | [mysqld] 17 | max_connections=2048 18 | query_cache_type=0 # Disable query cache, can cause severe lock contention 19 | query_cache_size=0 20 | 21 | -------------------------------------------------------------------------------- /packages/mediawiki/nginx.repo: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | [nginx-stable] 7 | name=nginx stable repo 8 | baseurl=http://nginx.org/packages/amzn2/$releasever/$basearch/ 9 | gpgcheck=1 10 | enabled=1 11 | gpgkey=https://nginx.org/keys/nginx_signing.key 12 | module_hotfixes=true 13 | 14 | [nginx-mainline] 15 | name=nginx mainline repo 16 | baseurl=http://nginx.org/packages/mainline/amzn2/$releasever/$basearch/ 17 | gpgcheck=1 18 | enabled=0 19 | gpgkey=https://nginx.org/keys/nginx_signing.key 20 | module_hotfixes=true 21 | -------------------------------------------------------------------------------- /packages/mediawiki/perf-record.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | # 7 | 8 | sleep 30 9 | if [ -f "perf.data" ]; then 10 | exit 0; 11 | fi 12 | if [ "${DCPERF_PERF_RECORD}" = "1" ]; then 13 | sudo nohup bash -xec "sleep 30; timeout -s INT 5 perf record -a -g;" > /tmp/mw-perf-record.log 2>&1 & 14 | fi 15 | -------------------------------------------------------------------------------- /packages/mediawiki/update_mariadb_pwd.sql: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Meta Platforms, Inc. and affiliates. 2 | This source code is licensed under the MIT license found in the 3 | LICENSE file in the root directory of this source tree. 4 | */ 5 | UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; 6 | DELETE FROM mysql.user WHERE user='root' AND host NOT IN ('localhost', '127.0.0.1', '::1'); 7 | DELETE FROM mysql.user WHERE user=''; 8 | FLUSH PRIVILEGES; 9 | -------------------------------------------------------------------------------- /packages/spark_standalone/cleanup_spark_standalone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | # 7 | SPARKBENCH_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) 8 | BENCHPRESS_ROOT="$(readlink -f "${SPARKBENCH_ROOT}/../..")" 9 | 10 | rm -rf "${BENCHPRESS_ROOT}/benchmarks/spark_standalone" 11 | -------------------------------------------------------------------------------- /packages/spark_standalone/install_spark_standalone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | set -Eeuo pipefail 7 | 8 | SPARK_PKG_ROOT="$(dirname "$(readlink -f "$0")")" 9 | 10 | # benchmark binaries that we install here live in benchmarks/ 11 | TEMPLATES_DIR="${SPARK_PKG_ROOT}/templates" 12 | LINUX_DIST_ID="$(awk -F "=" '/^ID=/ {print $2}' /etc/os-release | tr -d '"')" 13 | 14 | # Install system dependencies 15 | if [ "$LINUX_DIST_ID" = "ubuntu" ]; then 16 | apt install -y openjdk-8-jdk fio 17 | apt install -y git-lfs 18 | elif [ "$LINUX_DIST_ID" = "centos" ]; then 19 | dnf install -y java-1.8.0-openjdk fio 20 | dnf install -y git-lfs 21 | fi 22 | 23 | # copy over directory 24 | if [ ! -d "${OUT}/scripts" ]; then 25 | cp -r "${TEMPLATES_DIR}/proj_root/scripts" "${OUT}/" 26 | fi 27 | if [ ! -d "${OUT}/settings" ]; then 28 | cp -r "${TEMPLATES_DIR}/proj_root/settings" "${OUT}/" 29 | fi 30 | 31 | # download spark 32 | pushd "${OUT}" || exit 1 33 | if [ ! -f spark-2.4.5-bin-hadoop2.7.tgz ]; then 34 | wget https://archive.apache.org/dist/spark/spark-2.4.5/spark-2.4.5-bin-hadoop2.7.tgz 35 | fi 36 | tar xzf spark-2.4.5-bin-hadoop2.7.tgz 37 | popd || exit 1 38 | 39 | # create sub directories 40 | mkdir -p "${OUT}/work" 41 | mkdir -p "${OUT}/dataset" 42 | 43 | echo "SPARK_Standalone installed into ./benchmarks/spark_standalone" 44 | -------------------------------------------------------------------------------- /packages/tao_bench/cleanup_tao_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | BPKGS_TAO_BENCH_ROOT="$(dirname "$(readlink -f "$0")")" 8 | BENCHPRESS_ROOT="$(readlink -f "$BPKGS_TAO_BENCH_ROOT/../..")" 9 | BENCHMARKS_DIR="${BENCHPRESS_ROOT}/benchmarks" 10 | TAO_BENCH_DIR="${BENCHMARKS_DIR}/tao_bench" 11 | 12 | rm -rf "$TAO_BENCH_DIR" 13 | -------------------------------------------------------------------------------- /packages/tao_bench/db_items.json: -------------------------------------------------------------------------------- 1 | { 2 | "valSizeRangeProbability" : [ 3 | 30000, 4 | 6000, 5 | 2000, 6 | 500, 7 | 10, 8 | 5, 9 | 1 10 | ], 11 | "valSizeRange" : [ 12 | 256, 13 | 1024, 14 | 2048, 15 | 4096, 16 | 8192, 17 | 16384, 18 | 32768, 19 | 65536 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /packages/tao_bench/install_tao_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | set -Eeuo pipefail 7 | 8 | # FIXME(cltorres): Copy/link bpkgs benchmark contents into the BP_TMP automatically. 9 | BPKGS_TAO_BENCH_ROOT="$(dirname "$(readlink -f "$0")")" # Path to dir with this file. 10 | 11 | # Use the alternative arch-specific installer scripts 12 | ARCH="$(uname -p)" 13 | "${BPKGS_TAO_BENCH_ROOT}"/install_tao_bench_"${ARCH}".sh 14 | exit $? 15 | -------------------------------------------------------------------------------- /packages/tao_bench/tao_bench: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | [manifest] 6 | name = tao_bench 7 | 8 | [download] 9 | url = http://www.memcached.org/files/memcached-1.6.5.tar.gz 10 | sha256 = 1f4da3706fc13c33be9df97b2c1c8d7b0891d5f0dc88aebc603cb178e68b27df 11 | 12 | [build.os=linux] 13 | builder = autoconf 14 | 15 | [build.not(os=linux)] 16 | builder = nop 17 | 18 | [dependencies] 19 | folly 20 | openssl 21 | lz4 22 | libevent 23 | boost 24 | glog 25 | 26 | [autoconf.args] 27 | --enable-tls=true 28 | -------------------------------------------------------------------------------- /packages/video_transcode_bench/0001-ffmpeg.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c 2 | index 2c99d792af..1d5745bf6b 100644 3 | --- a/libavfilter/vf_libvmaf.c 4 | +++ b/libavfilter/vf_libvmaf.c 5 | @@ -61,6 +61,7 @@ typedef struct LIBVMAFContext { 6 | unsigned model_cnt; 7 | unsigned frame_cnt; 8 | unsigned bpc; 9 | + int aom_ctc; 10 | #if CONFIG_LIBVMAF_CUDA_FILTER 11 | VmafCudaState *cu_state; 12 | #endif 13 | @@ -77,6 +78,7 @@ static const AVOption libvmaf_options[] = { 14 | {"n_subsample", "Set interval for frame subsampling used when computing vmaf.", OFFSET(n_subsample), AV_OPT_TYPE_INT, {.i64=1}, 1, UINT_MAX, FLAGS}, 15 | {"model", "Set the model to be used for computing vmaf.", OFFSET(model_cfg), AV_OPT_TYPE_STRING, {.str="version=vmaf_v0.6.1"}, 0, 1, FLAGS}, 16 | {"feature", "Set the feature to be used for computing vmaf.", OFFSET(feature_cfg), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, 17 | + {"aom_ctc", "Set the options for aom_ctc v1.0", OFFSET(aom_ctc), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS}, 18 | { NULL } 19 | }; 20 | 21 | @@ -441,6 +443,15 @@ static av_cold int init(AVFilterContext *ctx) 22 | if (err) 23 | return AVERROR(EINVAL); 24 | 25 | + if (s->aom_ctc) { 26 | + av_free(s->model_cfg); 27 | + av_free(s->feature_cfg); 28 | + s->model_cfg = av_strdup( 29 | + "version=vmaf_v0.6.1:name=vmaf|version=vmaf_v0.6.1neg:name=vmaf_neg"); 30 | + s->feature_cfg = av_strdup( 31 | + "name=psnr:reduced_hbd_peak=true:enable_apsnr=true:min_sse=0.5|" 32 | + "name=float_ssim:enable_db=true:clip_db=true"); 33 | + } 34 | err = parse_models(ctx); 35 | if (err) 36 | return err; 37 | -------------------------------------------------------------------------------- /packages/video_transcode_bench/0002-ffmpeg.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c 2 | index 8fa42d590b..e99c656c5d 100644 3 | --- a/libavcodec/libsvtav1.c 4 | +++ b/libavcodec/libsvtav1.c 5 | @@ -430,7 +430,7 @@ static av_cold int eb_enc_init(AVCodecContext *avctx) 6 | 7 | svt_enc->eos_flag = EOS_NOT_REACHED; 8 | 9 | - svt_ret = svt_av1_enc_init_handle(&svt_enc->svt_handle, svt_enc, &svt_enc->enc_params); 10 | + svt_ret = svt_av1_enc_init_handle(&svt_enc->svt_handle, &svt_enc->enc_params); 11 | if (svt_ret != EB_ErrorNone) { 12 | return svt_print_error(avctx, svt_ret, "Error initializing encoder handle"); 13 | } 14 | -------------------------------------------------------------------------------- /packages/video_transcode_bench/cleanup_video_transcode_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | BPKGS_FFMPEG_ROOT="$(dirname "$(readlink -f "$0")")" 8 | BENCHPRESS_ROOT="$(readlink -f "$BPKGS_FFMPEG_ROOT/../..")" 9 | BENCHMARKS_DIR="${BENCHPRESS_ROOT}/benchmarks" 10 | FFMPEG_DIR="${BENCHMARKS_DIR}/video_transcode_bench" 11 | 12 | rm -rf "$FFMPEG_DIR" 13 | -------------------------------------------------------------------------------- /packages/wdl_bench/aggregate_result.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | 8 | import glob 9 | import json 10 | import sys 11 | 12 | import parse_line 13 | 14 | sum_c = {} 15 | 16 | 17 | for n in glob.glob("output_file_*"): 18 | with open(n) as f: 19 | if sys.argv[1] == "lzbench": 20 | parse_line.parse_line_lzbench(f, sum_c) 21 | else: 22 | parse_line.parse_line(f, sum_c) 23 | 24 | out_file_name = "out_" + sys.argv[1] + ".json" 25 | with open(out_file_name, "w") as f: 26 | json.dump(sum_c, f, indent=4, sort_keys=True) 27 | -------------------------------------------------------------------------------- /packages/wdl_bench/cleanup_wdl_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | BPKGS_WDL_ROOT="$(dirname "$(readlink -f "$0")")" 8 | BENCHPRESS_ROOT="$(readlink -f "$BPKGS_WDL_ROOT/../..")" 9 | BENCHMARKS_DIR="${BENCHPRESS_ROOT}/benchmarks" 10 | WDL_DIR="${BENCHMARKS_DIR}/wdl_bench" 11 | 12 | rm -rf "$WDL_DIR" 13 | -------------------------------------------------------------------------------- /packages/wdl_bench/convert.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under the MIT license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | 8 | import json 9 | import sys 10 | 11 | import parse_line 12 | 13 | sum_c = {} 14 | 15 | input_file_name = "out_" + sys.argv[1] + ".txt" 16 | 17 | 18 | with open(input_file_name) as f: 19 | if sys.argv[1] == "concurrent_hash_map_benchmark": 20 | parse_line.parse_line_chm(f, sum_c) 21 | elif sys.argv[1] == "lzbench": 22 | parse_line.parse_line_lzbench(f, sum_c) 23 | elif sys.argv[1] == "openssl": 24 | parse_line.parse_line_openssl(f, sum_c) 25 | else: 26 | parse_line.parse_line(f, sum_c) 27 | 28 | out_file_name = "out_" + sys.argv[1] + ".json" 29 | with open(out_file_name, "w") as f: 30 | json.dump(sum_c, f, indent=4, sort_keys=True) 31 | -------------------------------------------------------------------------------- /perfutils/README.md: -------------------------------------------------------------------------------- 1 | # Performance Scripts for Different Architectures 2 | We provide performance scripts tailored for various architectures. These scripts are designed to collect real-time micro-architecture metrics during benchmark execution. After data collection, processing scripts are available to convert the data into a unified format for analysis. 3 | 4 | In addition to DCPerf, these scripts can be used in a standalone way. A typical flow is first `./collect_[arch]_perf_counter.sh > ./perf.txt` for several minutes, and then `./generate_[cpu]_report.py ./perf.txt` to see the results. 5 | 6 | # Supported Architectures 7 | ## AMD Zen3 8 | - Data Collection: collect_amd_perf_counters.sh 9 | - Data Processing: generate_amd_perf_report.py --arch zen3 10 | ## AMD Zen4 11 | - Data Collection: 12 | collect_amd_perf_counters.sh and 13 | collect_amd_zen4_perf_counters.sh 14 | - Data Processing: generate_amd_perf_report.py --arch zen4 15 | ## AMD Zen5 16 | - Data Collection: collect_amd_zen5_perf_counters.sh 17 | - Data Processing: generate_amd_perf_report.py --arch zen5 18 | ## AMD Zen5 Engineer Samples 19 | - Data Collection: collect_amd_zen5_perf_counters.sh 20 | - Data Processing: generate_amd_perf_report.py --arch zen5es 21 | ## ARM (NVIDIA Grace) 22 | - Data Collection: collect_nvda_neoversev2_perf_counters.sh 23 | - Data Processing: generate_arm_perf_report.py 24 | ## ARM (Other) 25 | 26 | Use [topdown tool](https://learn.arm.com/install-guides/topdown-tool/). 27 | --------------------------------------------------------------------------------