Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal: cache build info to reduce lock contention in GetGitMetadataTags #2770

Merged
merged 4 commits into from
Jul 12, 2024

Conversation

darccio
Copy link
Member

@darccio darccio commented Jul 4, 2024

What does this PR do?

Introduces caching code to avoid calling debug.ReadBuildInfo multiple times each time a span is finished. It's cached on package initialisation.

Note: it's important to know that it's not possible to test debug.ReadBuildInfo because test binaries have no debug info, according to golang/go#33976.

Motivation

This was detected as an important lock contention area using our Continuous Profiler on one of our busiest services. It should help to reduce lock contention, with potential reduction around 15%.

image

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.

Unsure? Have a question? Request a review!

@darccio darccio requested a review from a team as a code owner July 4, 2024 11:34
@darccio darccio marked this pull request as draft July 4, 2024 11:40
@darccio
Copy link
Member Author

darccio commented Jul 4, 2024

Reverting to draft to investigate a bit more.

@darccio darccio force-pushed the dario.castane/reduce-lock-contention-getgitmetadata branch 2 times, most recently from ec06787 to 048ef48 Compare July 12, 2024 12:22
@darccio darccio marked this pull request as ready for review July 12, 2024 12:28
@darccio darccio changed the title internal: cache build info to reduce lock contention internal: cache build info to reduce lock contention in GetGitMetadataTags Jul 12, 2024
@pr-commenter
Copy link

pr-commenter bot commented Jul 12, 2024

Benchmarks

Benchmark execution time: 2024-07-12 14:58:20

Comparing candidate commit fcb1ad4 in PR branch dario.castane/reduce-lock-contention-getgitmetadata with baseline commit be3543a in branch main.

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

@darccio darccio force-pushed the dario.castane/reduce-lock-contention-getgitmetadata branch from 048ef48 to 1ab3ea6 Compare July 12, 2024 12:46
@darccio darccio force-pushed the dario.castane/reduce-lock-contention-getgitmetadata branch from 1ab3ea6 to f4ac899 Compare July 12, 2024 14:07
@darccio darccio requested review from a team as code owners July 12, 2024 14:07
Copy link
Contributor

@eliottness eliottness left a comment

Choose a reason for hiding this comment

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

LGTM, left 2 non-blocking suggestions

internal/gitmetadata.go Outdated Show resolved Hide resolved
internal/gitmetadata.go Outdated Show resolved Hide resolved
Copy link
Contributor

@nsrip-dd nsrip-dd left a comment

Choose a reason for hiding this comment

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

Thanks!

@darccio darccio enabled auto-merge (squash) July 12, 2024 14:37
Copy link
Contributor

@mtoffl01 mtoffl01 left a comment

Choose a reason for hiding this comment

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

nice approach!

@darccio darccio merged commit a87c895 into main Jul 12, 2024
164 checks passed
@darccio darccio deleted the dario.castane/reduce-lock-contention-getgitmetadata branch July 12, 2024 21:28
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.

5 participants