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

[PROF-8632] Ruby heap size profiling PoC #3261

Conversation

AlexJF
Copy link
Contributor

@AlexJF AlexJF commented Nov 15, 2023

What does this PR do?
Build on top of #3246 by adding a new profile type capturing the weighted heap size of all live sampled objects in the heap.

image

Motivation:
Tracking the number of living objects alone does not give us an idea of resource (in this case, memory) utilisation. To understand how close we are to hitting limits and OOMing, we need to understand the cumulative size of things in heap.

Additional Notes:

How to test the change?

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.

Unsure? Have a question? Request a review!

@github-actions github-actions bot added the profiling Involves Datadog profiling label Nov 15, 2023
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.

Gave it a pass, looks sane! ;)

Comment on lines +204 to +210
if (heap_recorder->enable_heap_size_profiling) {
// To get an accurate object size, we need to query our tracked live objects so lets iterate over the object_records
st_foreach(heap_recorder->object_records, st_object_records_iterate, (st_data_t) &internal_iteration_data);
} else {
// If we're just reporting heap counts/samples, it's faster to iterate on the heap records
st_foreach(heap_recorder->heap_records, st_heap_records_iterate, (st_data_t) &internal_iteration_data);
}
Copy link
Member

Choose a reason for hiding this comment

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

Uh, this is interesting -- may be worth calling out as an intro comment in the design of the heap recorder at some point.

Comment on lines 336 to +343
ENFORCE_BOOLEAN(cpu_time_enabled);
ENFORCE_BOOLEAN(alloc_samples_enabled);
ENFORCE_BOOLEAN(heap_samples_enabled);

struct stack_recorder_state *state;
TypedData_Get_Struct(recorder_instance, struct stack_recorder_state, &stack_recorder_typed_data, state);

state->heap_recorder = heap_recorder_init();
state->heap_recorder = heap_recorder_init(heap_size_enabled == Qtrue);
Copy link
Member

Choose a reason for hiding this comment

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

Minor: Don't forget the ENFORCE_BOOLEAN, to avoid typing accidents ;)

Also, perhaps we should raise if heap_samples_enabled == false but heap_size_enabled == true

@AlexJF AlexJF force-pushed the alexjf/prof-8543-ruby-heap-profiling-poc branch from 2a11d34 to 564543c Compare November 21, 2023 16:29
@AlexJF
Copy link
Contributor Author

AlexJF commented Dec 13, 2023

Replaced with more production-ready versions starting from #3281

@AlexJF AlexJF closed this Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
profiling Involves Datadog profiling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants