Moved isolate high watermark calculations into the Observatory client.

BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2656723002 .
This commit is contained in:
Ben Konyi 2017-01-25 15:03:42 -08:00
parent f6f2ecfe69
commit de72bf4991
5 changed files with 7 additions and 42 deletions

View file

@ -1508,7 +1508,7 @@ class Isolate extends ServiceObjectOwner implements M.Isolate {
final List<Thread> _threads = new List<Thread>();
int get memoryHighWatermark => _memoryHighWatermark;
int _memoryHighWatermark;
int _memoryHighWatermark = 0;
int get numZoneHandles => _numZoneHandles;
int _numZoneHandles;
@ -1645,10 +1645,13 @@ class Isolate extends ServiceObjectOwner implements M.Isolate {
threads.addAll(map['_threads']);
}
_memoryHighWatermark = int.parse(map['_memoryHighWatermark']);
int currentMemoryHighWatermark = 0;
for (var i = 0; i < threads.length; i++) {
currentMemoryHighWatermark += threads[i].memoryHighWatermark;
}
if (map['threads'] != null) {
threads.addAll(map['threads']);
if (currentMemoryHighWatermark > _memoryHighWatermark) {
_memoryHighWatermark = currentMemoryHighWatermark;
}
_numZoneHandles = map['_numZoneHandles'];

View file

@ -783,7 +783,6 @@ Isolate::Isolate(const Dart_IsolateFlags& api_flags)
single_step_(false),
thread_registry_(new ThreadRegistry()),
safepoint_handler_(new SafepointHandler(this)),
memory_high_watermark_(0),
message_notify_callback_(NULL),
name_(NULL),
debugger_name_(NULL),
@ -2118,7 +2117,6 @@ void Isolate::PrintJSON(JSONStream* stream, bool ref) {
}
}
jsobj.AddPropertyF("_memoryHighWatermark", "%" Pu "", memory_high_watermark_);
jsobj.AddProperty("_threads", thread_registry_);
}
#endif
@ -2717,7 +2715,6 @@ void Isolate::UnscheduleThread(Thread* thread,
// Ensure that the thread reports itself as being at a safepoint.
thread->EnterSafepoint();
}
UpdateMemoryHighWatermark();
OSThread* os_thread = thread->os_thread();
ASSERT(os_thread != NULL);
os_thread->DisableThreadInterrupts();
@ -2738,15 +2735,6 @@ void Isolate::UnscheduleThread(Thread* thread,
}
void Isolate::UpdateMemoryHighWatermark() {
const uintptr_t thread_watermarks_total =
thread_registry()->ThreadHighWatermarksTotalLocked();
if (thread_watermarks_total > memory_high_watermark_) {
memory_high_watermark_ = thread_watermarks_total;
}
}
static RawInstance* DeserializeObject(Thread* thread,
uint8_t* obj_data,
intptr_t obj_len) {

View file

@ -179,7 +179,6 @@ class Isolate : public BaseIsolate {
ThreadRegistry* thread_registry() const { return thread_registry_; }
SafepointHandler* safepoint_handler() const { return safepoint_handler_; }
uintptr_t memory_high_watermark() const { return memory_high_watermark_; }
ClassTable* class_table() { return &class_table_; }
static intptr_t class_table_offset() {
return OFFSET_OF(Isolate, class_table_);
@ -692,10 +691,6 @@ class Isolate : public BaseIsolate {
bool is_mutator,
bool bypass_safepoint = false);
// Updates the maximum memory usage in bytes of all zones in all threads of
// the current isolate.
void UpdateMemoryHighWatermark();
// DEPRECATED: Use Thread's methods instead. During migration, these default
// to using the mutator thread (which must also be the current thread).
Zone* current_zone() const {
@ -716,7 +711,6 @@ class Isolate : public BaseIsolate {
ThreadRegistry* thread_registry_;
SafepointHandler* safepoint_handler_;
uintptr_t memory_high_watermark_;
Dart_MessageNotifyCallback message_notify_callback_;
char* name_;
char* debugger_name_;

View file

@ -195,16 +195,4 @@ void ThreadRegistry::ReturnToFreelistLocked(Thread* thread) {
free_list_ = thread;
}
uintptr_t ThreadRegistry::ThreadHighWatermarksTotalLocked() const {
ASSERT(threads_lock()->IsOwnedByCurrentThread());
uintptr_t memory_high_watermarks_total = 0;
Thread* current = active_list_;
while (current != NULL) {
memory_high_watermarks_total += current->memory_high_watermark();
current = current->next_;
}
return memory_high_watermarks_total;
}
} // namespace dart

View file

@ -321,14 +321,6 @@ TEST_CASE(ManySimpleTasksWithZones) {
const char* json = stream.ToCString();
Thread* current_thread = Thread::Current();
{
StackZone stack_zone(current_thread);
char* isolate_info_buf = OS::SCreate(current_thread->zone(),
"\"_memoryHighWatermark\":"
"\"%" Pu "\"",
isolate->memory_high_watermark());
EXPECT_SUBSTRING(isolate_info_buf, json);
}
// Confirm all expected entries are in the JSON output.
for (intptr_t i = 0; i < kTaskCount + 1; i++) {