Commit 138bcfc3 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cpu-profiler] Add more logging to find flaky failure

There is a flaky 5x failure in the tree which I can't reproduce locally.
This extra logging will help flush out what the problem is.

Bug: v8:8649

Change-Id: If36d2ce0f4feb398d7d746d69b417bb55a714422
Reviewed-on: https://chromium-review.googlesource.com/c/1402787
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58796}
parent b4a3af91
include_rules = [
"+include",
"-src",
"+src/flags.h",
"+src/base",
"+src/libsampler",
]
\ No newline at end of file
......@@ -63,6 +63,8 @@ typedef zx_arm64_general_regs_t zx_thread_state_general_regs_t;
#include "src/base/atomic-utils.h"
#include "src/base/hashmap.h"
#include "src/base/platform/platform.h"
// TODO(petermarshall): Remove when cpu profiler logging is no longer needed
#include "src/flags.h"
#if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T)
......@@ -391,6 +393,9 @@ class SignalHandler {
static void DecreaseSamplerCount() {
base::MutexGuard lock_guard(mutex_);
if (i::FLAG_cpu_profiler_logging) {
printf("SignalHandler DecreaseSamplerCount: signals: %d\n", signals_);
}
if (--client_count_ == 0) Restore();
}
......@@ -428,13 +433,14 @@ class SignalHandler {
static int client_count_;
static bool signal_handler_installed_;
static struct sigaction old_signal_handler_;
static int signals_;
};
base::Mutex* SignalHandler::mutex_ = nullptr;
int SignalHandler::client_count_ = 0;
struct sigaction SignalHandler::old_signal_handler_;
bool SignalHandler::signal_handler_installed_ = false;
int SignalHandler::signals_ = 0;
void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
void* context) {
......@@ -442,6 +448,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
if (signal != SIGPROF) return;
v8::RegisterState state;
FillRegisterState(context, &state);
signals_++;
SamplerManager::instance()->DoSample(state);
}
......@@ -627,6 +634,9 @@ void Sampler::UnregisterIfRegistered() {
Sampler::~Sampler() {
DCHECK(!IsActive());
DCHECK(!IsRegistered());
if (i::FLAG_cpu_profiler_logging) {
printf("~Sampler: samples = %d\n", samples_);
}
delete data_;
}
......@@ -668,6 +678,7 @@ void Sampler::DecreaseProfilingDepth() {
#if defined(USE_SIGNALS)
void Sampler::DoSample() {
samples_++;
if (!SignalHandler::Installed()) return;
if (!IsActive() && !IsRegistered()) {
SamplerManager::instance()->AddSampler(this);
......
......@@ -100,6 +100,7 @@ class Sampler {
base::Atomic32 active_;
base::Atomic32 registered_;
PlatformData* data_; // Platform specific data.
int samples_ = 0;
DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
};
......
......@@ -406,6 +406,9 @@ void CpuProfiler::StartProcessorIfNotStarted() {
CpuProfile* CpuProfiler::StopProfiling(const char* title) {
if (!is_profiling_) return nullptr;
if (i::FLAG_cpu_profiler_logging) {
PrintF("StopProfiling: samples = %d\n", generator_->samples_);
}
StopProcessorIfLastProfile(title);
return profiles_->StopProfiling(title);
}
......
......@@ -783,6 +783,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
if (FLAG_cpu_profiler_logging) {
PrintF("RecordTickSample: ");
sample.print();
samples_++;
}
if (sample.pc != nullptr) {
......
......@@ -463,10 +463,16 @@ class CpuProfilesCollection {
class ProfileGenerator {
public:
explicit ProfileGenerator(CpuProfilesCollection* profiles);
~ProfileGenerator() {
if (FLAG_cpu_profiler_logging) {
PrintF("~ProfileGenerator: samples = %d\n", samples_);
}
}
void RecordTickSample(const TickSample& sample);
CodeMap* code_map() { return &code_map_; }
int samples_ = 0;
private:
CodeEntry* FindEntry(Address address);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment