[vm/metrics] Ensure the metrics exposed by VM also include on-the-fly metrics
The lower-case "value()" metrics getter can only be used to obtain metrics which are explicitly set by the VM. The metrics we expose also include ones which are computed on-the-fly. Those have to be accessed via "Value()". Change-Id: I283c3c7c660d47c383b880b4bff6357a4dba9c01 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123252 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
abb6f993b5
commit
5fba90b2f8
@@ -1060,7 +1060,7 @@ DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) {
|
||||
#if !defined(PRODUCT)
|
||||
#define VM_METRIC_API(type, variable, name, unit) \
|
||||
DART_EXPORT int64_t Dart_VM##variable##Metric() { \
|
||||
return vm_metric_##variable.value(); \
|
||||
return vm_metric_##variable.Value(); \
|
||||
}
|
||||
VM_METRIC_LIST(VM_METRIC_API);
|
||||
#undef VM_METRIC_API
|
||||
@@ -1071,7 +1071,7 @@ VM_METRIC_LIST(VM_METRIC_API);
|
||||
FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); \
|
||||
} \
|
||||
Isolate* iso = reinterpret_cast<Isolate*>(isolate); \
|
||||
return iso->Get##variable##Metric()->value(); \
|
||||
return iso->Get##variable##Metric()->Value(); \
|
||||
}
|
||||
ISOLATE_METRIC_LIST(ISOLATE_METRIC_API);
|
||||
#undef ISOLATE_METRIC_API
|
||||
|
||||
+10
-11
@@ -88,7 +88,6 @@ class Metric {
|
||||
|
||||
static Metric* vm_head() { return vm_list_head_; }
|
||||
|
||||
protected:
|
||||
// Override to get a callback when value is serialized to JSON.
|
||||
// Use this for metrics that produce their value on demand.
|
||||
virtual int64_t Value() const { return value(); }
|
||||
@@ -131,52 +130,52 @@ class MinMetric : public Metric {
|
||||
};
|
||||
|
||||
class MetricHeapOldUsed : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
class MetricHeapOldCapacity : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
class MetricHeapOldExternal : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
class MetricHeapNewUsed : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
class MetricHeapNewCapacity : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
class MetricHeapNewExternal : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
class MetricIsolateCount : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
class MetricCurrentRSS : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
class MetricPeakRSS : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
class MetricHeapUsed : public Metric {
|
||||
protected:
|
||||
public:
|
||||
virtual int64_t Value() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "platform/assert.h"
|
||||
|
||||
#include "include/dart_api.h"
|
||||
#include "include/dart_tools_api.h"
|
||||
|
||||
#include "vm/dart_api_impl.h"
|
||||
#include "vm/dart_api_state.h"
|
||||
#include "vm/globals.h"
|
||||
@@ -73,6 +76,42 @@ VM_UNIT_TEST_CASE(Metric_OnDemand) {
|
||||
Dart_ShutdownIsolate();
|
||||
}
|
||||
|
||||
ISOLATE_UNIT_TEST_CASE(Metric_EmbedderAPI) {
|
||||
{
|
||||
TransitionVMToNative transition(Thread::Current());
|
||||
|
||||
const char* kScript = "void main() {}";
|
||||
Dart_Handle api_lib = TestCase::LoadTestScript(
|
||||
kScript, /*resolver=*/nullptr, RESOLVED_USER_TEST_URI);
|
||||
EXPECT_VALID(api_lib);
|
||||
}
|
||||
|
||||
// Ensure we've done new/old GCs to ensure max metrics are initialized.
|
||||
String::New("<land-in-new-space>", Heap::kNew);
|
||||
Isolate::Current()->heap()->new_space()->Scavenge();
|
||||
Isolate::Current()->heap()->CollectAllGarbage(Heap::kLowMemory);
|
||||
|
||||
// Ensure we've something live in new space.
|
||||
String::New("<land-in-new-space2>", Heap::kNew);
|
||||
|
||||
{
|
||||
TransitionVMToNative transition(Thread::Current());
|
||||
|
||||
Dart_Isolate isolate = Dart_CurrentIsolate();
|
||||
EXPECT(Dart_VMIsolateCountMetric() > 0);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !PRODUCT
|
||||
|
||||
} // namespace dart
|
||||
|
||||
Reference in New Issue
Block a user