Skip to content

Avoid logger over-cloning #3409

@cthulhu-rider

Description

@cthulhu-rider

Is your feature request related to a problem? Please describe.

#3408 showed that https://pkg.go.dev/go.uber.org/zap#Logger.With is quite demanding in terms of resources. Being used frequently, it adds pretty visible alloc overhead. I propose to avoid using it as much as we can

moreover, when messages have lower severity level (e.g.debug in production), this is not just overhead but pure waste of resources

Describe the solution you'd like

never clone logger in request handlers and any other reoperations

even if cloning isn't done frequently in some cases, try to avoid it just to deduplicate common fields attached to different messages. Pass them explicitly or use var

Additional context

benchmarks

Metadata

Metadata

Assignees

No one assigned

    Labels

    I4No visible changesS3Minimally significantU4Nothing urgentenhancementImproving existing functionalityperformanceMore of something per second

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions