DataDog / datadog-ci-rb

Ruby library for Datadog Test Optimization
https://docs.datadoghq.com/tests/setup/ruby/?tab=cloudciprovideragentless
Other
11 stars 4 forks source link

[SDTEST-878] Optimise LocalRepository.relative_to_root helper to make test impact analysis faster #244

Closed anmarchenko closed 2 months ago

anmarchenko commented 2 months ago

What does this PR do? Applies some heuristics to avoid calling Pathname#relative_path_from function when determining what would be path relative to the git root for the given filepath:

Motivation Profiling rubocop test suite with Datadog continuous profiler showed that big part of CPU time is spent in Datadog::CI::Git::LocalRepository.relative_to_root function: profile-before

How to test the change? Unit tests are provided.

Benchmark results:

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.

Project coverage is 98.86%. Comparing base (7d381d5) to head (777af47).

Files with missing lines Patch % Lines
lib/datadog/ci/git/local_repository.rb 93.33% 1 Missing :warning:
lib/datadog/ci/transport/http.rb 50.00% 1 Missing :warning:
...atadog/ci/test_optimisation/coverage/event_spec.rb 93.33% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #244 +/- ## ========================================== - Coverage 98.88% 98.86% -0.02% ========================================== Files 279 279 Lines 13575 13603 +28 Branches 625 637 +12 ========================================== + Hits 13424 13449 +25 - Misses 151 154 +3 ``` | [Flag](https://app.codecov.io/gh/DataDog/datadog-ci-rb/pull/244/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | Coverage Δ | | |---|---|---| | [](https://app.codecov.io/gh/DataDog/datadog-ci-rb/pull/244/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.