{"id":16218127,"url":"https://github.com/quasilyte/go-perfguard","last_synced_at":"2025-03-16T11:31:00.089Z","repository":{"id":42230010,"uuid":"442463398","full_name":"quasilyte/go-perfguard","owner":"quasilyte","description":"CPU-guided performance analyzer for Go","archived":false,"fork":false,"pushed_at":"2022-10-19T15:37:12.000Z","size":409,"stargazers_count":75,"open_issues_count":77,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T08:19:44.292Z","etag":null,"topics":["autofix","dynamic-rules","go","go-analysis","golang","linter","performance","quickfix","ruleguard","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quasilyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-28T12:55:24.000Z","updated_at":"2024-07-26T15:42:03.000Z","dependencies_parsed_at":"2022-09-12T22:00:39.275Z","dependency_job_id":null,"html_url":"https://github.com/quasilyte/go-perfguard","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fgo-perfguard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fgo-perfguard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fgo-perfguard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Fgo-perfguard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quasilyte","download_url":"https://codeload.github.com/quasilyte/go-perfguard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814864,"owners_count":20352037,"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":["autofix","dynamic-rules","go","go-analysis","golang","linter","performance","quickfix","ruleguard","static-analysis"],"created_at":"2024-10-10T11:48:36.073Z","updated_at":"2025-03-16T11:30:59.400Z","avatar_url":"https://github.com/quasilyte.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Build Status](https://github.com/quasilyte/go-perfguard/workflows/Go/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/quasilyte/go-perfguard)](https://goreportcard.com/report/github.com/quasilyte/go-perfguard)\n\n# perfguard\n\n\u003e This tool is a work in progress.\n\u003e It's not fully production-ready yet, but you can try it out.\n\n## Overview\n\nperfguard is a Go static analyzer with an emphasis on performance.\n\nIt supports two run modes:\n\n1. `perfguard lint` finds potential issues, works like traditional static analysis\n2. `perfguard optimize` uses CPU profiles to improve the analysis precision\n\nperfguard key features:\n\n* Profile-guided analysis in `perfguard optimize` mode\n* Most found issues are auto-fixable with `--fix` argument (quickfixes)\n* Easy to extend with custom rules (no recompilation needed)\n* Can analyze big projects* even if they have some compilation errors\n\n\u003e (*) It doesn't try to load analysis targets into memory all at once.\n\nHere are some examples of what it can do for you:\n\n* Remove redundant data copying or make it faster\n* Reduce the amounts of heap allocations\n* Suggest more optimized functions or types from stdlib\n* Recognize expensive operations in hot paths that can be lifted\n\n## Installation\n\nInstall a `perfguard` binary under your `$(go env GOPATH)/bin`:\n\n```bash\n$ go install -v github.com/quasilyte/go-perfguard/cmd/perfguard@latest\n```\n\n## Using perfguard\n\nIt's recommended that you collect CPU profiles on realistic workflows.\n\nFor a short-lived CLI app it could be a full run. For a long-living app you may want to turn the profiling on for a minute or more, then save it to a file.\n\nProfiles that are obtained from benchmarks are not representative and may lead to suboptimal results.\n\nHot spots in the profile may appear in three main places:\n\n1. Standard Go library and the runtime. We can't apply fixes to that\n2. Your app (or library) own code\n3. Your code dependencies (direct or indirect)\n\nOptimizing your own code is straightforward. Run perfguard on the root of your project:\n\n```bash\n$ perfguard optimize --heatmap cpu.out ./...\n```\n\nThis will only suggest fixes to the `(2)` category.\n\nTo optimize the code from `(3)` we have several choices.\n\n1. Optimize the library itself\n2. Optimize the whole code base with an explicit vendor\n\nThe first option is preferable. You can use the same CPU profile to optimize the library. Run the perfguard on the library source code root just like you did with your application.\n\nThe second option can work for the cases when you want to deploy an optimized binary while not having a way to fix dependencies using the first option. Follow these steps:\n\n```bash\n# Make dependencies easily available for perfguard.\n$ go mod vendor\n# Run the analysis over the vendor.\n# We use --fix argument to immediately apply the suggested changes.\n$ perfguard optimize --heatmap cpu.out --fix ./vendor/...\n# Build the optimized binary.\n$ go build -o bin/app ./cmd/myapp\n```\n\nThen you can revert the changes to the `./vendor` or remove it if you're not using vendoring.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2Fgo-perfguard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquasilyte%2Fgo-perfguard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2Fgo-perfguard/lists"}