Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruleguard: add profiling labels support #338

Merged
merged 1 commit into from
Jan 1, 2022

Conversation

quasilyte
Copy link
Owner

When ruleguard is compiled with --tags pproflabels, profiling
will record per rules group labels, like rules:groupname.

This makes it easies to find the rules that may need to be
optimized or re-written in some other way.

Build tags protection is used to avoid the overhead in
the normal mode, when labels are not needed.

(pprof) tags
 rules: Total 2.3s
        410.0ms (18.14%): dupArg
        350.0ms (15.49%): offBy1
        250.0ms (11.06%): badLock
        160.0ms ( 7.08%): argOrder
        140.0ms ( 6.19%): equalFold
        120.0ms ( 5.31%): redundantSprint
        110.0ms ( 4.87%): wrapperFunc
         90.0ms ( 3.98%): ioutilDeprecated
         80.0ms ( 3.54%): preferFprint
         70.0ms ( 3.10%): assignOp
         60.0ms ( 2.65%): badCall
         60.0ms ( 2.65%): externalErrorReassign
         60.0ms ( 2.65%): stringXbytes
         50.0ms ( 2.21%): valSwap
         40.0ms ( 1.77%): stringConcatSimplify
         40.0ms ( 1.77%): yodaStyleExpr
         20.0ms ( 0.88%): badSorting
         20.0ms ( 0.88%): flagDeref
         20.0ms ( 0.88%): httpNoBody
         20.0ms ( 0.88%): preferStringWriter
         20.0ms ( 0.88%): timeExprSimplify
         10.0ms ( 0.44%): dynamicFmtString
         10.0ms ( 0.44%): emptyStringTest
         10.0ms ( 0.44%): preferWriteByte
         10.0ms ( 0.44%): regexpMust
         10.0ms ( 0.44%): returnAfterHttpError
         10.0ms ( 0.44%): sloppyLen
         10.0ms ( 0.44%): sprintfQuotedString

When ruleguard is compiled with `--tags pproflabels`, profiling
will record per rules group labels, like `rules:groupname`.

This makes it easies to find the rules that may need to be
optimized or re-written in some other way.

Build tags protection is used to avoid the overhead in
the normal mode, when labels are not needed.

```
(pprof) tags
 rules: Total 2.3s
        410.0ms (18.14%): dupArg
        350.0ms (15.49%): offBy1
        250.0ms (11.06%): badLock
        160.0ms ( 7.08%): argOrder
        140.0ms ( 6.19%): equalFold
        120.0ms ( 5.31%): redundantSprint
        110.0ms ( 4.87%): wrapperFunc
         90.0ms ( 3.98%): ioutilDeprecated
         80.0ms ( 3.54%): preferFprint
         70.0ms ( 3.10%): assignOp
         60.0ms ( 2.65%): badCall
         60.0ms ( 2.65%): externalErrorReassign
         60.0ms ( 2.65%): stringXbytes
         50.0ms ( 2.21%): valSwap
         40.0ms ( 1.77%): stringConcatSimplify
         40.0ms ( 1.77%): yodaStyleExpr
         20.0ms ( 0.88%): badSorting
         20.0ms ( 0.88%): flagDeref
         20.0ms ( 0.88%): httpNoBody
         20.0ms ( 0.88%): preferStringWriter
         20.0ms ( 0.88%): timeExprSimplify
         10.0ms ( 0.44%): dynamicFmtString
         10.0ms ( 0.44%): emptyStringTest
         10.0ms ( 0.44%): preferWriteByte
         10.0ms ( 0.44%): regexpMust
         10.0ms ( 0.44%): returnAfterHttpError
         10.0ms ( 0.44%): sloppyLen
         10.0ms ( 0.44%): sprintfQuotedString
```
@quasilyte quasilyte merged commit 00cd1e9 into master Jan 1, 2022
@quasilyte quasilyte deleted the quasilyte/profiling_labels branch January 1, 2022 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant