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

Memoize environment tags to improve performance #1762

Merged
merged 1 commit into from
Nov 8, 2021

Conversation

fermayo
Copy link
Contributor

@fermayo fermayo commented Nov 7, 2021

Fixes #1748

Environment tags do not change during the life of the test process, so we should calculate them only once.

@fermayo fermayo added bug Involves a bug performance Involves performance (e.g. CPU, memory, etc) ci-app CI product for test suite instrumentation labels Nov 7, 2021
@fermayo fermayo requested a review from a team November 7, 2021 19:13
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

Looks reasonable. Since this is seems like an important component of CI performance, I suggest also adding a test for it, since otherwise we could mistakenly remove the memoization, degrading performance again, and nothing would break 😅 .

@@ -38,7 +38,10 @@ def self.set_tags!(span, tags = {})
span.context.origin = Ext::Test::CONTEXT_ORIGIN if span.context
Copy link
Member

Choose a reason for hiding this comment

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

⬆️ GitHub doesn't allow me to comment on line 34, but is it just me or is it kinda weird that this method can receive an arbitrary tags hash, but does not actually set all of the tags in it, instead just cherry picking a few?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK it uses all tags passed in, but then adds/overwrites them with metadata. This should be an internal API anyway used only by the CI auto-instrumentation.

@fermayo
Copy link
Contributor Author

fermayo commented Nov 8, 2021

@ivoanjo we have internal end-to-end performance tests that do this already. What would you suggest doing? A benchmark?

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

@ivoanjo we have internal end-to-end performance tests that do this already. What would you suggest doing? A benchmark?

I was thinking more of a test that checks that Ext::Environment.tags(ENV) only ever gets called only once.

But if the internal end-to-end tests already cover this comfortably, then I'm very OK with relying on that -- up to you :)

@marcotc marcotc merged commit 988431a into master Nov 8, 2021
@marcotc marcotc deleted the fermayo/fix-ci-perf-issues branch November 8, 2021 19:39
@github-actions github-actions bot added this to the 0.54.0 milestone Nov 8, 2021
@fermayo
Copy link
Contributor Author

fermayo commented Nov 8, 2021

@ivoanjo oh that makes sense! I'm not familiar with the testing of this code, but we will definitely follow up with a test to avoid regressions.

@flovilmart
Copy link

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug ci-app CI product for test suite instrumentation performance Involves performance (e.g. CPU, memory, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ddtrace is causing slowness in rspec
5 participants