-
Notifications
You must be signed in to change notification settings - Fork 372
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
Improve performance of gathering the ClassCount metric #3386
Conversation
73a844c
to
11b79f3
Compare
Update: Rebased on top of current master to pull in #3387 and get a green CI again. |
CI is broken... Unrelated to this PR... Again... Fix is in #3390, I'll rebase once it's in master... |
31dddb9
to
37eec47
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3386 +/- ##
=======================================
Coverage 98.25% 98.25%
=======================================
Files 1262 1262
Lines 73603 73603
Branches 3442 3443 +1
=======================================
Hits 72316 72316
Misses 1287 1287 ☔ View full report in Codecov by Sentry. |
**What does this PR do?** This PR tweaks the `ClassCount.available?` method to cache its result. The result is expected to be always the same for a given Ruby VM, so we don't need to keep checking again and again. **Motivation:** While looking at our GitLab test deployments, I noticed that on this big app, calling `ObjectSpace.count_objects` does have some cost (because this method goes through the whole Ruby heap). I then noticed we _always_ call it twice in a row -- we call `available?` and then call `value`: ![image](https://github.com/DataDog/dd-trace-rb/assets/2785847/a6f9fc20-058a-4018-babc-95e93ccbe06d) It's trivial to avoid this, so I decided to open this tiny PR. **Additional Notes:** N/A **How to test the change?** Existing test coverage is enough :)
9da8507
to
eb504fc
Compare
So it appears that we were missing a few gemfile updates, that our github action pushed into this PR. I've looked into them and they look good. Going ahead and merging this PR. |
What does this PR do?
This PR tweaks the
ClassCount.available?
method to cache its result.The result is expected to be always the same for a given Ruby VM, so we don't need to keep checking again and again.
Motivation:
While looking at our GitLab test deployments, I noticed that on this big app, calling
ObjectSpace.count_objects
does have some cost (because this method goes through the whole Ruby heap).I then noticed we always call it twice in a row -- we call
available?
and then callvalue
:It's trivial to avoid this, so I decided to open this tiny PR.
Additional Notes:
N/A
How to test the change?
Existing test coverage is enough :)
For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance
.