Avoid logger over-cloning #1432

Open
opened 2025-12-28 17:22:59 +00:00 by sami · 0 comments
Owner

Originally created by @cthulhu-rider on GitHub (Jun 20, 2025).

#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

Originally created by @cthulhu-rider on GitHub (Jun 20, 2025). ## 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
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-node#1432
No description provided.