-
Notifications
You must be signed in to change notification settings - Fork 5
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
[SDTEST-878] Optimise LocalRepository.relative_to_root helper to make test impact analysis faster #244
[SDTEST-878] Optimise LocalRepository.relative_to_root helper to make test impact analysis faster #244
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -149,6 +149,10 @@ def code | |||
nil | |||
end | |||
|
|||
def response_size | |||
0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated change, I noticed that library started to fail if certain backend API is not available because for ErrorResponse there is no http_response
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:path[prefix_length..]
)Pathname#relative_path_from
once and then we store the difference between the relative filepath and the computed relative path from root in the@prefix_to_root
cached variable. We can do it because all relative paths are computed relative to theDir.pwd
which doesn't change in the lifetime of the process. After we have@prefix_to_root
cache, we prepend it to every filepath we get (or just return the filepath if the tests are running from the git root).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:How to test the change?
Unit tests are provided.
Benchmark results: