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

Side by Side Diff: runtime/vm/thread_test.cc

Issue 2608463002: Added isolate + thread high watermark tracking to Observatory (Closed)
Patch Set: Added tracking of memory usage inside of threads. In addition, the max memory usage is kept track o… Created 3 years, 11 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
« no previous file with comments | « runtime/vm/thread_registry.cc ('k') | runtime/vm/zone.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/isolate.h" 6 #include "vm/isolate.h"
7 #include "vm/lockers.h" 7 #include "vm/lockers.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 #include "vm/profiler.h" 9 #include "vm/profiler.h"
10 #include "vm/safepoint.h" 10 #include "vm/safepoint.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 done_count = 0; 313 done_count = 0;
314 } 314 }
315 315
316 // Get the information for the current isolate. 316 // Get the information for the current isolate.
317 // We only need to check the current isolate since all tasks are spawned 317 // We only need to check the current isolate since all tasks are spawned
318 // inside this single isolate. 318 // inside this single isolate.
319 JSONStream stream; 319 JSONStream stream;
320 isolate->PrintJSON(&stream, false); 320 isolate->PrintJSON(&stream, false);
321 const char* json = stream.ToCString(); 321 const char* json = stream.ToCString();
322 322
323 Thread* current_thread = Thread::Current();
324 {
325 StackZone stack_zone(current_thread);
326 char* isolate_info_buf = OS::SCreate(current_thread->zone(),
327 "\"isolateMemoryHighWatermark\":"
328 "%" Pd "",
329 isolate->GetIsolateHighWatermark());
330 EXPECT_SUBSTRING(isolate_info_buf, json);
331 }
332
323 // Confirm all expected entries are in the JSON output. 333 // Confirm all expected entries are in the JSON output.
324 for (intptr_t i = 0; i < kTaskCount + 1; i++) { 334 for (intptr_t i = 0; i < kTaskCount + 1; i++) {
325 Thread* thread = threads[i]; 335 Thread* thread = threads[i];
326 Zone* top_zone = thread->zone(); 336 Zone* top_zone = thread->zone();
327 337
328 Thread* current_thread = Thread::Current();
329 StackZone stack_zone(current_thread); 338 StackZone stack_zone(current_thread);
330 Zone* current_zone = current_thread->zone(); 339 Zone* current_zone = current_thread->zone();
331 340
332 // Check that all zones are present with correct sizes. 341 // Check that all zones are present with correct sizes.
333 while (top_zone != NULL) { 342 while (top_zone != NULL) {
334 char* zone_info_buf = 343 char* zone_info_buf =
335 OS::SCreate(current_zone, 344 OS::SCreate(current_zone,
336 "\"type\":\"_Zone\"," 345 "\"type\":\"_Zone\","
337 "\"capacity\":%" Pd 346 "\"capacity\":%" Pd
338 "," 347 ","
339 "\"used\":%" Pd "", 348 "\"used\":%" Pd "",
340 top_zone->CapacityInBytes(), top_zone->SizeInBytes()); 349 top_zone->CapacityInBytes(), top_zone->SizeInBytes());
341 EXPECT_SUBSTRING(zone_info_buf, json); 350 EXPECT_SUBSTRING(zone_info_buf, json);
342 top_zone = top_zone->previous(); 351 top_zone = top_zone->previous();
343 } 352 }
344 353
345 // Check the thread exists and is the correct size. 354 // Check the thread exists and is the correct size.
346 char* thread_info_buf = 355 char* thread_info_buf =
347 OS::SCreate(current_zone, 356 OS::SCreate(current_zone,
348 "\"type\":\"_Thread\"," 357 "\"type\":\"_Thread\","
349 "\"id\":\"threads\\/%" Pd 358 "\"id\":\"threads\\/%" Pd
350 "\"," 359 "\","
351 "\"kind\":\"%s\"", 360 "\"kind\":\"%s\","
361 "\"threadMemoryHighWatermark\":%" Pd "",
352 OSThread::ThreadIdToIntPtr(thread->os_thread()->trace_id()), 362 OSThread::ThreadIdToIntPtr(thread->os_thread()->trace_id()),
353 Thread::TaskKindToCString(thread->task_kind())); 363 Thread::TaskKindToCString(thread->task_kind()),
364 thread->GetThreadHighWatermark());
354 365
355 EXPECT_SUBSTRING(thread_info_buf, json); 366 EXPECT_SUBSTRING(thread_info_buf, json);
356 } 367 }
357 368
358 // Unblock the tasks so they can finish. 369 // Unblock the tasks so they can finish.
359 { 370 {
360 MonitorLocker sync_ml(&sync); 371 MonitorLocker sync_ml(&sync);
361 wait = false; 372 wait = false;
362 sync_ml.NotifyAll(); 373 sync_ml.NotifyAll();
363 } 374 }
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 TransitionVMToBlocked transition(thread); 803 TransitionVMToBlocked transition(thread);
793 MonitorLocker ml(&done_monitor); 804 MonitorLocker ml(&done_monitor);
794 if (done) { 805 if (done) {
795 break; 806 break;
796 } 807 }
797 } 808 }
798 } 809 }
799 } 810 }
800 811
801 } // namespace dart 812 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/thread_registry.cc ('k') | runtime/vm/zone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698