Reduce the space used by the stack for the profiling thread.

Review URL: https://chromiumcodereview.appspot.com/9117032

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10490 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
erik.corry@gmail.com 2012-01-24 15:48:16 +00:00
parent 1a10995a9d
commit ee1d0fc5c6
11 changed files with 67 additions and 75 deletions

View File

@ -39,13 +39,14 @@
namespace v8 {
namespace internal {
static const int kEventsBufferSize = 256*KB;
static const int kTickSamplesBufferChunkSize = 64*KB;
static const int kEventsBufferSize = 256 * KB;
static const int kTickSamplesBufferChunkSize = 64 * KB;
static const int kTickSamplesBufferChunksCount = 16;
static const int kProfilerStackSize = 32 * KB;
ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator)
: Thread("v8:ProfEvntProc"),
: Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)),
generator_(generator),
running_(true),
ticks_buffer_(sizeof(TickSampleEventRecord),

View File

@ -120,6 +120,9 @@ ShellOptions Shell::options;
const char* Shell::kPrompt = "d8> ";
const int MB = 1024 * 1024;
#ifndef V8_SHARED
bool CounterMap::Match(void* key1, void* key2) {
const char* name1 = reinterpret_cast<const char*>(key1);
@ -1210,14 +1213,11 @@ Handle<String> SourceGroup::ReadFile(const char* name) {
#ifndef V8_SHARED
i::Thread::Options SourceGroup::GetThreadOptions() {
i::Thread::Options options;
options.name = "IsolateThread";
// On some systems (OSX 10.6) the stack size default is 0.5Mb or less
// which is not enough to parse the big literal expressions used in tests.
// The stack size should be at least StackGuard::kLimitSize + some
// OS-specific padding for thread startup code.
options.stack_size = 2 << 20; // 2 Mb seems to be enough
return options;
// OS-specific padding for thread startup code. 2Mbytes seems to be enough.
return i::Thread::Options("IsolateThread", 2 * MB);
}

View File

@ -505,7 +505,6 @@ Isolate* Heap::isolate() {
#define GC_GREEDY_CHECK() { }
#endif
// Calls the FUNCTION_CALL function and retries it up to three times
// to guarantee that any allocations performed during the call will
// succeed if there's enough memory.

View File

@ -464,15 +464,8 @@ class Thread::PlatformData : public Malloced {
Thread::Thread(const Options& options)
: data_(new PlatformData),
stack_size_(options.stack_size) {
set_name(options.name);
}
Thread::Thread(const char* name)
: data_(new PlatformData),
stack_size_(0) {
set_name(name);
stack_size_(options.stack_size()) {
set_name(options.name());
}
@ -717,8 +710,10 @@ class SignalSender : public Thread {
FULL_INTERVAL
};
static const int kSignalSenderStackSize = 32 * KB;
explicit SignalSender(int interval)
: Thread("SignalSender"),
: Thread(Thread::Options("SignalSender", kSignalSenderStackSize)),
interval_(interval) {}
static void AddActiveSampler(Sampler* sampler) {

View File

@ -720,15 +720,8 @@ class Thread::PlatformData : public Malloced {
Thread::Thread(const Options& options)
: data_(new PlatformData()),
stack_size_(options.stack_size) {
set_name(options.name);
}
Thread::Thread(const char* name)
: data_(new PlatformData()),
stack_size_(0) {
set_name(name);
stack_size_(options.stack_size()) {
set_name(options.name());
}
@ -1035,8 +1028,10 @@ class SignalSender : public Thread {
FULL_INTERVAL
};
static const int kSignalSenderStackSize = 32 * KB;
explicit SignalSender(int interval)
: Thread("SignalSender"),
: Thread(Thread::Options("SignalSender", kSignalSenderStackSize)),
vm_tgid_(getpid()),
interval_(interval) {}

View File

@ -473,17 +473,11 @@ class Thread::PlatformData : public Malloced {
pthread_t thread_; // Thread handle for pthread.
};
Thread::Thread(const Options& options)
: data_(new PlatformData),
stack_size_(options.stack_size) {
set_name(options.name);
}
Thread::Thread(const char* name)
: data_(new PlatformData),
stack_size_(0) {
set_name(name);
stack_size_(options.stack_size()) {
set_name(options.name());
}
@ -736,10 +730,13 @@ class Sampler::PlatformData : public Malloced {
thread_act_t profiled_thread_;
};
class SamplerThread : public Thread {
public:
static const int kSamplerThreadStackSize = 32 * KB;
explicit SamplerThread(int interval)
: Thread("SamplerThread"),
: Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
interval_(interval) {}
static void AddActiveSampler(Sampler* sampler) {

View File

@ -512,15 +512,8 @@ class Thread::PlatformData : public Malloced {
Thread::Thread(const Options& options)
: data_(new PlatformData()),
stack_size_(options.stack_size) {
set_name(options.name);
}
Thread::Thread(const char* name)
: data_(new PlatformData()),
stack_size_(0) {
set_name(name);
stack_size_(options.stack_size()) {
set_name(options.name());
}
@ -789,8 +782,10 @@ class SignalSender : public Thread {
FULL_INTERVAL
};
static const int kSignalSenderStackSize = 32 * KB;
explicit SignalSender(int interval)
: Thread("SignalSender"),
: Thread(Thread::Options("SignalSender", kSignalSenderStackSize)),
vm_tgid_(getpid()),
interval_(interval) {}

View File

@ -453,17 +453,11 @@ class Thread::PlatformData : public Malloced {
pthread_t thread_; // Thread handle for pthread.
};
Thread::Thread(const Options& options)
: data_(new PlatformData()),
stack_size_(options.stack_size) {
set_name(options.name);
}
Thread::Thread(const char* name)
: data_(new PlatformData()),
stack_size_(0) {
set_name(name);
stack_size_(options.stack_size()) {
set_name(options.name());
}
@ -710,8 +704,10 @@ class SignalSender : public Thread {
FULL_INTERVAL
};
static const int kSignalSenderStackSize = 32 * KB;
explicit SignalSender(int interval)
: Thread("SignalSender"),
: Thread(Thread::Options("SignalSender", kSignalSenderStackSize)),
interval_(interval) {}
static void InstallSignalHandler() {

View File

@ -1526,16 +1526,9 @@ class Thread::PlatformData : public Malloced {
// handle until it is started.
Thread::Thread(const Options& options)
: stack_size_(options.stack_size) {
: stack_size_(options.stack_size()) {
data_ = new PlatformData(kNoThread);
set_name(options.name);
}
Thread::Thread(const char* name)
: stack_size_(0) {
data_ = new PlatformData(kNoThread);
set_name(name);
set_name(options.name());
}
@ -1901,8 +1894,10 @@ class Sampler::PlatformData : public Malloced {
class SamplerThread : public Thread {
public:
static const int kSamplerThreadStackSize = 32 * KB;
explicit SamplerThread(int interval)
: Thread("SamplerThread"),
: Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
interval_(interval) {}
static void AddActiveSampler(Sampler* sampler) {

View File

@ -412,16 +412,22 @@ class Thread {
LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt
};
struct Options {
Options() : name("v8:<unknown>"), stack_size(0) {}
class Options {
public:
Options() : name_("v8:<unknown>"), stack_size_(0) {}
Options(const char* name, int stack_size = 0)
: name_(name), stack_size_(stack_size) {}
const char* name;
int stack_size;
const char* name() const { return name_; }
int stack_size() const { return stack_size_; }
private:
const char* name_;
int stack_size_;
};
// Create new thread.
explicit Thread(const Options& options);
explicit Thread(const char* name);
virtual ~Thread();
// Start new thread by calling the Run() method in the new thread.

View File

@ -526,12 +526,25 @@ static intptr_t MemoryInUse() {
TEST(BootUpMemoryUse) {
intptr_t initial_memory = MemoryInUse();
FLAG_crankshaft = false; // Avoid flakiness.
// Only Linux has the proc filesystem and only if it is mapped. If it's not
// there we just skip the test.
if (initial_memory >= 0) {
InitializeVM();
intptr_t booted_memory = MemoryInUse();
CHECK_LE(booted_memory - initial_memory, 16 * 1024 * 1024);
if (sizeof(initial_memory) == 8) {
if (v8::internal::Snapshot::IsEnabled()) {
CHECK_LE(booted_memory - initial_memory, 7654 * 1024); // 7468.
} else {
CHECK_LE(booted_memory - initial_memory, 7777 * 1024); // 7620.
}
} else {
if (v8::internal::Snapshot::IsEnabled()) {
CHECK_LE(booted_memory - initial_memory, 7500 * 1024); // 7380.
} else {
CHECK_LE(booted_memory - initial_memory, 7654 * 1024); // 7448
}
}
}
}