nspcc-dev / nspcc-dev/neofs-node

Avoid logger over-cloning

Open
#3,409 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement I4 performance S3 U4
Dominant language
Go
Stars
38
Forks
51
Avg merge
1d 20h
Merged PRs (30d)
38

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating uses of zap.Logger.With in request handlers and other operations, then inspect the existing benchmarks mentioned in the issue. The work is done when unnecessary logger cloning is removed from those paths and benchmark results show the allocation overhead has been reduced.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.