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

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

Issue 1820013002: Remember thread's task when sampling use it when filtering (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/profiler_test.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 "vm/profiler_service.h" 5 #include "vm/profiler_service.h"
6 6
7 #include "vm/growable_array.h" 7 #include "vm/growable_array.h"
8 #include "vm/log.h" 8 #include "vm/log.h"
9 #include "vm/native_symbol.h" 9 #include "vm/native_symbol.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 2479 matching lines...) Expand 10 before | Expand all | Expand 10 after
2490 } else { 2490 } else {
2491 profile.PrintProfileJSON(stream); 2491 profile.PrintProfileJSON(stream);
2492 } 2492 }
2493 } 2493 }
2494 } 2494 }
2495 2495
2496 2496
2497 class NoAllocationSampleFilter : public SampleFilter { 2497 class NoAllocationSampleFilter : public SampleFilter {
2498 public: 2498 public:
2499 NoAllocationSampleFilter(Isolate* isolate, 2499 NoAllocationSampleFilter(Isolate* isolate,
2500 bool include_background_samples, 2500 intptr_t thread_task_mask,
2501 int64_t time_origin_micros, 2501 int64_t time_origin_micros,
2502 int64_t time_extent_micros) 2502 int64_t time_extent_micros)
2503 : SampleFilter(isolate, 2503 : SampleFilter(isolate,
2504 thread_task_mask,
2504 time_origin_micros, 2505 time_origin_micros,
2505 time_extent_micros), 2506 time_extent_micros) {
2506 include_background_samples_(include_background_samples) {
2507 } 2507 }
2508 2508
2509 bool FilterSample(Sample* sample) { 2509 bool FilterSample(Sample* sample) {
2510 if (sample->is_allocation_sample()) { 2510 if (sample->is_allocation_sample()) {
rmacnak 2016/03/21 21:10:52 return !sample->is_allocation_sample()
Cutch 2016/03/22 15:42:27 Done.
2511 return false; 2511 return false;
2512 } 2512 }
2513 return sample->is_mutator_thread() || include_background_samples_; 2513 return true;
2514 } 2514 }
2515
2516 private:
2517 const bool include_background_samples_;
2518 }; 2515 };
2519 2516
2520 2517
2521 void ProfilerService::PrintJSON(JSONStream* stream, 2518 void ProfilerService::PrintJSON(JSONStream* stream,
2522 Profile::TagOrder tag_order, 2519 Profile::TagOrder tag_order,
2523 intptr_t extra_tags, 2520 intptr_t extra_tags,
2524 int64_t time_origin_micros, 2521 int64_t time_origin_micros,
2525 int64_t time_extent_micros) { 2522 int64_t time_extent_micros) {
2526 Thread* thread = Thread::Current(); 2523 Thread* thread = Thread::Current();
2527 Isolate* isolate = thread->isolate(); 2524 Isolate* isolate = thread->isolate();
2528 const bool include_background_samples = false;
2529 NoAllocationSampleFilter filter(isolate, 2525 NoAllocationSampleFilter filter(isolate,
2530 include_background_samples, 2526 Thread::kMutatorTask,
2531 time_origin_micros, 2527 time_origin_micros,
2532 time_extent_micros); 2528 time_extent_micros);
2533 const bool as_timeline = false; 2529 const bool as_timeline = false;
2534 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline); 2530 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline);
2535 } 2531 }
2536 2532
2537 2533
2538 class ClassAllocationSampleFilter : public SampleFilter { 2534 class ClassAllocationSampleFilter : public SampleFilter {
2539 public: 2535 public:
2540 ClassAllocationSampleFilter(Isolate* isolate, 2536 ClassAllocationSampleFilter(Isolate* isolate,
2541 const Class& cls, 2537 const Class& cls,
2538 intptr_t thread_task_mask,
2542 int64_t time_origin_micros, 2539 int64_t time_origin_micros,
2543 int64_t time_extent_micros) 2540 int64_t time_extent_micros)
2544 : SampleFilter(isolate, 2541 : SampleFilter(isolate,
2542 thread_task_mask,
2545 time_origin_micros, 2543 time_origin_micros,
2546 time_extent_micros), 2544 time_extent_micros),
2547 cls_(Class::Handle(cls.raw())) { 2545 cls_(Class::Handle(cls.raw())) {
2548 ASSERT(!cls_.IsNull()); 2546 ASSERT(!cls_.IsNull());
2549 } 2547 }
2550 2548
2551 bool FilterSample(Sample* sample) { 2549 bool FilterSample(Sample* sample) {
2552 return sample->is_allocation_sample() && 2550 return sample->is_allocation_sample() &&
2553 (sample->allocation_cid() == cls_.id()); 2551 (sample->allocation_cid() == cls_.id());
2554 } 2552 }
2555 2553
2556 private: 2554 private:
2557 const Class& cls_; 2555 const Class& cls_;
2558 }; 2556 };
2559 2557
2560 2558
2561 void ProfilerService::PrintAllocationJSON(JSONStream* stream, 2559 void ProfilerService::PrintAllocationJSON(JSONStream* stream,
2562 Profile::TagOrder tag_order, 2560 Profile::TagOrder tag_order,
2563 const Class& cls, 2561 const Class& cls,
2564 int64_t time_origin_micros, 2562 int64_t time_origin_micros,
2565 int64_t time_extent_micros) { 2563 int64_t time_extent_micros) {
2566 Thread* thread = Thread::Current(); 2564 Thread* thread = Thread::Current();
2567 Isolate* isolate = thread->isolate(); 2565 Isolate* isolate = thread->isolate();
2568 ClassAllocationSampleFilter filter(isolate, 2566 ClassAllocationSampleFilter filter(isolate,
2569 cls, 2567 cls,
2568 Thread::kMutatorTask,
2570 time_origin_micros, 2569 time_origin_micros,
2571 time_extent_micros); 2570 time_extent_micros);
2572 const bool as_timeline = false; 2571 const bool as_timeline = false;
2573 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); 2572 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
2574 } 2573 }
2575 2574
2576 2575
2577 void ProfilerService::PrintTimelineJSON(JSONStream* stream, 2576 void ProfilerService::PrintTimelineJSON(JSONStream* stream,
2578 Profile::TagOrder tag_order, 2577 Profile::TagOrder tag_order,
2579 int64_t time_origin_micros, 2578 int64_t time_origin_micros,
2580 int64_t time_extent_micros) { 2579 int64_t time_extent_micros) {
2581 Thread* thread = Thread::Current(); 2580 Thread* thread = Thread::Current();
2582 Isolate* isolate = thread->isolate(); 2581 Isolate* isolate = thread->isolate();
2583 const bool include_background_samples = true; 2582 const intptr_t thread_task_mask = Thread::kMutatorTask |
2583 Thread::kCompilerTask |
2584 Thread::kSweeperTask |
2585 Thread::kMarkerTask;
2584 NoAllocationSampleFilter filter(isolate, 2586 NoAllocationSampleFilter filter(isolate,
2585 include_background_samples, 2587 thread_task_mask,
2586 time_origin_micros, 2588 time_origin_micros,
2587 time_extent_micros); 2589 time_extent_micros);
2588 const bool as_timeline = true; 2590 const bool as_timeline = true;
2589 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); 2591 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline);
2590 } 2592 }
2591 2593
2592 2594
2593 void ProfilerService::ClearSamples() { 2595 void ProfilerService::ClearSamples() {
2594 SampleBuffer* sample_buffer = Profiler::sample_buffer(); 2596 SampleBuffer* sample_buffer = Profiler::sample_buffer();
2595 if (sample_buffer == NULL) { 2597 if (sample_buffer == NULL) {
2596 return; 2598 return;
2597 } 2599 }
2598 2600
2599 Thread* thread = Thread::Current(); 2601 Thread* thread = Thread::Current();
2600 Isolate* isolate = thread->isolate(); 2602 Isolate* isolate = thread->isolate();
2601 2603
2602 // Disable thread interrupts while processing the buffer. 2604 // Disable thread interrupts while processing the buffer.
2603 DisableThreadInterruptsScope dtis(thread); 2605 DisableThreadInterruptsScope dtis(thread);
2604 2606
2605 ClearProfileVisitor clear_profile(isolate); 2607 ClearProfileVisitor clear_profile(isolate);
2606 sample_buffer->VisitSamples(&clear_profile); 2608 sample_buffer->VisitSamples(&clear_profile);
2607 } 2609 }
2608 2610
2609 #endif // !PRODUCT 2611 #endif // !PRODUCT
2610 2612
2611 } // namespace dart 2613 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/profiler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698