nspcc-dev / nspcc-dev/neofs-node
Avoid logger over-cloning
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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