Skip to content

Improve updateFeatureContext performances#2489

Merged
xgouchet merged 1 commit into
developfrom
xgouchet/feature_context_perf
Jan 21, 2025
Merged

Improve updateFeatureContext performances#2489
xgouchet merged 1 commit into
developfrom
xgouchet/feature_context_perf

Conversation

@xgouchet

Copy link
Copy Markdown
Contributor

What does this PR do?

It slightly improve the performance of context sharing across modules.

Motivation

Context sharing is what allows different modules (RUM, SR, APM) to share context (e.g.: RUM Session Id) to link events together.

Additional Notes

We focused this PR on several bottlenecks.

  • The getFeatureContext() method returned a copy of the source-of-truth Map, which was unnecessary as it was already typed as immutable;
  • The updateFeatureContext() method would create a copy of the source-of-truth map for every module it notified;
  • The updateFeatureContext() method would use the .filter{} utility on a map, which creates an unnecessary copy

@xgouchet
xgouchet requested review from a team as code owners January 20, 2025 16:13
@codecov-commenter

codecov-commenter commented Jan 20, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 69.94%. Comparing base (1424c51) to head (dcd63fe).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...n/com/datadog/android/core/internal/DatadogCore.kt 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2489      +/-   ##
===========================================
+ Coverage    69.88%   69.94%   +0.06%     
===========================================
  Files          788      788              
  Lines        29647    29646       -1     
  Branches      4961     4962       +1     
===========================================
+ Hits         20717    20735      +18     
+ Misses        7548     7535      -13     
+ Partials      1382     1376       -6     
Files with missing lines Coverage Δ
...og/android/core/internal/DatadogContextProvider.kt 100.00% <100.00%> (+2.38%) ⬆️
...n/com/datadog/android/core/internal/DatadogCore.kt 82.19% <83.33%> (-0.08%) ⬇️

... and 28 files with indirect coverage changes

Comment thread detekt_custom.yml
- "kotlin.collections.MutableList.toTypedArray()"
- "kotlin.collections.MutableList.withIndex()"
- "kotlin.collections.MutableList.firstOrNull()"
- "kotlin.collections.MutableMap.asSequence()"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it seems there is no usage of this method in the PR?

@xgouchet
xgouchet merged commit 224c09e into develop Jan 21, 2025
@xgouchet
xgouchet deleted the xgouchet/feature_context_perf branch January 21, 2025 11:02
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.

4 participants