All Projects → quasilyte → go-perfguard

quasilyte / go-perfguard

Licence: BSD-3-Clause license
CPU-guided performance analyzer for Go

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to go-perfguard

Bodyclose
Analyzer: checks whether HTTP response body is closed and a re-use of TCP connection is not blocked.
Stars: ✭ 181 (+212.07%)
Mutual labels:  linter, static-analysis
Spotbugs
SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.
Stars: ✭ 2,569 (+4329.31%)
Mutual labels:  linter, static-analysis
Woke
✊ Detect non-inclusive language in your source code.
Stars: ✭ 190 (+227.59%)
Mutual labels:  linter, static-analysis
Njsscan
njsscan is a semantic aware SAST tool that can find insecure code patterns in your Node.js applications.
Stars: ✭ 128 (+120.69%)
Mutual labels:  linter, static-analysis
Revive
🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
Stars: ✭ 3,139 (+5312.07%)
Mutual labels:  linter, static-analysis
Rstcheck
Checks syntax of reStructuredText and code blocks nested within it
Stars: ✭ 130 (+124.14%)
Mutual labels:  linter, static-analysis
Bellybutton
Custom Python linting through AST expressions
Stars: ✭ 196 (+237.93%)
Mutual labels:  linter, static-analysis
Static Analysis
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.
Stars: ✭ 9,310 (+15951.72%)
Mutual labels:  linter, static-analysis
lints
Lint all your JavaScript, CSS, HTML, Markdown and Dockerfiles with a single command
Stars: ✭ 14 (-75.86%)
Mutual labels:  linter, static-analysis
D Scanner
Swiss-army knife for D source code
Stars: ✭ 221 (+281.03%)
Mutual labels:  linter, static-analysis
Abaplint
Standalone linter for ABAP
Stars: ✭ 111 (+91.38%)
Mutual labels:  linter, static-analysis
dlint
Dlint is a tool for encouraging best coding practices and helping ensure Python code is secure.
Stars: ✭ 130 (+124.14%)
Mutual labels:  linter, static-analysis
Gopherci
GopherCI was a project to help you maintain high-quality Go projects, by checking each GitHub Pull Request, for backward incompatible changes, and a suite of other third party static analysis tools.
Stars: ✭ 105 (+81.03%)
Mutual labels:  linter, static-analysis
Cflint
Static code analysis for CFML (a linter)
Stars: ✭ 156 (+168.97%)
Mutual labels:  linter, static-analysis
Unimport
A linter, formatter for finding and removing unused import statements.
Stars: ✭ 96 (+65.52%)
Mutual labels:  linter, static-analysis
Diktat
Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
Stars: ✭ 196 (+237.93%)
Mutual labels:  linter, static-analysis
Clj Kondo
A linter for Clojure code that sparks joy.
Stars: ✭ 1,083 (+1767.24%)
Mutual labels:  linter, static-analysis
Flake8
The official GitHub mirror of https://gitlab.com/pycqa/flake8
Stars: ✭ 1,112 (+1817.24%)
Mutual labels:  linter, static-analysis
Protoc Gen Lint
A plug-in for Google's Protocol Buffers (protobufs) compiler to lint .proto files for style violations.
Stars: ✭ 221 (+281.03%)
Mutual labels:  linter, static-analysis
tryceratops
A linter to prevent exception handling antipatterns in Python (limited only for those who like dinosaurs).
Stars: ✭ 381 (+556.9%)
Mutual labels:  linter, static-analysis

Build Status Go Report Card

perfguard

This tool is a work in progress. It's not fully production-ready yet, but you can try it out.

Overview

perfguard is a Go static analyzer with an emphasis on performance.

It supports two run modes:

  1. perfguard lint finds potential issues, works like traditional static analysis
  2. perfguard optimize uses CPU profiles to improve the analysis precision

perfguard key features:

  • Profile-guided analysis in perfguard optimize mode
  • Most found issues are auto-fixable with --fix argument (quickfixes)
  • Easy to extend with custom rules (no recompilation needed)
  • Can analyze big projects* even if they have some compilation errors

(*) It doesn't try to load analysis targets into memory all at once.

Here are some examples of what it can do for you:

  • Remove redundant data copying or make it faster
  • Reduce the amounts of heap allocations
  • Suggest more optimized functions or types from stdlib
  • Recognize expensive operations in hot paths that can be lifted

Installation

Install a perfguard binary under your $(go env GOPATH)/bin:

$ go install -v github.com/quasilyte/go-perfguard/cmd/perfguard@latest

Using perfguard

It's recommended that you collect CPU profiles on realistic workflows.

For 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.

Profiles that are obtained from benchmarks are not representative and may lead to suboptimal results.

Hot spots in the profile may appear in three main places:

  1. Standard Go library and the runtime. We can't apply fixes to that
  2. Your app (or library) own code
  3. Your code dependencies (direct or indirect)

Optimizing your own code is straightforward. Run perfguard on the root of your project:

$ perfguard optimize --heatmap cpu.out ./...

This will only suggest fixes to the (2) category.

To optimize the code from (3) we have several choices.

  1. Optimize the library itself
  2. Optimize the whole code base with an explicit vendor

The 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.

The 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:

# Make dependencies easily available for perfguard.
$ go mod vendor
# Run the analysis over the vendor.
# We use --fix argument to immediately apply the suggested changes.
$ perfguard optimize --heatmap cpu.out --fix ./vendor/...
# Build the optimized binary.
$ go build -o bin/app ./cmd/myapp

Then you can revert the changes to the ./vendor or remove it if you're not using vendoring.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].