Skip to content
This repository has been archived by the owner before Nov 9, 2022. It is now read-only.
Permalink
Browse files
8277919: OldObjectSample event causing bloat in the class constant po…
…ol in JFR recording

Reviewed-by: jbachorik
  • Loading branch information
Markus Grönlund committed Dec 14, 2021
1 parent 32139c1 commit 475ec8e6c5abc3431344d69bd46395e8c4b46e4c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
@@ -202,7 +202,7 @@ static void prepare_for_resolution() {

static bool stack_trace_precondition(const ObjectSample* sample) {
assert(sample != NULL, "invariant");
return sample->has_stack_trace_id() && !sample->is_dead();
return sample->has_stack_trace_id() && !sample->is_dead() && !sample->stacktrace().valid();
}

class StackTraceBlobInstaller {
@@ -249,7 +249,7 @@ void StackTraceBlobInstaller::install(ObjectSample* sample) {
writer.write_type(TYPE_STACKTRACE);
writer.write_count(1);
ObjectSampleCheckpoint::write_stacktrace(stack_trace, writer);
blob = writer.copy();
blob = writer.move();
_cache.put(sample, blob);
sample->set_stacktrace(blob);
}
@@ -278,7 +278,7 @@ void ObjectSampleCheckpoint::on_rotation(const ObjectSampler* sampler) {
}

static bool is_klass_unloaded(traceid klass_id) {
assert(ClassLoaderDataGraph_lock->owned_by_self(), "invariant");
assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
return JfrKlassUnloading::is_unloaded(klass_id);
}

@@ -381,6 +381,12 @@ void ObjectSampleCheckpoint::write(const ObjectSampler* sampler, EdgeStore* edge
assert(sampler != NULL, "invariant");
assert(edge_store != NULL, "invariant");
assert(thread != NULL, "invariant");
{
// First install stacktrace blobs for the most recently added candidates.
MutexLocker lock(SafepointSynchronize::is_at_safepoint() ? nullptr : ClassLoaderDataGraph_lock);
// the lock is needed to ensure the unload lists do not grow in the middle of inspection.
install_stack_traces(sampler);
}
write_sample_blobs(sampler, emit_all, thread);
// write reference chains
if (!edge_store->is_empty()) {
@@ -232,6 +232,7 @@ int write__klass(JfrCheckpointWriter* writer, const void* k) {
int write__klass__leakp(JfrCheckpointWriter* writer, const void* k) {
assert(k != NULL, "invariant");
KlassPtr klass = (KlassPtr)k;
CLEAR_LEAKP(klass);
return write_klass(writer, klass, true);
}

@@ -835,7 +836,7 @@ class MethodIteratorHost {
private:
MethodCallback _method_cb;
KlassCallback _klass_cb;
MethodUsedPredicate<leakp> _method_used_predicate;
MethodUsedPredicate _method_used_predicate;
MethodFlagPredicate<leakp> _method_flag_predicate;
public:
MethodIteratorHost(JfrCheckpointWriter* writer,
@@ -146,16 +146,12 @@ class SymbolPredicate {
}
};

template <bool leakp>
class MethodUsedPredicate {
bool _current_epoch;
public:
MethodUsedPredicate(bool current_epoch) : _current_epoch(current_epoch) {}
bool operator()(const Klass* klass) {
if (_current_epoch) {
return leakp ? IS_LEAKP(klass) : METHOD_USED_THIS_EPOCH(klass);
}
return leakp ? IS_LEAKP(klass) : METHOD_USED_PREVIOUS_EPOCH(klass);
return _current_epoch ? METHOD_USED_THIS_EPOCH(klass) : METHOD_USED_PREVIOUS_EPOCH(klass);
}
};

5 comments on commit 475ec8e

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 475ec8e Dec 14, 2021

Choose a reason for hiding this comment

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

@jbachorik
Copy link

@jbachorik jbachorik commented on 475ec8e Dec 15, 2021

Choose a reason for hiding this comment

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

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on 475ec8e Dec 15, 2021

Choose a reason for hiding this comment

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

@jbachorik the backport was successfully created on the branch jbachorik-backport-475ec8e6 in my personal fork of openjdk/jdk17u. To create a pull request with this backport targeting openjdk/jdk17u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 475ec8e6 from the openjdk/jdk18 repository.

The commit being backported was authored by Markus Grönlund on 14 Dec 2021 and was reviewed by Jaroslav Bachorik.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u:

$ git fetch https://github.com/openjdk-bots/jdk17u jbachorik-backport-475ec8e6:jbachorik-backport-475ec8e6
$ git checkout jbachorik-backport-475ec8e6
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u jbachorik-backport-475ec8e6

@jbachorik
Copy link

@jbachorik jbachorik commented on 475ec8e Dec 29, 2021

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 475ec8e Dec 29, 2021

Choose a reason for hiding this comment

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

@jbachorik the backport was successfully created on the branch jbachorik-backport-475ec8e6 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 475ec8e6 from the openjdk/jdk18 repository.

The commit being backported was authored by Markus Grönlund on 14 Dec 2021 and was reviewed by Jaroslav Bachorik.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev jbachorik-backport-475ec8e6:jbachorik-backport-475ec8e6
$ git checkout jbachorik-backport-475ec8e6
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev jbachorik-backport-475ec8e6

Please sign in to comment.