mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[vm/heap/metrics] Make sure heap-related metric are reported for the isolate group, rather than isolate.
TEST=ci Change-Id: Ie0514f05c0a024ce37f10d56dd29b3fa921133d2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247504 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Alexander Aprelev <aam@google.com>
This commit is contained in:
parent
6e27d2458f
commit
1fddb10107
|
@ -1204,6 +1204,14 @@ DART_EXPORT Dart_IsolateGroup Dart_CurrentIsolateGroup(void);
|
|||
*/
|
||||
DART_EXPORT void* Dart_CurrentIsolateGroupData(void);
|
||||
|
||||
/**
|
||||
* Gets an id that uniquely identifies current isolate group.
|
||||
*
|
||||
* It is the responsibility of the caller to free the returned ID.
|
||||
*/
|
||||
typedef int64_t Dart_IsolateGroupId;
|
||||
DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId();
|
||||
|
||||
/**
|
||||
* Returns the callback data associated with the specified isolate group. This
|
||||
* data was passed to the isolate when it was created.
|
||||
|
|
|
@ -290,7 +290,10 @@ typedef struct {
|
|||
typedef struct {
|
||||
const char* type;
|
||||
const char* reason;
|
||||
|
||||
// DEPRECATED: Use [isolate_group_id] instead.
|
||||
const char* isolate_id;
|
||||
Dart_IsolateGroupId isolate_group_id;
|
||||
|
||||
Dart_GCStats new_space;
|
||||
Dart_GCStats old_space;
|
||||
|
@ -457,30 +460,68 @@ DART_EXPORT void Dart_SetThreadName(const char* name);
|
|||
DART_EXPORT int64_t Dart_VMIsolateCountMetric(); // Counter
|
||||
DART_EXPORT int64_t Dart_VMCurrentRSSMetric(); // Byte
|
||||
DART_EXPORT int64_t Dart_VMPeakRSSMetric(); // Byte
|
||||
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapOldUsedMetric instead
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldUsedMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapOldUsedMaxMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldUsedMaxMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapOldCapacityMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldCapacityMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapOldCapacityMaxMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldCapacityMaxMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapOldExternalMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapOldExternalMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapNewUsedMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewUsedMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapNewUsedMaxMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewUsedMaxMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapNewCapacityMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewCapacityMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapNewCapacityMaxMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewCapacityMaxMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapNewExternalMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapNewExternalMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapGlobalUsedMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapGlobalUsedMetric(Dart_Isolate isolate); // Byte
|
||||
// DEPRECATED: Use Dart_IsolateGroupHeapGlobalUsedMaxMetric instead.
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateHeapGlobalUsedMaxMetric(Dart_Isolate isolate); // Byte
|
||||
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapOldUsedMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapOldUsedMaxMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapOldCapacityMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapOldCapacityMaxMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapOldExternalMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapNewUsedMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapNewUsedMaxMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapNewCapacityMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapNewCapacityMaxMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapNewExternalMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapGlobalUsedMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateGroupHeapGlobalUsedMaxMetric(Dart_IsolateGroup group); // Byte
|
||||
DART_EXPORT int64_t
|
||||
Dart_IsolateRunnableLatencyMetric(Dart_Isolate isolate); // Microsecond
|
||||
DART_EXPORT int64_t
|
||||
|
|
|
@ -1234,6 +1234,7 @@ VM_METRIC_LIST(VM_METRIC_API)
|
|||
#undef VM_METRIC_API
|
||||
#endif // !defined(PRODUCT)
|
||||
|
||||
// TODO(dartbug.com/49211): Remove definition of deprecated functions.
|
||||
#define ISOLATE_GROUP_METRIC_API(type, variable, name, unit) \
|
||||
DART_EXPORT int64_t Dart_Isolate##variable##Metric(Dart_Isolate isolate) { \
|
||||
if (isolate == nullptr) { \
|
||||
|
@ -1241,6 +1242,15 @@ VM_METRIC_LIST(VM_METRIC_API)
|
|||
} \
|
||||
Isolate* iso = reinterpret_cast<Isolate*>(isolate); \
|
||||
return iso->group()->Get##variable##Metric()->Value(); \
|
||||
} \
|
||||
DART_EXPORT int64_t Dart_IsolateGroup##variable##Metric( \
|
||||
Dart_IsolateGroup isolate_group) { \
|
||||
if (isolate_group == nullptr) { \
|
||||
FATAL1("%s expects argument 'isolate_group' to be non-null.", \
|
||||
CURRENT_FUNC); \
|
||||
} \
|
||||
IsolateGroup* group = reinterpret_cast<IsolateGroup*>(isolate_group); \
|
||||
return group->Get##variable##Metric()->Value(); \
|
||||
}
|
||||
ISOLATE_GROUP_METRIC_LIST(ISOLATE_GROUP_METRIC_API)
|
||||
#undef ISOLATE_GROUP_METRIC_API
|
||||
|
@ -1528,6 +1538,12 @@ DART_EXPORT void* Dart_CurrentIsolateGroupData() {
|
|||
return isolate_group->embedder_data();
|
||||
}
|
||||
|
||||
DART_EXPORT Dart_IsolateGroupId Dart_CurrentIsolateGroupId() {
|
||||
IsolateGroup* isolate_group = IsolateGroup::Current();
|
||||
CHECK_ISOLATE_GROUP(isolate_group);
|
||||
return isolate_group->id();
|
||||
}
|
||||
|
||||
DART_EXPORT void* Dart_IsolateGroupData(Dart_Isolate isolate) {
|
||||
if (isolate == NULL) {
|
||||
FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC);
|
||||
|
|
|
@ -1026,58 +1026,51 @@ void Heap::RecordAfterGC(GCType type) {
|
|||
}
|
||||
#endif // !PRODUCT
|
||||
if (Dart::gc_event_callback() != nullptr) {
|
||||
isolate_group_->ForEachIsolate(
|
||||
[&](Isolate* isolate) {
|
||||
if (!Isolate::IsSystemIsolate(isolate)) {
|
||||
Dart_GCEvent event;
|
||||
auto isolate_id = Utils::CStringUniquePtr(
|
||||
OS::SCreate(nullptr, ISOLATE_SERVICE_ID_FORMAT_STRING,
|
||||
isolate->main_port()),
|
||||
std::free);
|
||||
int64_t isolate_uptime_micros = isolate->UptimeMicros();
|
||||
Dart_GCEvent event;
|
||||
int64_t isolate_group_uptime_micros = isolate_group_->UptimeMicros();
|
||||
|
||||
event.isolate_id = isolate_id.get();
|
||||
event.type = GCTypeToString(stats_.type_);
|
||||
event.reason = GCReasonToString(stats_.reason_);
|
||||
// TODO(dartbug.com/49211): Remove use of deprecated [isolate_id] field.
|
||||
auto isolate_id = Utils::CStringUniquePtr(
|
||||
OS::SCreate(nullptr, ISOLATE_GROUP_SERVICE_ID_FORMAT_STRING,
|
||||
isolate_group_->id()),
|
||||
std::free);
|
||||
event.isolate_id = isolate_id.get();
|
||||
|
||||
// New space - Scavenger.
|
||||
{
|
||||
intptr_t new_space_collections = new_space_.collections();
|
||||
event.isolate_group_id = isolate_group_->id();
|
||||
event.type = GCTypeToString(stats_.type_);
|
||||
event.reason = GCReasonToString(stats_.reason_);
|
||||
|
||||
event.new_space.collections = new_space_collections;
|
||||
event.new_space.used =
|
||||
stats_.after_.new_.used_in_words * kWordSize;
|
||||
event.new_space.capacity =
|
||||
stats_.after_.new_.capacity_in_words * kWordSize;
|
||||
event.new_space.external =
|
||||
stats_.after_.new_.external_in_words * kWordSize;
|
||||
event.new_space.time =
|
||||
MicrosecondsToSeconds(new_space_.gc_time_micros());
|
||||
event.new_space.avg_collection_period = AvgCollectionPeriod(
|
||||
isolate_uptime_micros, new_space_collections);
|
||||
}
|
||||
// New space - Scavenger.
|
||||
{
|
||||
intptr_t new_space_collections = new_space_.collections();
|
||||
|
||||
// Old space - Page.
|
||||
{
|
||||
intptr_t old_space_collections = old_space_.collections();
|
||||
event.new_space.collections = new_space_collections;
|
||||
event.new_space.used = stats_.after_.new_.used_in_words * kWordSize;
|
||||
event.new_space.capacity =
|
||||
stats_.after_.new_.capacity_in_words * kWordSize;
|
||||
event.new_space.external =
|
||||
stats_.after_.new_.external_in_words * kWordSize;
|
||||
event.new_space.time = MicrosecondsToSeconds(new_space_.gc_time_micros());
|
||||
event.new_space.avg_collection_period = AvgCollectionPeriod(
|
||||
isolate_group_uptime_micros, new_space_collections);
|
||||
}
|
||||
|
||||
event.old_space.collections = old_space_collections;
|
||||
event.old_space.used =
|
||||
stats_.after_.old_.used_in_words * kWordSize;
|
||||
event.old_space.capacity =
|
||||
stats_.after_.old_.capacity_in_words * kWordSize;
|
||||
event.old_space.external =
|
||||
stats_.after_.old_.external_in_words * kWordSize;
|
||||
event.old_space.time =
|
||||
MicrosecondsToSeconds(old_space_.gc_time_micros());
|
||||
event.old_space.avg_collection_period = AvgCollectionPeriod(
|
||||
isolate_uptime_micros, old_space_collections);
|
||||
}
|
||||
// Old space - Page.
|
||||
{
|
||||
intptr_t old_space_collections = old_space_.collections();
|
||||
|
||||
(*Dart::gc_event_callback())(&event);
|
||||
}
|
||||
},
|
||||
/*at_safepoint=*/true);
|
||||
event.old_space.collections = old_space_collections;
|
||||
event.old_space.used = stats_.after_.old_.used_in_words * kWordSize;
|
||||
event.old_space.capacity =
|
||||
stats_.after_.old_.capacity_in_words * kWordSize;
|
||||
event.old_space.external =
|
||||
stats_.after_.old_.external_in_words * kWordSize;
|
||||
event.old_space.time = MicrosecondsToSeconds(old_space_.gc_time_micros());
|
||||
event.old_space.avg_collection_period = AvgCollectionPeriod(
|
||||
isolate_group_uptime_micros, old_space_collections);
|
||||
}
|
||||
|
||||
(*Dart::gc_event_callback())(&event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -479,10 +479,10 @@ void IsolateGroup::CreateHeap(bool is_vm_isolate,
|
|||
|
||||
is_vm_isolate_heap_ = is_vm_isolate;
|
||||
|
||||
#define ISOLATE_METRIC_CONSTRUCTORS(type, variable, name, unit) \
|
||||
#define ISOLATE_GROUP_METRIC_CONSTRUCTORS(type, variable, name, unit) \
|
||||
metric_##variable##_.InitInstance(this, name, nullptr, Metric::unit);
|
||||
ISOLATE_GROUP_METRIC_LIST(ISOLATE_METRIC_CONSTRUCTORS)
|
||||
#undef ISOLATE_METRIC_CONSTRUCTORS
|
||||
ISOLATE_GROUP_METRIC_LIST(ISOLATE_GROUP_METRIC_CONSTRUCTORS)
|
||||
#undef ISOLATE_GROUP_METRIC_CONSTRUCTORS
|
||||
}
|
||||
|
||||
void IsolateGroup::Shutdown() {
|
||||
|
|
|
@ -99,20 +99,20 @@ ISOLATE_UNIT_TEST_CASE(Metric_EmbedderAPI) {
|
|||
{
|
||||
TransitionVMToNative transition(thread);
|
||||
|
||||
Dart_Isolate isolate = Dart_CurrentIsolate();
|
||||
Dart_IsolateGroup isolate_group = Dart_CurrentIsolateGroup();
|
||||
#if !defined(PRODUCT)
|
||||
EXPECT(Dart_VMIsolateCountMetric() > 0);
|
||||
#endif
|
||||
EXPECT(Dart_IsolateHeapOldUsedMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateHeapOldUsedMaxMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateHeapOldCapacityMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateHeapOldCapacityMaxMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateHeapNewUsedMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateHeapNewUsedMaxMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateHeapNewCapacityMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateHeapNewCapacityMaxMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateHeapGlobalUsedMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateHeapGlobalUsedMaxMetric(isolate) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapOldUsedMetric(isolate_group) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapOldUsedMaxMetric(isolate_group) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapOldCapacityMetric(isolate_group) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapOldCapacityMaxMetric(isolate_group) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapNewUsedMetric(isolate_group) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapNewUsedMaxMetric(isolate_group) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapNewCapacityMetric(isolate_group) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapNewCapacityMaxMetric(isolate_group) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapGlobalUsedMetric(isolate_group) > 0);
|
||||
EXPECT(Dart_IsolateGroupHeapGlobalUsedMaxMetric(isolate_group) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue