Skip to content

chore(internal/log): optimize message formatting in printMsg function#3365

Merged
darccio merged 5 commits into
v2-devfrom
dario.castane/optimize-log
Apr 2, 2025
Merged

chore(internal/log): optimize message formatting in printMsg function#3365
darccio merged 5 commits into
v2-devfrom
dario.castane/optimize-log

Conversation

@darccio

@darccio darccio commented Apr 1, 2025

Copy link
Copy Markdown
Member

What does this PR do?

Reduces usage of fmt.Sprintf when logging messages.

Motivation

Optimizes our logger to reduce memory allocations. From:

BenchmarkLog-10    	  367110	      3268 ns/op	     246 B/op	       5 allocs/op

To:

BenchmarkLog-10    	  652357	      1787 ns/op	     120 B/op	       2 allocs/op

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.
  • For internal contributors, a matching PR should be created to the v2-dev branch and reviewed by @DataDog/apm-go.

Unsure? Have a question? Request a review!

@darccio
darccio requested review from a team as code owners April 1, 2025 08:19
@darccio darccio changed the title chore(internal/log): add benchmark for logging performance chore(internal/log): optimize message formatting in printMsg function Apr 1, 2025
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Apr 1, 2025

Copy link
Copy Markdown

Datadog Report

Branch report: dario.castane/optimize-log
Commit report: 2816c21
Test service: dd-trace-go

✅ 0 Failed, 4440 Passed, 66 Skipped, 3m 17.95s Total Time

@pr-commenter

pr-commenter Bot commented Apr 1, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-04-02 12:40:28

Comparing candidate commit a120bf3 in PR branch dario.castane/optimize-log with baseline commit e5cfb7b in branch v2-dev.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 55 metrics, 1 unstable metrics.

Comment thread internal/log/log.go Outdated
@darccio
darccio changed the base branch from v2-dev to main April 2, 2025 15:15
@darccio
darccio requested review from a team as code owners April 2, 2025 15:15
@darccio
darccio requested a review from dromanol April 2, 2025 15:15
@darccio
darccio changed the base branch from main to v2-dev April 2, 2025 15:15
@darccio
darccio merged commit d652d88 into v2-dev Apr 2, 2025
@darccio
darccio deleted the dario.castane/optimize-log branch April 2, 2025 15:16
@darccio darccio added the v2.0 label Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants