Skip to content

log: less allocs#20455

Merged
AskAlexSharov merged 1 commit intomainfrom
alex/log_less_alloc_35
Apr 10, 2026
Merged

log: less allocs#20455
AskAlexSharov merged 1 commit intomainfrom
alex/log_less_alloc_35

Conversation

@AskAlexSharov
Copy link
Copy Markdown
Collaborator

  • no ToUpper() call on each format
  • no logEnvBool call on each format

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces per-log-record allocations in the common/log/v3 terminal formatter by removing repeated string uppercasing and by caching an environment flag outside the hot formatting path.

Changes:

  • Add Lvl.UpperString() to avoid strings.ToUpper(r.Lvl.String()) on every formatted record.
  • Cache ERIGON_LOG_NO_TIMESTAMPS once per TerminalFormat() instance instead of re-reading it per record.
  • Add a regression test asserting TerminalFormatNoColor()’s level prefix and message padding/layout.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
common/log/v3/logger.go Adds Lvl.UpperString() for allocation-free uppercase level strings.
common/log/v3/format.go Uses UpperString() and caches logNoTimestamps outside the formatter closure.
common/log/v3/log_test.go Adds TerminalFormatNoColor() output/layout test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

AskAlexSharov added a commit that referenced this pull request Apr 10, 2026
cherry-pick of #20455
@AskAlexSharov AskAlexSharov enabled auto-merge April 10, 2026 03:15
AskAlexSharov added a commit that referenced this pull request Apr 10, 2026
@AskAlexSharov AskAlexSharov added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 32705ea Apr 10, 2026
39 checks passed
@AskAlexSharov AskAlexSharov deleted the alex/log_less_alloc_35 branch April 10, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants