{"id":19911015,"url":"https://github.com/leaningtech/chrome-profiling","last_synced_at":"2025-09-19T02:31:47.064Z","repository":{"id":176911549,"uuid":"659232263","full_name":"leaningtech/chrome-profiling","owner":"leaningtech","description":"Collection of helpful assets for linux perf","archived":false,"fork":false,"pushed_at":"2024-01-26T19:04:29.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-11-12T21:24:24.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leaningtech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-27T11:56:36.000Z","updated_at":"2024-07-22T22:03:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"b257c813-ab9a-44bc-9e4c-3e96f1a30c4d","html_url":"https://github.com/leaningtech/chrome-profiling","commit_stats":null,"previous_names":["leaningtech/chrome-profiling"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaningtech%2Fchrome-profiling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaningtech%2Fchrome-profiling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaningtech%2Fchrome-profiling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaningtech%2Fchrome-profiling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leaningtech","download_url":"https://codeload.github.com/leaningtech/chrome-profiling/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233545004,"owners_count":18692100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T21:22:59.901Z","updated_at":"2025-09-19T02:31:41.816Z","avatar_url":"https://github.com/leaningtech.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Script usage\n### Requirements\n- linux-perf version 5 or higher (previous versions don't have jit support).\n- Be able to run linux perf wihout sudo, you can find instructions on that further down.\n### lt_perf_chrome.py\nThis script launches Chromium with the required terminal switches and V8 flags, and then executes\n`perf record` with the render process ID of the opened Chrome tab. Once Chrome is open, you can\nnavigate to the desired website for profiling and then either close the browser or press Ctrl + C\nin the terminal. The profiling data will be saved in the specified folder (the script creates it if\nit doesn't exist), or in the current directory if no `--perf-dir=` parameter is provided.\nAdditionally, the script performs post-processing of the data using `perf inject`. You also have the\noption to include additional V8, Chromium, and perf flags by using the parameters `--chrome-options=\"\"`,\n`--js-flags=\"\"`, and `--perf-options=\"\"`. \n\nIf you haven't used linux perf before, running this script might take some time as perf will\ndownload debug information.  \n\nIMPORTANT: Please avoid opening additional tabs in the Chrome instance launched by this script, as\nit may interfere with the correct identification of the Chrome render process ID.  \n\n### Examples\n```\n./LT_perf_chrome.py --url=https://webvm.io/ --perf-dir=perf_dir\n```\n```\n./LT_perf_chrome.py --url=https://webvm.io/ --perf=/home/builds/linux-stable/tools/perf/perf --wait\n```\n```\n./LT_perf_chrome.py --url=https://webvm.io/ --perf-options=\"--call-graph=fp\" --js-flags=\"--perf-prof-annotate-wasm\"\n```\n\n# Cheatsheets\n### [perf_cheatsheet.md](https://github.com/leaningtech/chrome-profiling/blob/main/perf_cheatsheet.md)\nA collection of linux perf commands with examples and explanations.\n\n### [perf_chrome_cheatsheet.md](https://github.com/leaningtech/chrome-profiling/blob/main/perf_chrome_cheatsheet.md)\nIf you prefer to profile Chromium without using a script, this cheatsheet provides a step-by-step\nguide on how to profile Chromium using linux perf.\n\n# Linux perf source build\nA Linux perf source build is not necessary, but it can make things a little easier by ensuring that\nall features of Linux perf are enabled. If you want to build Linux perf from source, you'll need to\nobtain the Linux kernel source code. **This step is optional.**  \nThe build process itself is straightforward, and there's no need to feel overwhelmed by the kernel\nsource code. You won't be building an actual kernel; we only need to access the necessary tools\ndirectory. You can get a kernel source from either of these websites:\n- https://kernel.org/ \n- https://mirrors.edge.kernel.org/pub/linux/kernel/\n\nThe safest approach is to obtain a kernel version that matches your current kernel, but you can also\nopt for a newer version if desired.  \nPersonally, I did not encounter any issues when obtaining a newer version.\n\n## Building linux perf from source\nGet the sources, either download them directly or use this command with the version you need  \n```\ncurl -o linux-source.tar.gz https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-6.0.9.tar.gz\n```\n\nUnpack the kernel source  \n```\ntar xvf linux-source.tar.gz\n```\n\nMove to the perf tool directory\n```\ncd linux-6.0.9/tools/perf\n```\n\nBuild perf  \n```\nmake\n```\n\nYou may come across several build warnings, which are actually quite helpful. They indicate which\nfeatures are disabled and which packages you need to enable them. Simply install all the missing\npackages and run make again.  \nThese are some common dependencies that may be missing:\n```\nsudo apt-get install libdw-dev libunwind8-dev systemtap-sdt-dev \\\nlibaudit-dev libslang2-dev binutils-dev liblzma-dev\n```\n\n# Linux perf without sudo access\nIf you are using linux perf for the first time, you may encounter an error related to the \n*kernel.perf_event_paranoid* settings. To use linux perf without sudo privileges, you need to enable\ncertain kernel settings, which are also required for our custom script to work. Running the following\ncommands should enable linux perf without requiring root access.\n```\nsudo sh -c 'echo kernel.perf_event_paranoid=1 \u003e /etc/sysctl.d/local.conf'\nsudo sh -c 'echo kernel.kptr_restrict=0 \u003e /etc/sysctl.d/local.conf'\n```\nAfter running these commands you should restart sysctl with this command\n`sudo sysctl -p /etc/sysctl.conf` or reboot your machine.\n\n# The build-id Cache\nAt the end of each run, the perf record command updates a build-id cache, with new entries for ELF\nimages with samples. By default, this cache is saved on disk in the $HOME/.debug directory. Over\ntime, this folder can become filled with data, so it's a good practice to periodically clean it out.\n\nYou can use the command `perf buildid-cache -P` to clear the cache, but I still recommend manually\nreviewing and deleting the data occasionally.\n\n# Missing symbols \nIf you only see addresses in the perf report and not actually function names you might be missing\nsome debug symbol information. In many cases, additional debug symbol packages are available to\nresolve these profiling reports. For instance, Chromium has a separate package for debug symbols,\nsuch as \"chromium-dbg\" on Linux Mint. Package names may vary depending on the distribution, but they\ncommonly include terms like \"-dbgsym\" or \"-dbg\".\n\n# Resources\nIf you want to explore the linux perf command in more depth, these resources provide in-depth\ndetails:\n\n- https://perf.wiki.kernel.org/index.php/Main_Page\n- https://www.brendangregg.com/linuxperf.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleaningtech%2Fchrome-profiling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleaningtech%2Fchrome-profiling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleaningtech%2Fchrome-profiling/lists"}