├── .github ├── LICENSE ├── README.md ├── scripts │ ├── export.sh │ ├── setup.sh │ └── tune.sh └── workflows │ ├── Dockerfile │ └── linux.yml ├── perf └── perf.cppm /.github/LICENSE: -------------------------------------------------------------------------------- 1 | > Copyright (c) 2024-2025 Kris Jusiak 2 | 3 | | license | namespace | guard | description | 4 | | ---------------- | -------------- | ---------------- | ---------------------------------- | 5 | | MIT [1] | `perf::*` | - | https://opensource.org/license/mit | 6 | | Apache2+LLVM [2] | `perf::mca::*` | `PERF_LLVM == 1` | https://llvm.org/LICENSE.txt | 7 | 8 | 9 | > [1] The MIT License (MIT) 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE. 28 | 29 | For more details, see https://opensource.org/license/mit 30 | 31 | > [2] Apache License v2.0 with LLVM Exceptions 32 | 33 | ============================================================================== 34 | The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: 35 | ============================================================================== 36 | 37 | Apache License 38 | Version 2.0, January 2004 39 | http://www.apache.org/licenses/ 40 | 41 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 42 | 43 | 1. Definitions. 44 | 45 | "License" shall mean the terms and conditions for use, reproduction, 46 | and distribution as defined by Sections 1 through 9 of this document. 47 | 48 | "Licensor" shall mean the copyright owner or entity authorized by 49 | the copyright owner that is granting the License. 50 | 51 | "Legal Entity" shall mean the union of the acting entity and all 52 | other entities that control, are controlled by, or are under common 53 | control with that entity. For the purposes of this definition, 54 | "control" means (i) the power, direct or indirect, to cause the 55 | direction or management of such entity, whether by contract or 56 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 57 | outstanding shares, or (iii) beneficial ownership of such entity. 58 | 59 | "You" (or "Your") shall mean an individual or Legal Entity 60 | exercising permissions granted by this License. 61 | 62 | "Source" form shall mean the preferred form for making modifications, 63 | including but not limited to software source code, documentation 64 | source, and configuration files. 65 | 66 | "Object" form shall mean any form resulting from mechanical 67 | transformation or translation of a Source form, including but 68 | not limited to compiled object code, generated documentation, 69 | and conversions to other media types. 70 | 71 | "Work" shall mean the work of authorship, whether in Source or 72 | Object form, made available under the License, as indicated by a 73 | copyright notice that is included in or attached to the work 74 | (an example is provided in the Appendix below). 75 | 76 | "Derivative Works" shall mean any work, whether in Source or Object 77 | form, that is based on (or derived from) the Work and for which the 78 | editorial revisions, annotations, elaborations, or other modifications 79 | represent, as a whole, an original work of authorship. For the purposes 80 | of this License, Derivative Works shall not include works that remain 81 | separable from, or merely link (or bind by name) to the interfaces of, 82 | the Work and Derivative Works thereof. 83 | 84 | "Contribution" shall mean any work of authorship, including 85 | the original version of the Work and any modifications or additions 86 | to that Work or Derivative Works thereof, that is intentionally 87 | submitted to Licensor for inclusion in the Work by the copyright owner 88 | or by an individual or Legal Entity authorized to submit on behalf of 89 | the copyright owner. For the purposes of this definition, "submitted" 90 | means any form of electronic, verbal, or written communication sent 91 | to the Licensor or its representatives, including but not limited to 92 | communication on electronic mailing lists, source code control systems, 93 | and issue tracking systems that are managed by, or on behalf of, the 94 | Licensor for the purpose of discussing and improving the Work, but 95 | excluding communication that is conspicuously marked or otherwise 96 | designated in writing by the copyright owner as "Not a Contribution." 97 | 98 | "Contributor" shall mean Licensor and any individual or Legal Entity 99 | on behalf of whom a Contribution has been received by Licensor and 100 | subsequently incorporated within the Work. 101 | 102 | 2. Grant of Copyright License. Subject to the terms and conditions of 103 | this License, each Contributor hereby grants to You a perpetual, 104 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 105 | copyright license to reproduce, prepare Derivative Works of, 106 | publicly display, publicly perform, sublicense, and distribute the 107 | Work and such Derivative Works in Source or Object form. 108 | 109 | 3. Grant of Patent License. Subject to the terms and conditions of 110 | this License, each Contributor hereby grants to You a perpetual, 111 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 112 | (except as stated in this section) patent license to make, have made, 113 | use, offer to sell, sell, import, and otherwise transfer the Work, 114 | where such license applies only to those patent claims licensable 115 | by such Contributor that are necessarily infringed by their 116 | Contribution(s) alone or by combination of their Contribution(s) 117 | with the Work to which such Contribution(s) was submitted. If You 118 | institute patent litigation against any entity (including a 119 | cross-claim or counterclaim in a lawsuit) alleging that the Work 120 | or a Contribution incorporated within the Work constitutes direct 121 | or contributory patent infringement, then any patent licenses 122 | granted to You under this License for that Work shall terminate 123 | as of the date such litigation is filed. 124 | 125 | 4. Redistribution. You may reproduce and distribute copies of the 126 | Work or Derivative Works thereof in any medium, with or without 127 | modifications, and in Source or Object form, provided that You 128 | meet the following conditions: 129 | 130 | (a) You must give any other recipients of the Work or 131 | Derivative Works a copy of this License; and 132 | 133 | (b) You must cause any modified files to carry prominent notices 134 | stating that You changed the files; and 135 | 136 | (c) You must retain, in the Source form of any Derivative Works 137 | that You distribute, all copyright, patent, trademark, and 138 | attribution notices from the Source form of the Work, 139 | excluding those notices that do not pertain to any part of 140 | the Derivative Works; and 141 | 142 | (d) If the Work includes a "NOTICE" text file as part of its 143 | distribution, then any Derivative Works that You distribute must 144 | include a readable copy of the attribution notices contained 145 | within such NOTICE file, excluding those notices that do not 146 | pertain to any part of the Derivative Works, in at least one 147 | of the following places: within a NOTICE text file distributed 148 | as part of the Derivative Works; within the Source form or 149 | documentation, if provided along with the Derivative Works; or, 150 | within a display generated by the Derivative Works, if and 151 | wherever such third-party notices normally appear. The contents 152 | of the NOTICE file are for informational purposes only and 153 | do not modify the License. You may add Your own attribution 154 | notices within Derivative Works that You distribute, alongside 155 | or as an addendum to the NOTICE text from the Work, provided 156 | that such additional attribution notices cannot be construed 157 | as modifying the License. 158 | 159 | You may add Your own copyright statement to Your modifications and 160 | may provide additional or different license terms and conditions 161 | for use, reproduction, or distribution of Your modifications, or 162 | for any such Derivative Works as a whole, provided Your use, 163 | reproduction, and distribution of the Work otherwise complies with 164 | the conditions stated in this License. 165 | 166 | 5. Submission of Contributions. Unless You explicitly state otherwise, 167 | any Contribution intentionally submitted for inclusion in the Work 168 | by You to the Licensor shall be under the terms and conditions of 169 | this License, without any additional terms or conditions. 170 | Notwithstanding the above, nothing herein shall supersede or modify 171 | the terms of any separate license agreement you may have executed 172 | with Licensor regarding such Contributions. 173 | 174 | 6. Trademarks. This License does not grant permission to use the trade 175 | names, trademarks, service marks, or product names of the Licensor, 176 | except as required for reasonable and customary use in describing the 177 | origin of the Work and reproducing the content of the NOTICE file. 178 | 179 | 7. Disclaimer of Warranty. Unless required by applicable law or 180 | agreed to in writing, Licensor provides the Work (and each 181 | Contributor provides its Contributions) on an "AS IS" BASIS, 182 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 183 | implied, including, without limitation, any warranties or conditions 184 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 185 | PARTICULAR PURPOSE. You are solely responsible for determining the 186 | appropriateness of using or redistributing the Work and assume any 187 | risks associated with Your exercise of permissions under this License. 188 | 189 | 8. Limitation of Liability. In no event and under no legal theory, 190 | whether in tort (including negligence), contract, or otherwise, 191 | unless required by applicable law (such as deliberate and grossly 192 | negligent acts) or agreed to in writing, shall any Contributor be 193 | liable to You for damages, including any direct, indirect, special, 194 | incidental, or consequential damages of any character arising as a 195 | result of this License or out of the use or inability to use the 196 | Work (including but not limited to damages for loss of goodwill, 197 | work stoppage, computer failure or malfunction, or any and all 198 | other commercial damages or losses), even if such Contributor 199 | has been advised of the possibility of such damages. 200 | 201 | 9. Accepting Warranty or Additional Liability. While redistributing 202 | the Work or Derivative Works thereof, You may choose to offer, 203 | and charge a fee for, acceptance of support, warranty, indemnity, 204 | or other liability obligations and/or rights consistent with this 205 | License. However, in accepting such obligations, You may act only 206 | on Your own behalf and on Your sole responsibility, not on behalf 207 | of any other Contributor, and only if You agree to indemnify, 208 | defend, and hold each Contributor harmless for any liability 209 | incurred by, or claims asserted against, such Contributor by reason 210 | of your accepting any such warranty or additional liability. 211 | 212 | END OF TERMS AND CONDITIONS 213 | 214 | APPENDIX: How to apply the Apache License to your work. 215 | 216 | To apply the Apache License to your work, attach the following 217 | boilerplate notice, with the fields enclosed by brackets "[]" 218 | replaced with your own identifying information. (Don't include 219 | the brackets!) The text should be enclosed in the appropriate 220 | comment syntax for the file format. We also recommend that a 221 | file or class name and description of purpose be included on the 222 | same "printed page" as the copyright notice for easier 223 | identification within third-party archives. 224 | 225 | Copyright [yyyy] [name of copyright owner] 226 | 227 | Licensed under the Apache License, Version 2.0 (the "License"); 228 | you may not use this file except in compliance with the License. 229 | You may obtain a copy of the License at 230 | 231 | http://www.apache.org/licenses/LICENSE-2.0 232 | 233 | Unless required by applicable law or agreed to in writing, software 234 | distributed under the License is distributed on an "AS IS" BASIS, 235 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 236 | See the License for the specific language governing permissions and 237 | limitations under the License. 238 | 239 | 240 | ---- LLVM Exceptions to the Apache 2.0 License ---- 241 | 242 | As an exception, if, as a result of your compiling your source code, portions 243 | of this Software are embedded into an Object form of such source code, you 244 | may redistribute such embedded portions in such Object form without complying 245 | with the conditions of Sections 4(a), 4(b) and 4(d) of the License. 246 | 247 | In addition, if you combine or link compiled forms of this Software with 248 | software that is licensed under the GPLv2 ("Combined Software") and if a 249 | court of competent jurisdiction determines that the patent provision (Section 250 | 3), the indemnity provision (Section 9) or other Section of the License 251 | conflicts with the conditions of the GPLv2, you may retroactively and 252 | prospectively choose to deem waived or otherwise exclude such Section(s) of 253 | the License, but only in their entirety and only with respect to the Combined 254 | Software. 255 | 256 | ============================================================================== 257 | Software from third parties included in the LLVM Project: 258 | ============================================================================== 259 | The LLVM Project contains third party software which is under different license 260 | terms. All such code will be identified clearly using at least one of two 261 | mechanisms: 262 | 1) It will be in a separate directory tree with its own `LICENSE.txt` or 263 | `LICENSE` file at the top containing the specific license and restrictions 264 | which apply to that software, or 265 | 2) It will contain specific license and restriction terms at the top of every 266 | file. 267 | 268 | ============================================================================== 269 | Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): 270 | ============================================================================== 271 | University of Illinois/NCSA 272 | Open Source License 273 | 274 | Copyright (c) 2003-2019 University of Illinois at Urbana-Champaign. 275 | All rights reserved. 276 | 277 | Developed by: 278 | 279 | LLVM Team 280 | 281 | University of Illinois at Urbana-Champaign 282 | 283 | http://llvm.org 284 | 285 | Permission is hereby granted, free of charge, to any person obtaining a copy of 286 | this software and associated documentation files (the "Software"), to deal with 287 | the Software without restriction, including without limitation the rights to 288 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 289 | of the Software, and to permit persons to whom the Software is furnished to do 290 | so, subject to the following conditions: 291 | 292 | * Redistributions of source code must retain the above copyright notice, 293 | this list of conditions and the following disclaimers. 294 | 295 | * Redistributions in binary form must reproduce the above copyright notice, 296 | this list of conditions and the following disclaimers in the 297 | documentation and/or other materials provided with the distribution. 298 | 299 | * Neither the names of the LLVM Team, University of Illinois at 300 | Urbana-Champaign, nor the names of its contributors may be used to 301 | endorse or promote products derived from this Software without specific 302 | prior written permission. 303 | 304 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 305 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 306 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 307 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 308 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 309 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 310 | SOFTWARE. 311 | 312 | --- 313 | 314 | For more details, see https://llvm.org/LICENSE.txt 315 | -------------------------------------------------------------------------------- /.github/README.md: -------------------------------------------------------------------------------- 1 | ../perf -------------------------------------------------------------------------------- /.github/scripts/export.sh: -------------------------------------------------------------------------------- 1 | # 2 | # The MIT License (MIT) 3 | # 4 | # Copyright (c) 2024-2025 Kris Jusiak 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in all 14 | # copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | # SOFTWARE. 23 | # 24 | # Requirements: 25 | # - apt-get install coreutils # base64 26 | # - apt-get install imagemagick # convert 27 | # - apt-get install libsixel-bin # sixel 28 | # - pip install ansi2html # ansi2html 29 | # 30 | # Usage: 31 | # ./app 2>&1 | ./export.sh markdown > app.md 32 | # ./app 2>&1 | ./export.sh notebook > app.ipynb 33 | # ./app 2>&1 | ./export.sh html > app.html 34 | 35 | function markdown() { 36 | stdin=$(mktemp) 37 | stdout=$(mktemp) 38 | 39 | cat - > $stdin 40 | 41 | while grep -q $'\x1bP' $stdin; do 42 | sed -z 's/\(.*\)\x1bP.*/\1/' $stdin >> $stdout 43 | sed -z 's/.*\(\x1bP.*\x1b\\\).*/\1/' $stdin | \ 44 | convert sixel:- png:- | base64 | tr -d '\n' | \ 45 | xargs -i{} echo -e "\n\`\`\`\n![image](data:image/png;base64,{})\n\`\`\`\n" >> $stdout 46 | sed -z 's/.*\x1b\\\(.*\)/\1/' $stdin >> $stdout 47 | mv $stdout $stdin 48 | done 49 | echo "\`\`\`" 50 | cat $stdin 51 | echo "\`\`\`" 52 | } 53 | 54 | function html() { 55 | stdin=$(mktemp) 56 | stdout=$(mktemp) 57 | 58 | cat - | ansi2html > $stdin 59 | 60 | while grep -q $'\x1bP' $stdin; do 61 | sed -z 's/\(.*\)\x1bP.*/\1/' $stdin >> $stdout 62 | sed -z 's/.*\(\x1bP.*\x1b\\\).*/\1/' $stdin | \ 63 | convert sixel:- png:- | base64 | tr -d '\n' | \ 64 | xargs -i{} echo "
" >> $stdout 65 | sed -z 's/.*\x1b\\\(.*\)/\1/' $stdin >> $stdout 66 | mv $stdout $stdin 67 | done 68 | cat $stdin 69 | } 70 | 71 | function notebook() { 72 | cat < # reads from stdin" 99 | exit 1 100 | fi 101 | 102 | cat - | $1 103 | -------------------------------------------------------------------------------- /.github/scripts/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # The MIT License (MIT) 4 | # 5 | # Copyright (c) 2024-2025 Kris Jusiak 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | # 25 | SET_PERF=false 26 | SET_RDPMC=false 27 | MAX_SAMPLE_RATE="" 28 | 29 | usage() { 30 | echo "Usage: $0 [options]" 31 | echo "" 32 | echo "Options:" 33 | echo " -p, --perf Enable perf setup: sysctls, remount debugfs, set uprobe_events [default: not set]" 34 | echo " -r, --rdpmc Enable rdpmc (sets value to 2) [default: not set]" 35 | echo " -s, --max-sample-rate RATE Set perf_event_max_sample_rate (e.g., 100000) [default: not set]" 36 | echo " -h, --help Show this help message" 37 | echo "" 38 | echo "Usage:" 39 | echo " $0" 40 | echo " Run with defaults (perf setup enabled, rdpmc off, no sample rate)" 41 | exit 1 42 | } 43 | 44 | while [[ "$#" -gt 0 ]]; do 45 | case $1 in 46 | -p|--perf) SET_PERF=true ;; 47 | -r|--rdpmc) SET_RDPMC=true ;; 48 | -s|--max-sample-rate) MAX_SAMPLE_RATE="$2"; shift ;; 49 | -h|--help) usage ;; 50 | *) echo "Unknown parameter: $1"; usage ;; 51 | esac 52 | shift 53 | done 54 | 55 | if [[ -z "$MAX_SAMPLE_RATE" && "$SET_RDPMC" == false && "$SET_PERF" == false ]]; then 56 | usage 57 | fi 58 | 59 | if $SET_PERF; then 60 | sudo mount -o remount,mode=755 /sys/kernel/debug 61 | sudo mount -o remount,mode=755 /sys/kernel/debug/tracing 62 | echo 0 | sudo tee /proc/sys/kernel/kptr_restrict 63 | echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid 64 | sudo chown "$(whoami)" /sys/kernel/debug/tracing/uprobe_events 65 | sudo chmod a+rw /sys/kernel/debug/tracing/uprobe_events 66 | fi 67 | 68 | if [[ -n "$MAX_SAMPLE_RATE" ]]; then 69 | echo "$MAX_SAMPLE_RATE" | sudo tee /proc/sys/kernel/perf_event_max_sample_rate 70 | fi 71 | 72 | if $SET_RDPMC; then 73 | echo 2 | sudo tee /sys/devices/cpu_core/rdpmc 74 | fi 75 | -------------------------------------------------------------------------------- /.github/scripts/tune.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## todo on/off 4 | 5 | # Disable CPU Frequency Scaling (apt install cpufrequtils) 6 | sudo cpupower frequency-set --governor performance 7 | # cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 8 | 9 | # Disable Address Space Randomization 10 | echo 0 > /proc/sys/kernel/randomize_va_space 11 | 12 | # Disable Processor Boosting 13 | echo 0 | sudo tee /sys/devices/system/cpu/cpufreq/boost 14 | 15 | # Disable Turbo Mode 16 | echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo 17 | 18 | # Disable Hyperthreading/SMT 19 | echo off | sudo tee /sys/devices/system/cpu/smt/control 20 | 21 | # Restrict memory to a single socket 22 | #numactl -m 0 -N 0 ./a.out 23 | 24 | # Enable Huge Pages 25 | #sudo numactl --cpunodebind=1 --membind=1 hugeadm --obey-mempolicy --pool-pages-min=1G:64 26 | #sudo hugeadm --create-mounts 27 | -------------------------------------------------------------------------------- /.github/workflows/Dockerfile: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 2024-2025 Kris Jusiak 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 | 23 | # ``` 24 | # docker build -t perf . 25 | # ``` 26 | 27 | # ``` 28 | # docker run \ 29 | # --rm \ 30 | # --user $(id -u):$(id -g) \ 31 | # --privileged \ 32 | # --network=host \ 33 | # -e DISPLAY=${DISPLAY} \ 34 | # -v ${PWD}:${PWD} \ 35 | # -w ${PWD} \ 36 | # perf 37 | # ``` 38 | 39 | FROM ubuntu:24.04 40 | ARG CLANG=20 41 | ARG GCC=14 42 | 43 | RUN apt-get update && apt-get install -y \ 44 | gnupg software-properties-common lsb-release ca-certificates \ 45 | python3-pip python3-venv cmake \ 46 | wget bzip2 vim pkg-config dbus-x11 git gh \ 47 | kmod linux-headers-generic linux-tools-generic linux-tools-*-generic util-linux hwloc msr-tools \ 48 | llvm-dev libpfm4 libpapi-dev papi-tools libipt-dev \ 49 | libgoogle-perftools-dev google-perftools valgrind kcachegrind coz-profiler pahole likwid hotspot hyperfine \ 50 | graphviz gnuplot coreutils imagemagick libsixel-bin 51 | 52 | RUN python3 -m venv /venv 53 | RUN /venv/bin/pip install \ 54 | pyperf osaca \ 55 | jupyter numpy pandas matplotlib ansi2html 56 | 57 | RUN wget -qO - https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | \ 58 | gpg --dearmor -o /usr/share/keyrings/intel-oneapi-archive-keyring.gpg 59 | RUN echo "deb [signed-by=/usr/share/keyrings/intel-oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | \ 60 | tee /etc/apt/sources.list.d/oneAPI.list 61 | RUN apt-get update && apt-get install -y libnss3 intel-oneapi-vtune 62 | 63 | RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh $CLANG && rm llvm.sh 64 | RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt update && apt install -y g++-$GCC 65 | 66 | ENV PATH="/venv/bin:$PATH" 67 | ENV DISPLAY=:0 68 | -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: linux 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | 7 | pull_request: 8 | branches: [ main ] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: checkout 16 | uses: actions/checkout@v3 17 | 18 | - name: image 19 | run: docker build -f .github/workflows/Dockerfile -t perf . 20 | 21 | - name: build 22 | run: | 23 | cat < perf.cpp 24 | #include 25 | int main() { } 26 | EOF 27 | docker run --rm --privileged -v ${PWD}:${PWD} -w ${PWD} perf sh -c "\ 28 | clang++-20 -DPERF_INTEL=0 -std=c++23 -O3 -I. -I/usr/lib/llvm-20/include -lLLVM-20 -lipt perf.cpp -o perf && ./perf" 29 | 30 | # TODO 31 | # - header/module 32 | # - gcc/clang 33 | # - LLVM INTEL 34 | # - NTEST 35 | # - O1/O2/O3 36 | # - -g 37 | -------------------------------------------------------------------------------- /perf.cppm: -------------------------------------------------------------------------------- 1 | //