Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
perf: optimize slog by not calling runtime.Callers
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Apr 16, 2024
1 parent 10fcbf5 commit ec828d4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/anycable-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ import (

"github.com/anycable/anycable-go/cli"
_ "github.com/anycable/anycable-go/diagnostics"

_ "unsafe"
)

// IgnorePC is responsible for adding callers pointer to log records.
// We don't use `AddSource` in our handler, so why not dropping the `runtime.Callers` overhead?
// See also https://github.com/rs/zerolog/issues/571#issuecomment-1697479194
//
//go:linkname IgnorePC log/slog/internal.IgnorePC
var IgnorePC = true

func main() {
c, err, ok := cli.NewConfigFromCLI(os.Args)
if err != nil {
Expand Down

0 comments on commit ec828d4

Please sign in to comment.