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

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: Rebaseline 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
« no previous file with comments | « src/sampler.h ('k') | test/cctest/test-cpu-profiler.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 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 ThreadId profiled_thread_id_; 167 ThreadId profiled_thread_id_;
168 }; 168 };
169 169
170 } // namespace 170 } // namespace
171 171
172 #if defined(USE_SIGNALS) 172 #if defined(USE_SIGNALS)
173 173
174 class Sampler::PlatformData : public PlatformDataCommon { 174 class Sampler::PlatformData : public PlatformDataCommon {
175 public: 175 public:
176 PlatformData() : vm_tid_(pthread_self()) {} 176 PlatformData() : vm_tid_(pthread_self()) {}
177 pthread_t vm_tid() const { return vm_tid_; } 177
178 void SendProfilingSignal() const;
178 179
179 private: 180 private:
180 pthread_t vm_tid_; 181 pthread_t vm_tid_;
181 }; 182 };
182 183
183 #elif defined(__MACH__) 184 #elif defined(__MACH__)
184 185
185 class Sampler::PlatformData : public PlatformDataCommon { 186 class Sampler::PlatformData : public PlatformDataCommon {
186 public: 187 public:
187 PlatformData() : profiled_thread_(mach_thread_self()) {} 188 PlatformData() : profiled_thread_(mach_thread_self()) {}
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 486 }
486 } 487 }
487 OS::Sleep(interval_); 488 OS::Sleep(interval_);
488 } 489 }
489 } 490 }
490 491
491 private: 492 private:
492 #if defined(USE_SIGNALS) 493 #if defined(USE_SIGNALS)
493 494
494 void SampleContext(Sampler* sampler) { 495 void SampleContext(Sampler* sampler) {
495 if (!SignalHandler::Installed()) return; 496 sampler->platform_data()->SendProfilingSignal();
496 pthread_t tid = sampler->platform_data()->vm_tid();
497 pthread_kill(tid, SIGPROF);
498 } 497 }
499 498
500 #elif defined(__MACH__) 499 #elif defined(__MACH__)
501 500
502 void SampleContext(Sampler* sampler) { 501 void SampleContext(Sampler* sampler) {
503 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); 502 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread();
504 503
505 #if defined(USE_SIMULATOR) 504 #if defined(USE_SIMULATOR)
506 SimulatorHelper helper; 505 SimulatorHelper helper;
507 Isolate* isolate = sampler->isolate(); 506 Isolate* isolate = sampler->isolate();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 List<Sampler*> active_samplers_; 599 List<Sampler*> active_samplers_;
601 600
602 DISALLOW_COPY_AND_ASSIGN(SamplerThread); 601 DISALLOW_COPY_AND_ASSIGN(SamplerThread);
603 }; 602 };
604 603
605 604
606 Mutex* SamplerThread::mutex_ = NULL; 605 Mutex* SamplerThread::mutex_ = NULL;
607 SamplerThread* SamplerThread::instance_ = NULL; 606 SamplerThread* SamplerThread::instance_ = NULL;
608 607
609 608
609 #if defined(USE_SIGNALS)
610 void Sampler::PlatformData::SendProfilingSignal() const {
611 if (!SignalHandler::Installed()) return;
612 pthread_kill(vm_tid_, SIGPROF);
613 }
614 #endif
615
616
610 // 617 //
611 // StackTracer implementation 618 // StackTracer implementation
612 // 619 //
613 DISABLE_ASAN void TickSample::Init(Isolate* isolate, 620 DISABLE_ASAN void TickSample::Init(Isolate* isolate,
614 const RegisterState& regs) { 621 const RegisterState& regs) {
615 ASSERT(isolate->IsInitialized()); 622 ASSERT(isolate->IsInitialized());
616 pc = regs.pc; 623 pc = regs.pc;
617 state = isolate->current_vm_state(); 624 state = isolate->current_vm_state();
618 625
619 // Avoid collecting traces while doing GC. 626 // Avoid collecting traces while doing GC.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 665
659 void Sampler::TearDown() { 666 void Sampler::TearDown() {
660 SamplerThread::TearDown(); 667 SamplerThread::TearDown();
661 } 668 }
662 669
663 670
664 Sampler::Sampler(Isolate* isolate, int interval) 671 Sampler::Sampler(Isolate* isolate, int interval)
665 : isolate_(isolate), 672 : isolate_(isolate),
666 interval_(interval), 673 interval_(interval),
667 profiling_(false), 674 profiling_(false),
675 has_processing_thread_(false),
668 active_(false), 676 active_(false),
669 is_counting_samples_(false), 677 is_counting_samples_(false),
670 js_and_external_sample_count_(0) { 678 js_and_external_sample_count_(0) {
671 data_ = new PlatformData; 679 data_ = new PlatformData;
672 } 680 }
673 681
674 682
675 Sampler::~Sampler() { 683 Sampler::~Sampler() {
676 ASSERT(!IsActive()); 684 ASSERT(!IsActive());
677 delete data_; 685 delete data_;
(...skipping 20 matching lines...) Expand all
698 if (sample == NULL) sample = &sample_obj; 706 if (sample == NULL) sample = &sample_obj;
699 sample->Init(isolate_, state); 707 sample->Init(isolate_, state);
700 if (is_counting_samples_) { 708 if (is_counting_samples_) {
701 if (sample->state == JS || sample->state == EXTERNAL) { 709 if (sample->state == JS || sample->state == EXTERNAL) {
702 ++js_and_external_sample_count_; 710 ++js_and_external_sample_count_;
703 } 711 }
704 } 712 }
705 Tick(sample); 713 Tick(sample);
706 } 714 }
707 715
716
717 bool Sampler::CanSampleOnProfilerEventsProcessorThread() {
718 #if defined(USE_SIGNALS)
719 return true;
720 #else
721 return false;
722 #endif
723 }
724
725
726 void Sampler::DoSample() {
727 #if defined(USE_SIGNALS)
728 platform_data()->SendProfilingSignal();
729 #endif
730 }
731
708 } } // namespace v8::internal 732 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « 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