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

Side by Side Diff: src/sampler.cc

Issue 21101002: Support higher CPU profiler sampling rate on posix systems (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 ThreadId profiled_thread_id_; 162 ThreadId profiled_thread_id_;
163 }; 163 };
164 164
165 } // namespace 165 } // namespace
166 166
167 #if defined(USE_SIGNALS) 167 #if defined(USE_SIGNALS)
168 168
169 class Sampler::PlatformData : public PlatformDataCommon { 169 class Sampler::PlatformData : public PlatformDataCommon {
170 public: 170 public:
171 PlatformData() : vm_tid_(pthread_self()) {} 171 PlatformData() : vm_tid_(pthread_self()) {}
172 pthread_t vm_tid() const { return vm_tid_; } 172
173 void SendProfilingSignal() const;
173 174
174 private: 175 private:
175 pthread_t vm_tid_; 176 pthread_t vm_tid_;
176 }; 177 };
177 178
178 #elif V8_OS_DARWIN 179 #elif V8_OS_DARWIN
179 180
180 class Sampler::PlatformData : public PlatformDataCommon { 181 class Sampler::PlatformData : public PlatformDataCommon {
181 public: 182 public:
182 PlatformData() : profiled_thread_(mach_thread_self()) {} 183 PlatformData() : profiled_thread_(mach_thread_self()) {}
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 480 }
480 } 481 }
481 OS::Sleep(interval_); 482 OS::Sleep(interval_);
482 } 483 }
483 } 484 }
484 485
485 private: 486 private:
486 #if defined(USE_SIGNALS) 487 #if defined(USE_SIGNALS)
487 488
488 void SampleContext(Sampler* sampler) { 489 void SampleContext(Sampler* sampler) {
489 if (!SignalHandler::Installed()) return; 490 sampler->platform_data()->SendProfilingSignal();
490 pthread_t tid = sampler->platform_data()->vm_tid();
491 pthread_kill(tid, SIGPROF);
492 } 491 }
493 492
494 #elif V8_OS_DARWIN 493 #elif V8_OS_DARWIN
495 494
496 void SampleContext(Sampler* sampler) { 495 void SampleContext(Sampler* sampler) {
497 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); 496 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread();
498 497
499 #if defined(USE_SIMULATOR) 498 #if defined(USE_SIMULATOR)
500 SimulatorHelper helper; 499 SimulatorHelper helper;
501 Isolate* isolate = sampler->isolate(); 500 Isolate* isolate = sampler->isolate();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 List<Sampler*> active_samplers_; 593 List<Sampler*> active_samplers_;
595 594
596 DISALLOW_COPY_AND_ASSIGN(SamplerThread); 595 DISALLOW_COPY_AND_ASSIGN(SamplerThread);
597 }; 596 };
598 597
599 598
600 Mutex* SamplerThread::mutex_ = NULL; 599 Mutex* SamplerThread::mutex_ = NULL;
601 SamplerThread* SamplerThread::instance_ = NULL; 600 SamplerThread* SamplerThread::instance_ = NULL;
602 601
603 602
603 #if defined(USE_SIGNALS)
604 void Sampler::PlatformData::SendProfilingSignal() const {
605 if (!SignalHandler::Installed()) return;
606 pthread_kill(vm_tid_, SIGPROF);
607 }
608 #endif
609
610
604 // 611 //
605 // StackTracer implementation 612 // StackTracer implementation
606 // 613 //
607 DISABLE_ASAN void TickSample::Init(Isolate* isolate, 614 DISABLE_ASAN void TickSample::Init(Isolate* isolate,
608 const RegisterState& regs) { 615 const RegisterState& regs) {
609 ASSERT(isolate->IsInitialized()); 616 ASSERT(isolate->IsInitialized());
610 pc = regs.pc; 617 pc = regs.pc;
611 state = isolate->current_vm_state(); 618 state = isolate->current_vm_state();
612 619
613 // Avoid collecting traces while doing GC. 620 // Avoid collecting traces while doing GC.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 660
654 void Sampler::TearDown() { 661 void Sampler::TearDown() {
655 SamplerThread::TearDown(); 662 SamplerThread::TearDown();
656 } 663 }
657 664
658 665
659 Sampler::Sampler(Isolate* isolate, int interval) 666 Sampler::Sampler(Isolate* isolate, int interval)
660 : isolate_(isolate), 667 : isolate_(isolate),
661 interval_(interval), 668 interval_(interval),
662 profiling_(false), 669 profiling_(false),
670 has_processing_thread_(false),
663 active_(false), 671 active_(false),
664 is_counting_samples_(false), 672 is_counting_samples_(false),
665 js_and_external_sample_count_(0) { 673 js_and_external_sample_count_(0) {
666 data_ = new PlatformData; 674 data_ = new PlatformData;
667 } 675 }
668 676
669 677
670 Sampler::~Sampler() { 678 Sampler::~Sampler() {
671 ASSERT(!IsActive()); 679 ASSERT(!IsActive());
672 delete data_; 680 delete data_;
(...skipping 20 matching lines...) Expand all
693 if (sample == NULL) sample = &sample_obj; 701 if (sample == NULL) sample = &sample_obj;
694 sample->Init(isolate_, state); 702 sample->Init(isolate_, state);
695 if (is_counting_samples_) { 703 if (is_counting_samples_) {
696 if (sample->state == JS || sample->state == EXTERNAL) { 704 if (sample->state == JS || sample->state == EXTERNAL) {
697 ++js_and_external_sample_count_; 705 ++js_and_external_sample_count_;
698 } 706 }
699 } 707 }
700 Tick(sample); 708 Tick(sample);
701 } 709 }
702 710
711
712 bool Sampler::CanSampleOnProfilerEventsProcessorThread() {
713 #if defined(USE_SIGNALS)
714 return true;
715 #else
716 return false;
717 #endif
718 }
719
720
721 void Sampler::DoSample() {
722 platform_data()->SendProfilingSignal();
723 }
724
703 } } // namespace v8::internal 725 } } // namespace v8::internal
OLDNEW
« src/cpu-profiler.cc ('K') | « src/sampler.h ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698