Skip to content

Commit

Permalink
Minor: Split heap recorder stats into young/non-young
Browse files Browse the repository at this point in the history
This avoids "muddying" the waters for our stats, as young object updates
will have more objects skipped, and different mixes of alive/dead.
  • Loading branch information
ivoanjo committed Oct 23, 2024
1 parent 6494eee commit dd653ce
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions ext/datadog_profiling_native_extension/heap_recorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ struct heap_recorder {
unsigned long updates_skipped_gcgen;
unsigned long updates_skipped_time;

double ewma_young_objects_alive;
double ewma_young_objects_dead;
double ewma_young_objects_skipped; // Note: Here "young" refers to the young update; objects skipped includes non-young objects

double ewma_objects_alive;
double ewma_objects_dead;
double ewma_objects_skipped;
Expand Down Expand Up @@ -491,12 +495,15 @@ static void heap_recorder_update(heap_recorder *heap_recorder, bool full_update)
heap_recorder->stats_lifetime.updates_successful++;

// Lifetime stats updating
// TODO: Discuss with Alex -- should we separate these out between young objects only and full updates?
// Tracking them together in this way seems to be muddying the waters -- young object updates will have more objects
// skipped, and different mixes of alive/dead
heap_recorder->stats_lifetime.ewma_objects_alive = ewma_stat(heap_recorder->stats_lifetime.ewma_objects_alive, heap_recorder->stats_last_update.objects_alive);
heap_recorder->stats_lifetime.ewma_objects_dead = ewma_stat(heap_recorder->stats_lifetime.ewma_objects_dead, heap_recorder->stats_last_update.objects_dead);
heap_recorder->stats_lifetime.ewma_objects_skipped = ewma_stat(heap_recorder->stats_lifetime.ewma_objects_skipped, heap_recorder->stats_last_update.objects_skipped);
if (!full_update) {
heap_recorder->stats_lifetime.ewma_young_objects_alive = ewma_stat(heap_recorder->stats_lifetime.ewma_young_objects_alive, heap_recorder->stats_last_update.objects_alive);
heap_recorder->stats_lifetime.ewma_young_objects_dead = ewma_stat(heap_recorder->stats_lifetime.ewma_young_objects_dead, heap_recorder->stats_last_update.objects_dead);
heap_recorder->stats_lifetime.ewma_young_objects_skipped = ewma_stat(heap_recorder->stats_lifetime.ewma_young_objects_skipped, heap_recorder->stats_last_update.objects_skipped);
} else {
heap_recorder->stats_lifetime.ewma_objects_alive = ewma_stat(heap_recorder->stats_lifetime.ewma_objects_alive, heap_recorder->stats_last_update.objects_alive);
heap_recorder->stats_lifetime.ewma_objects_dead = ewma_stat(heap_recorder->stats_lifetime.ewma_objects_dead, heap_recorder->stats_last_update.objects_dead);
heap_recorder->stats_lifetime.ewma_objects_skipped = ewma_stat(heap_recorder->stats_lifetime.ewma_objects_skipped, heap_recorder->stats_last_update.objects_skipped);
}

heap_recorder->updating = false;
}
Expand Down Expand Up @@ -582,6 +589,10 @@ VALUE heap_recorder_state_snapshot(heap_recorder *heap_recorder) {
ID2SYM(rb_intern("lifetime_updates_skipped_concurrent")), /* => */ LONG2NUM(heap_recorder->stats_lifetime.updates_skipped_concurrent),
ID2SYM(rb_intern("lifetime_updates_skipped_gcgen")), /* => */ LONG2NUM(heap_recorder->stats_lifetime.updates_skipped_gcgen),
ID2SYM(rb_intern("lifetime_updates_skipped_time")), /* => */ LONG2NUM(heap_recorder->stats_lifetime.updates_skipped_time),
ID2SYM(rb_intern("lifetime_ewma_young_objects_alive")), /* => */ DBL2NUM(heap_recorder->stats_lifetime.ewma_young_objects_alive),
ID2SYM(rb_intern("lifetime_ewma_young_objects_dead")), /* => */ DBL2NUM(heap_recorder->stats_lifetime.ewma_young_objects_dead),
// Note: Here "young" refers to the young update; objects skipped includes non-young objects
ID2SYM(rb_intern("lifetime_ewma_young_objects_skipped")), /* => */ DBL2NUM(heap_recorder->stats_lifetime.ewma_young_objects_skipped),
ID2SYM(rb_intern("lifetime_ewma_objects_alive")), /* => */ DBL2NUM(heap_recorder->stats_lifetime.ewma_objects_alive),
ID2SYM(rb_intern("lifetime_ewma_objects_dead")), /* => */ DBL2NUM(heap_recorder->stats_lifetime.ewma_objects_dead),
ID2SYM(rb_intern("lifetime_ewma_objects_skipped")), /* => */ DBL2NUM(heap_recorder->stats_lifetime.ewma_objects_skipped),
Expand Down

0 comments on commit dd653ce

Please sign in to comment.