Remove class ref cache because it is too expensive · DataDog/java-profiler@930bc88 · GitHub
Skip to content

Commit 930bc88

Browse files
committed
Remove class ref cache because it is too expensive
1 parent b419969 commit 930bc88

6 files changed

Lines changed: 6 additions & 239 deletions

File tree

‎ddprof-lib/src/main/cpp/classRefCache.cpp‎

Lines changed: 0 additions & 87 deletions
This file was deleted.

‎ddprof-lib/src/main/cpp/classRefCache.h‎

Lines changed: 0 additions & 119 deletions
This file was deleted.

‎ddprof-lib/src/main/cpp/flightRecorder.cpp‎

Lines changed: 1 addition & 7 deletions

‎ddprof-lib/src/main/cpp/livenessTracker.cpp‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <jni.h>
2020
#include <string.h>
2121
#include "arch.h"
22-
#include "classRefCache.h"
2322
#include "context.h"
2423
#include "incbin.h"
2524
#include "livenessTracker.h"
@@ -32,7 +31,7 @@
3231

3332
LivenessTracker* const LivenessTracker::_instance = new LivenessTracker();
3433

35-
void LivenessTracker::cleanup_table(bool update_class_ref_cache) {
34+
void LivenessTracker::cleanup_table() {
3635
u64 current = loadAcquire(_last_gc_epoch);
3736
u64 target_gc_epoch = loadAcquire(_gc_epoch);
3837

@@ -52,15 +51,6 @@ void LivenessTracker::cleanup_table(bool update_class_ref_cache) {
5251
std::set<jclass> kept_classes;
5352
for (u32 i = 0; i < (sz = _table_size); i++) {
5453
if (!env->IsSameObject(_table[i].ref, NULL)) {
55-
if (update_class_ref_cache) {
56-
// collect referenced classes
57-
jclass klass;
58-
for (int f_idx = 0; f_idx < _table[i].frames_size; f_idx++) {
59-
if (jvmti->GetMethodDeclaringClass(_table[i].frames[f_idx].method, &klass) == 0) {
60-
kept_classes.insert(klass);
61-
}
62-
}
63-
}
6454
// it survived one more GarbageCollectionFinish event
6555
_table[i].age += epoch_diff;
6656
_table[newsz++] = _table[i];
@@ -74,10 +64,6 @@ void LivenessTracker::cleanup_table(bool update_class_ref_cache) {
7464

7565
_table_size = newsz;
7666

77-
if (update_class_ref_cache) {
78-
ClassRefCache::instance()->keep(env, kept_classes);
79-
}
80-
8167
_table_lock.unlock();
8268
end = OS::nanotime();
8369
Log::debug("Liveness tracker cleanup took %.2fms (%.2fus/element)",
@@ -94,7 +80,7 @@ void LivenessTracker::flush_table(std::set<int> *tracked_thread_ids) {
9480

9581
// make sure that the tracking table is cleaned up before we start flushing it
9682
// this is to make sure we are including as few false 'live' objects as possible
97-
cleanup_table(true);
83+
cleanup_table();
9884

9985
_table_lock.lockShared();
10086

@@ -185,7 +171,7 @@ Error LivenessTracker::start(Arguments& args) {
185171
}
186172

187173
void LivenessTracker::stop() {
188-
cleanup_table(false);
174+
cleanup_table();
189175
flush_table(NULL);
190176

191177
// do not disable GC notifications here - the tracker is supposed to survive multiple recordings
@@ -292,7 +278,7 @@ void LivenessTracker::track(JNIEnv* env, AllocEvent &event, jint tid, jobject ob
292278
retried = true;
293279

294280
// try cleanup before resizing - there is a good chance it will free some space
295-
cleanup_table(false);
281+
cleanup_table();
296282

297283
if (_table_cap < _table_max_cap) {
298284

‎ddprof-lib/src/main/cpp/livenessTracker.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class LivenessTracker {
6868
Error initialize(Arguments& args);
6969
Error initialize_table(int sampling_interval);
7070

71-
void cleanup_table(bool update_class_ref_cache);
71+
void cleanup_table();
7272

7373
void flush_table(std::set<int> *tracked_thread_ids);
7474

‎ddprof-lib/src/main/cpp/objectSampler.cpp‎

Lines changed: 0 additions & 7 deletions

0 commit comments

Comments
 (0)