Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove thread information on Isolates page #2730

Merged
merged 2 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ class IsolateStatisticsViewBody extends StatelessWidget {
child: _buildTopRow(),
),
Flexible(
child: _buildBottomRow(),
child: IsolatePortsWidget(
controller: controller,
),
),
],
),
Expand All @@ -74,8 +76,19 @@ class IsolateStatisticsViewBody extends StatelessWidget {
return Row(
children: [
Flexible(
child: GeneralIsolateStatisticsWidget(
controller: controller,
child: Column(
children: [
Flexible(
child: GeneralIsolateStatisticsWidget(
controller: controller,
),
),
Flexible(
child: IsolateMemoryStatisticsWidget(
controller: controller,
),
),
],
),
),
Flexible(
Expand All @@ -91,24 +104,6 @@ class IsolateStatisticsViewBody extends StatelessWidget {
],
);
}

Widget _buildBottomRow() {
return Row(
children: [
Flexible(
child: IsolateMemoryStatisticsWidget(
controller: controller,
),
),
Flexible(
flex: 2,
child: IsolatePortsWidget(
controller: controller,
),
),
],
);
}
}

/// Displays general information about the current isolate, including:
Expand Down Expand Up @@ -166,8 +161,6 @@ class GeneralIsolateStatisticsWidget extends StatelessWidget {
/// Displays memory statistics for the isolate, including:
/// - Total Dart heap size
/// - New + Old space capacity and usage
/// - Handle counts (zone + scoped)
/// - Per-thread zone memory usage
class IsolateMemoryStatisticsWidget extends StatelessWidget {
const IsolateMemoryStatisticsWidget({@required this.controller});

Expand Down Expand Up @@ -211,21 +204,7 @@ class IsolateMemoryStatisticsWidget extends StatelessWidget {
isolate?.oldSpaceCapacity,
),
),
MapEntry(
'Max Zone Capacity',
prettyPrintBytes(
controller.zoneCapacityHighWatermark,
includeUnit: true,
),
),
MapEntry('# of Zone Handles', isolate?.zoneHandleCount),
MapEntry('# of Scoped Handles', isolate?.scopedHandleCount),
],
table: Flexible(
child: ThreadMemoryTable(
controller: controller,
),
),
),
),
],
Expand Down Expand Up @@ -284,88 +263,6 @@ class _PercentageColumn extends ColumnData<VMTag> {
String getDisplayValue(VMTag dataObject) => percent2(dataObject.percentage);
}

/// Displays a table of threads associated with a given isolate with the
/// following information:
/// - Thread kind (e.g., mutator, background compiler, etc.)
/// - Maximum zone capacity (aka "high watermark")
/// - Current zone capacity
class ThreadMemoryTable extends StatelessWidget {
ThreadMemoryTable({@required this.controller});

final id = _IDColumn();
final kind = _KindColumn();
final watermark = _HighWatermarkColumn();
final capacity = _ZoneCapacityColumn();

List<ColumnData<Thread>> get columns => [
id,
kind,
watermark,
capacity,
];
final IsolateStatisticsViewController controller;

@override
Widget build(BuildContext context) {
final threads = controller.isolate?.threads ?? [];
return Column(
children: [
areaPaneHeader(context, title: 'Threads (${threads.length})'),
Expanded(
child: FlatTable<Thread>(
columns: columns,
data: threads,
keyFactory: (Thread thread) => ValueKey<String>(thread.id),
sortColumn: id,
sortDirection: SortDirection.ascending,
onItemSelected: (_) => null,
),
),
],
);
}
}

class _IDColumn extends ColumnData<Thread> {
_IDColumn() : super.wide('ID');

@override
String getValue(Thread thread) => thread.id;
}

class _KindColumn extends ColumnData<Thread> {
_KindColumn() : super.wide('Kind');

@override
String getValue(Thread thread) => thread.kind;
}

class _HighWatermarkColumn extends ColumnData<Thread> {
_HighWatermarkColumn() : super.wide('Max Zone Capacity');

@override
int getValue(Thread thread) => thread.zoneHighWatermark;

@override
String getDisplayValue(Thread thread) => prettyPrintBytes(
thread.zoneHighWatermark,
includeUnit: true,
);
}

class _ZoneCapacityColumn extends ColumnData<Thread> {
_ZoneCapacityColumn() : super.wide('Current Zone Capacity');

@override
int getValue(Thread thread) => thread.zoneCapacity;

@override
String getDisplayValue(Thread thread) => prettyPrintBytes(
thread.zoneCapacity,
includeUnit: true,
);
}

class _PortIDColumn extends ColumnData<InstanceRef> {
_PortIDColumn() : super.wide('ID');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ class IsolateStatisticsViewController extends DisposableController
UnmodifiableListView(_serviceExtensions);
List<String> _serviceExtensions = [];

int get zoneCapacityHighWatermark => _zoneCapacityHighWatermark;
int _zoneCapacityHighWatermark = 0;

Future<void> refresh() async => await switchToIsolate(isolate);

Future<void> switchToIsolate(IsolateRef isolateRef) async {
Expand All @@ -57,7 +54,6 @@ class IsolateStatisticsViewController extends DisposableController
// Retrieve updated isolate information and refresh the page.
_isolate = await _service.getIsolate(isolateRef.id);
_updateTagCounters(isolate);
_updateZoneUsageData(isolate);
_ports = (await _service.getPorts(_isolate.id)).ports;
_serviceExtensions = isolate.extensionRPCs ?? [];
_serviceExtensions.sort();
Expand Down Expand Up @@ -87,14 +83,6 @@ class IsolateStatisticsViewController extends DisposableController
];
}
}

void _updateZoneUsageData(Isolate isolate) {
final currentWatermark =
isolate.threads.fold(0, (p, t) => p + t.zoneHighWatermark);
if (currentWatermark > _zoneCapacityHighWatermark) {
_zoneCapacityHighWatermark = currentWatermark;
}
}
}

/// Data class representing a single VM tag and its runtime percentage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:meta/meta.dart';
import 'package:vm_service/vm_service.dart';

/// NOTE: this file contains extensions to classes provided by
Expand All @@ -22,13 +21,6 @@ extension VMPrivateViewExtension on VM {

/// An extension on [Isolate] which allows for access to VM internal fields.
extension IsolatePrivateViewExtension on Isolate {
List<Thread> get threads {
return (json['_threads'].cast<Map<String, dynamic>>())
.map((e) => Thread.parse(e))
.toList()
.cast<Thread>();
}

Map<String, dynamic> get tagCounters => json['_tagCounters'];

int get dartHeapSize => newSpaceUsage + oldSpaceUsage;
Expand All @@ -39,31 +31,4 @@ extension IsolatePrivateViewExtension on Isolate {

int get newSpaceCapacity => json['_heaps']['new']['capacity'];
int get oldSpaceCapacity => json['_heaps']['old']['capacity'];

int get zoneHandleCount => json['_numZoneHandles'];
int get scopedHandleCount => json['_numScopedHandles'];
}

/// An internal representation of a thread running within an isolate.
class Thread {
const Thread({
@required this.id,
@required this.kind,
@required this.zoneHighWatermark,
@required this.zoneCapacity,
});

factory Thread.parse(Map<String, dynamic> json) {
return Thread(
id: json['id'],
kind: json['kind'],
zoneHighWatermark: int.parse(json['_zoneHighWatermark']),
zoneCapacity: int.parse(json['_zoneCapacity']),
);
}

final String id;
final String kind;
final int zoneHighWatermark;
final int zoneCapacity;
}