diff --git a/src/native/clr/host/bridge-processing.cc b/src/native/clr/host/bridge-processing.cc index 2489346b15e..157407c822f 100644 --- a/src/native/clr/host/bridge-processing.cc +++ b/src/native/clr/host/bridge-processing.cc @@ -165,6 +165,17 @@ void BridgeProcessingShared::process () noexcept GCBridge::trigger_java_gc (env); cleanup_after_java_collection (); log_gc_summary (); + + // GC bridge gref churn instrumentation (dotnet/runtime#131370): one line per round. + // Every peer is flipped strong->weak in prepare (NewWeakGlobalRef + DeleteGlobalRef) and + // weak->strong in cleanup (NewGlobalRef + DeleteWeakGlobalRef): 4 JNI global-ref ops per peer. + size_t churn_peers = 0; + for (size_t i = 0; i < cross_refs->ComponentCount; i++) { + churn_peers = Helpers::add_with_overflow_check (churn_peers, cross_refs->Components [i].Count); + } + log_warnf (LOG_GC, "GCBRIDGE_CHURN runtime=coreclr sccs=%zu peers=%zu xrefs=%zu jni_transitions=%zu", + static_cast (cross_refs->ComponentCount), churn_peers, + static_cast (cross_refs->CrossReferenceCount), churn_peers * 4); } void BridgeProcessingShared::prepare_for_java_collection () noexcept diff --git a/src/native/mono/monodroid/osbridge.cc b/src/native/mono/monodroid/osbridge.cc index f6a111a6885..6fa7853b889 100644 --- a/src/native/mono/monodroid/osbridge.cc +++ b/src/native/mono/monodroid/osbridge.cc @@ -1035,6 +1035,15 @@ OSBridge::gc_cross_references (int num_sccs, MonoGCBridgeSCC **sccs, int num_xre gc_cleanup_after_java_collection (env, num_sccs, sccs); set_bridge_processing_field (domains_list, 0); + + // GC bridge gref churn instrumentation (dotnet/runtime#131370): one line per round. + // Every peer is flipped strong->weak in prepare (NewWeakGlobalRef + DeleteGlobalRef) and + // weak->strong in cleanup (NewGlobalRef + DeleteWeakGlobalRef): 4 JNI global-ref ops per peer. + int churn_peers = 0; + for (int i = 0; i < num_sccs; i++) + churn_peers += sccs [i]->num_objs; + log_warn (LOG_GC, "GCBRIDGE_CHURN runtime=mono sccs={} peers={} xrefs={} jni_transitions={}", + num_sccs, churn_peers, num_xrefs, churn_peers * 4); } void