Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 2762323002: Reimplemented zone memory tracking to avoid race conditions that were causing crashes in the previo… (Closed)
Patch Set: Final change Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of service; 5 part of service;
6 6
7 // Some value smaller than the object ring, so requesting a large array 7 // Some value smaller than the object ring, so requesting a large array
8 // doesn't result in an expired ref because the elements lapped it in the 8 // doesn't result in an expired ref because the elements lapped it in the
9 // object ring. 9 // object ring.
10 const int kDefaultFieldLimit = 100; 10 const int kDefaultFieldLimit = 100;
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 String fileAndLine; 1512 String fileAndLine;
1513 1513
1514 DartError error; 1514 DartError error;
1515 StreamController _snapshotFetch; 1515 StreamController _snapshotFetch;
1516 1516
1517 List<ByteData> _chunksInProgress; 1517 List<ByteData> _chunksInProgress;
1518 1518
1519 List<Thread> get threads => _threads; 1519 List<Thread> get threads => _threads;
1520 final List<Thread> _threads = new List<Thread>(); 1520 final List<Thread> _threads = new List<Thread>();
1521 1521
1522 int get memoryHighWatermark => _memoryHighWatermark; 1522 int get zoneHighWatermark => _zoneHighWatermark;
1523 int _memoryHighWatermark = 0; 1523 int _zoneHighWatermark = 0;
1524 1524
1525 int get numZoneHandles => _numZoneHandles; 1525 int get numZoneHandles => _numZoneHandles;
1526 int _numZoneHandles; 1526 int _numZoneHandles;
1527 1527
1528 int get numScopedHandles => _numScopedHandles; 1528 int get numScopedHandles => _numScopedHandles;
1529 int _numScopedHandles; 1529 int _numScopedHandles;
1530 1530
1531 void _loadHeapSnapshot(ServiceEvent event) { 1531 void _loadHeapSnapshot(ServiceEvent event) {
1532 if (_snapshotFetch == null || _snapshotFetch.isClosed) { 1532 if (_snapshotFetch == null || _snapshotFetch.isClosed) {
1533 // No outstanding snapshot request. Presumably another client asked for a 1533 // No outstanding snapshot request. Presumably another client asked for a
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 extensionRPCs.clear(); 1651 extensionRPCs.clear();
1652 if (map['extensionRPCs'] != null) { 1652 if (map['extensionRPCs'] != null) {
1653 extensionRPCs.addAll(map['extensionRPCs']); 1653 extensionRPCs.addAll(map['extensionRPCs']);
1654 } 1654 }
1655 1655
1656 threads.clear(); 1656 threads.clear();
1657 if (map['_threads'] != null) { 1657 if (map['_threads'] != null) {
1658 threads.addAll(map['_threads']); 1658 threads.addAll(map['_threads']);
1659 } 1659 }
1660 1660
1661 int currentMemoryHighWatermark = 0; 1661 int currentZoneHighWatermark = 0;
1662 for (var i = 0; i < threads.length; i++) { 1662 for (var i = 0; i < threads.length; i++) {
1663 currentMemoryHighWatermark += threads[i].memoryHighWatermark; 1663 currentZoneHighWatermark += threads[i].zoneHighWatermark;
1664 } 1664 }
1665 1665
1666 if (currentMemoryHighWatermark > _memoryHighWatermark) { 1666 if (currentZoneHighWatermark > _zoneHighWatermark) {
1667 _memoryHighWatermark = currentMemoryHighWatermark; 1667 _zoneHighWatermark = currentZoneHighWatermark;
1668 } 1668 }
1669 1669
1670 _numZoneHandles = map['_numZoneHandles']; 1670 _numZoneHandles = map['_numZoneHandles'];
1671 _numScopedHandles = map['_numScopedHandles']; 1671 _numScopedHandles = map['_numScopedHandles'];
1672 } 1672 }
1673 1673
1674 Future<TagProfile> updateTagProfile() { 1674 Future<TagProfile> updateTagProfile() {
1675 return isolate.invokeRpcNoUpgrade('_getTagProfile', {}).then((Map map) { 1675 return isolate.invokeRpcNoUpgrade('_getTagProfile', {}).then((Map map) {
1676 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0; 1676 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0;
1677 tagProfile._processTagProfile(seconds, map); 1677 tagProfile._processTagProfile(seconds, map);
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
3099 3099
3100 String toString() => 'Sentinel($kind)'; 3100 String toString() => 'Sentinel($kind)';
3101 String get shortName => valueAsString; 3101 String get shortName => valueAsString;
3102 } 3102 }
3103 3103
3104 class Thread extends ServiceObject implements M.Thread { 3104 class Thread extends ServiceObject implements M.Thread {
3105 M.ThreadKind get kind => _kind; 3105 M.ThreadKind get kind => _kind;
3106 M.ThreadKind _kind; 3106 M.ThreadKind _kind;
3107 String get kindString => _kindString; 3107 String get kindString => _kindString;
3108 String _kindString; 3108 String _kindString;
3109 int get memoryHighWatermark => _memoryHighWatermark; 3109 int get zoneHighWatermark => _zoneHighWatermark;
3110 int _memoryHighWatermark; 3110 int _zoneHighWatermark;
3111 3111 int get zoneCapacity => _zoneCapacity;
3112 // TODO(bkonyi): zones will always be empty. See issue #28885. 3112 int _zoneCapacity;
3113 List<Zone> get zones => _zones;
3114 final List<Zone> _zones = new List<Zone>();
3115 3113
3116 Thread._empty(ServiceObjectOwner owner) : super._empty(owner); 3114 Thread._empty(ServiceObjectOwner owner) : super._empty(owner);
3117 3115
3118 void _update(Map map, bool mapIsRef) { 3116 void _update(Map map, bool mapIsRef) {
3119 String rawKind = map['kind']; 3117 String rawKind = map['kind'];
3120 3118
3121 switch (rawKind) { 3119 switch (rawKind) {
3122 case "kUnknownTask": 3120 case "kUnknownTask":
3123 _kind = M.ThreadKind.unknownTask; 3121 _kind = M.ThreadKind.unknownTask;
3124 _kindString = 'unknown'; 3122 _kindString = 'unknown';
(...skipping 15 matching lines...) Expand all
3140 _kindString = 'marker'; 3138 _kindString = 'marker';
3141 break; 3139 break;
3142 case "kFinalizerTask": 3140 case "kFinalizerTask":
3143 _kind = M.ThreadKind.finalizerTask; 3141 _kind = M.ThreadKind.finalizerTask;
3144 _kindString = 'finalizer'; 3142 _kindString = 'finalizer';
3145 break; 3143 break;
3146 default: 3144 default:
3147 assert(false); 3145 assert(false);
3148 } 3146 }
3149 3147
3150 _memoryHighWatermark = int.parse(map['_memoryHighWatermark']); 3148 _zoneHighWatermark = int.parse(map['_zoneHighWatermark']);
3149 _zoneCapacity = int.parse(map['_zoneCapacity']);
3151 } 3150 }
3152 } 3151 }
3153 3152
3154 class Zone implements M.Zone { 3153 class Zone implements M.Zone {
3155 int get capacity => _capacity; 3154 int get capacity => _capacity;
3156 int _capacity; 3155 int _capacity;
3157 int get used => _used; 3156 int get used => _used;
3158 int _used; 3157 int _used;
3159 3158
3160 Zone(this._capacity, this._used); 3159 Zone(this._capacity, this._used);
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
4625 var v = list[i]; 4624 var v = list[i];
4626 if ((v is Map) && _isServiceMap(v)) { 4625 if ((v is Map) && _isServiceMap(v)) {
4627 list[i] = owner.getFromMap(v); 4626 list[i] = owner.getFromMap(v);
4628 } else if (v is List) { 4627 } else if (v is List) {
4629 _upgradeList(v, owner); 4628 _upgradeList(v, owner);
4630 } else if (v is Map) { 4629 } else if (v is Map) {
4631 _upgradeMap(v, owner); 4630 _upgradeMap(v, owner);
4632 } 4631 }
4633 } 4632 }
4634 } 4633 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698