Go-perfguard - A static analyzer with emphasis on performance

Build Status Go Report Card

perfguard

This tool is a work in progress. It's not production-ready yet.

perfguard is a static analyzer with emphasis on performance.

There are two main modes: optimize and lint. Optimization mode uses CPU profile information to improve the analysis precision and avoid suggestions in the cold execution paths. Lint mode reports all potential performance issues.

perfguard features:

  • Profile-guided analysis in "optimize" mode
  • Most found issues are auto-fixable (quickfixes)
  • Easy to extend with custom rules
Owner
Comments
  • exit with non zero code if found issues (warnings) in `lint` mode ?

    exit with non zero code if found issues (warnings) in `lint` mode ?

    currently we exit with zero status code when perfguard found some issues, so users should check analyze stdout for changes. i think it will be fine if we exit with 1 status code if there are any issues.

    what do you think?

  • perfguard/_rules: add math.Abs optimization rules

    perfguard/_rules: add math.Abs optimization rules

    Add rewrite rules:

    math.Abs(x) * math.Abs(y) => math.Abs((x) * (y))
    math.Abs(x) / math.Abs(y) => math.Abs((x) / (y))
    

    See https://github.com/golang/go/issues/50126

  • perfguard/_rules: add sliceClone pattern

    perfguard/_rules: add sliceClone pattern

    For hot paths (o2 level) suggest this rewrite:

    append([]byte(str1), str2...)
    =>
    append(append(make([]byte, 0, len(str1)+len(str2)), str1...), str2...)
    

    This will make the operation work with only 1 allocation instead of 2.

    See https://github.com/golang/go/issues/47454

  • perfguard/_rules: fix rangeValueCopy pos ranges

    perfguard/_rules: fix rangeValueCopy pos ranges

    Use a range header pattern instead of a whole loop for ... {$*_} pattern that will use the whole loop body to compute the relevant CPU profile samples.

    With range header, we only calculate the first loop line, the one that accounts for arguments copying.

  • up go to 1.18 to support generics code

    up go to 1.18 to support generics code

    Up go to 1.18 and other necessary dependencies to make perfguard work with generics code. But still have no idea what to do with missing function runRulesTest(t, key).

  • Add strings.Split rules

    Add strings.Split rules

    https://go.dev/play/p/6flcdVdZKBX

    len(strings.Split($s, $sep))
    =>
    strings.Count($s, $sep) + 1
    
    • anything else that comes to mind and does appear in a go corpus.
  • Recognize dull strconv atoi

    Recognize dull strconv atoi

    https://shareablecode.com/snippets/golang-solution-for-leetcode-problem-add-binary-dxhd-FPGR

    ai, _ := strconv.Atoi(string(a[i]))
    // =>
    ai := int(a[i] - '0')
    
structslop is a static analyzer for Go that recommends struct field rearrangements to provide for maximum space/allocation efficiency.

structslop Package structslop defines an Analyzer that checks struct can be re-arranged fields to get optimal struct size.

Dec 28, 2022
Analyzer: zapvet is static analysis tool for zap

zapvet zapvet is static analysis tool for zap. fieldtype: fieldtype finds confliction type of field Install You can get zapvet by go install command (

Sep 18, 2022
Analyzer: debugcode finds debug codes

debugcode debugcode finds debug codes. builtinprint: finds calling builtin print or println. commentout: finds a commented out debug code without reas

Aug 16, 2021
gostatement is an analyzer checking for occurrence of `go` statements

gostatement gostatement is an analyzer checking for occurrence of go statements. You may want to use a custom func wrapping the statement utilizing re

Nov 4, 2021
This static analysis tool works to ensure your program's data flow does not spill beyond its banks.

Go Flow Levee This static analysis tool works to ensure your program's data flow does not spill beyond its banks. An input program's data flow is expl

Dec 1, 2022
A Golang tool that does static analysis, unit testing, code review and generate code quality report.
A Golang tool that does static analysis, unit testing, code review and generate code quality report.

goreporter A Golang tool that does static analysis, unit testing, code review and generate code quality report. This is a tool that concurrently runs

Jan 8, 2023
GoKart - Go Security Static Analysis
 GoKart - Go Security Static Analysis

GoKart is a static analysis tool for Go that finds vulnerabilities using the SSA (single static assignment) form of Go source code.

Jan 1, 2023
Retnilnil is a static analysis tool to detect `return nil, nil`

retnilnil retnilnil is a static analysis tool for Golang that detects return nil, nil in functions with (*T, error) as the return type. func f() (*T,

Jun 9, 2022
[mirror] Performance measurement, storage, and analysis.

Go performance measurement, storage, and analysis tools This subrepository holds the source for various packages and tools related to performance meas

Dec 24, 2022
Nginx-Log-Analyzer is a lightweight (simplistic) log analyzer for Nginx.
Nginx-Log-Analyzer is a lightweight (simplistic) log analyzer for Nginx.

Nginx-Log-Analyzer is a lightweight (simplistic) log analyzer, used to analyze Nginx access logs for myself.

Nov 29, 2022
Log-analyzer - Log analyzer with golang

Log Analyzer what do we have here? Objective Installation and Running Applicatio

Jan 27, 2022
A static code analyzer for annotated TODO comments
A static code analyzer for annotated TODO comments

todocheck todocheck is a static code analyzer for annotated TODO comments. It let's you create actionable TODOs by annotating them with issues from an

Dec 7, 2022
structslop is a static analyzer for Go that recommends struct field rearrangements to provide for maximum space/allocation efficiency.

structslop Package structslop defines an Analyzer that checks struct can be re-arranged fields to get optimal struct size.

Dec 28, 2022
Analyzer: zapvet is static analysis tool for zap

zapvet zapvet is static analysis tool for zap. fieldtype: fieldtype finds confliction type of field Install You can get zapvet by go install command (

Sep 18, 2022
C4udit - Static analyzer for solidity contracts based on regexs specifically crafted for Code4Rena contests

c4udit Introduction c4udit is a static analyzer for solidity contracts based on

Jan 9, 2023
An extensive Philips Hue client library for Go with an emphasis on simplicity
An extensive Philips Hue client library for Go with an emphasis on simplicity

Huego An extensive Philips Hue client library for Go with an emphasis on simplicity. It is designed to be clean, unbloated and extensible. With Huego

Dec 28, 2022
A client software for acme-dns with emphasis on usability and guidance through setup and additional security safeguard mechanisms

acme-dns-client A client software for acme-dns with emphasis on usability and guidance through setup and additional security safeguard mechanisms. It

Dec 2, 2022
Totsugen - Generate emphasis message with golang

totsugen Requirements Go 1.17+ Run $ go run main.go -value {value} # ex: go run

May 21, 2022
H265/HEVC Bitstream Analyzer in Go

GoVisa H.265/HEVC Bitstream Analyzer in Go /* The copyright in this software is being made available under the BSD License, included below. This softw

Aug 14, 2022