Skip to content

Commit fca0324

Browse files
a-sivaCommit Queue
authored andcommitted
[VM/Runtime] Turn on isolate group metrics gathering in product mode
dart2js benchmarks use --print-metrics to track heap usage, with the shift to running dart2js using aproduct mode AOT snapshot these metrics are not printed resulting in errors from the benchmarks. The size increase from turning on these isolate group metrics in product mode is not very significant (about 2k). TEST=ci Change-Id: Ie9bbaecd57a2b45c27a158f6eb4988966a41ce67 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405220 Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Siva Annamalai <[email protected]>
1 parent ae92595 commit fca0324

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

runtime/vm/isolate.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2504,20 +2504,22 @@ void Isolate::LowLevelShutdown() {
25042504
"\tisolate: %s\n",
25052505
name());
25062506
}
2507+
#endif // !defined(PRODUCT)
25072508
if (FLAG_print_metrics) {
25082509
LogBlock lb;
25092510
OS::PrintErr("Printing metrics for %s\n", name());
25102511
#define ISOLATE_GROUP_METRIC_PRINT(type, variable, name, unit) \
25112512
OS::PrintErr("%s\n", isolate_group_->Get##variable##Metric()->ToString());
25122513
ISOLATE_GROUP_METRIC_LIST(ISOLATE_GROUP_METRIC_PRINT)
25132514
#undef ISOLATE_GROUP_METRIC_PRINT
2515+
#if !defined(PRODUCT)
25142516
#define ISOLATE_METRIC_PRINT(type, variable, name, unit) \
25152517
OS::PrintErr("%s\n", metric_##variable##_.ToString());
25162518
ISOLATE_METRIC_LIST(ISOLATE_METRIC_PRINT)
25172519
#undef ISOLATE_METRIC_PRINT
2520+
#endif // !defined(PRODUCT)
25182521
OS::PrintErr("\n");
25192522
}
2520-
#endif // !defined(PRODUCT)
25212523
}
25222524

25232525
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)

runtime/vm/metrics.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ void Metric::InitInstance(IsolateGroup* isolate_group,
3535
unit_ = unit;
3636
}
3737

38-
#if !defined(PRODUCT)
3938
void Metric::InitInstance(Isolate* isolate,
4039
const char* name,
4140
const char* description,
@@ -58,6 +57,7 @@ void Metric::InitInstance(const char* name,
5857
unit_ = unit;
5958
}
6059

60+
#if !defined(PRODUCT)
6161
static const char* UnitString(intptr_t unit) {
6262
switch (unit) {
6363
case Metric::kCounter:
@@ -79,11 +79,13 @@ void Metric::PrintJSON(JSONStream* stream) {
7979
obj.AddProperty("name", name_);
8080
obj.AddProperty("description", description_);
8181
obj.AddProperty("unit", UnitString(unit()));
82+
8283
if (isolate_ == nullptr && isolate_group_ == nullptr) {
8384
obj.AddFixedServiceId("vm/metrics/%s", name_);
8485
} else {
8586
obj.AddFixedServiceId("metrics/native/%s", name_);
8687
}
88+
8789
// TODO(johnmccutchan): Overflow?
8890
double value_as_double = static_cast<double>(Value());
8991
obj.AddProperty("value", value_as_double);
@@ -180,11 +182,11 @@ int64_t MetricHeapUsed::Value() const {
180182
isolate_group()->heap()->UsedInWords(Heap::kOld) * kWordSize;
181183
}
182184

183-
#if !defined(PRODUCT)
184185
int64_t MetricIsolateCount::Value() const {
185186
return Isolate::IsolateListLength();
186187
}
187188

189+
#if !defined(PRODUCT)
188190
int64_t MetricCurrentRSS::Value() const {
189191
return Service::CurrentRSS();
190192
}

runtime/vm/metrics.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ class Metric {
6060

6161
Metric();
6262

63-
#if !defined(PRODUCT)
6463
static void Init();
6564
static void Cleanup();
66-
#endif // !defined(PRODUCT)
6765

6866
// Initialize a metric for an isolate.
6967
void InitInstance(Isolate* isolate,
@@ -82,9 +80,9 @@ class Metric {
8280

8381
virtual ~Metric();
8482

85-
#ifndef PRODUCT
83+
#if !defined(PRODUCT)
8684
void PrintJSON(JSONStream* stream);
87-
#endif // !PRODUCT
85+
#endif // !defined(PRODUCT)
8886

8987
// Returns a zone allocated string.
9088
static char* ValueToString(int64_t value, Unit unit);
@@ -173,7 +171,6 @@ class MetricHeapNewExternal : public Metric {
173171
virtual int64_t Value() const;
174172
};
175173

176-
#if !defined(PRODUCT)
177174
class MetricIsolateCount : public Metric {
178175
public:
179176
virtual int64_t Value() const;
@@ -188,7 +185,6 @@ class MetricPeakRSS : public Metric {
188185
public:
189186
virtual int64_t Value() const;
190187
};
191-
#endif // !defined(PRODUCT)
192188

193189
class MetricHeapUsed : public Metric {
194190
public:

0 commit comments

Comments
 (0)