Revision: 7562 Author: [email protected] Date: Sun Apr 10 01:29:18 2011 Log: Fix JS ratio computation on startup.
Review URL: http://codereview.chromium.org/6826026 http://code.google.com/p/v8/source/detail?r=7562 Modified: /branches/bleeding_edge/src/runtime-profiler.cc /branches/bleeding_edge/src/runtime-profiler.h ======================================= --- /branches/bleeding_edge/src/runtime-profiler.cc Tue Apr 5 02:01:47 2011 +++ /branches/bleeding_edge/src/runtime-profiler.cc Sun Apr 10 01:29:18 2011 @@ -130,9 +130,11 @@ js_ratio_(0), sampler_window_position_(0), optimize_soon_list_(NULL), - state_window_position_(0) { - state_counts_[0] = kStateWindowSize; - state_counts_[1] = 0; + state_window_position_(0), + state_window_ticks_(0) { + state_counts_[IN_NON_JS_STATE] = kStateWindowSize; + state_counts_[IN_JS_STATE] = 0; + STATIC_ASSERT(IN_NON_JS_STATE == 0); memset(state_window_, 0, sizeof(state_window_)); ClearSampleBuffer(); } @@ -344,8 +346,12 @@ ASSERT(IsPowerOf2(kStateWindowSize)); state_window_position_ = (state_window_position_ + 1) & (kStateWindowSize - 1); + // Note: to calculate correct ratio we have to track how many valid + // ticks are actually in the state window, because on profiler + // startup this number can be less than the window size. + state_window_ticks_ = Min(kStateWindowSize, state_window_ticks_ + 1); NoBarrier_Store(&js_ratio_, state_counts_[IN_JS_STATE] * 100 / - kStateWindowSize); + state_window_ticks_); } #endif ======================================= --- /branches/bleeding_edge/src/runtime-profiler.h Fri Mar 18 13:35:07 2011 +++ /branches/bleeding_edge/src/runtime-profiler.h Sun Apr 10 01:29:18 2011 @@ -40,13 +40,6 @@ class PendingListNode; class Semaphore; - -enum SamplerState { - IN_NON_JS_STATE = 0, - IN_JS_STATE = 1 -}; - - class RuntimeProfiler { public: explicit RuntimeProfiler(Isolate* isolate); @@ -101,6 +94,11 @@ static const int kSamplerWindowSize = 16; static const int kStateWindowSize = 128; + enum SamplerState { + IN_NON_JS_STATE = 0, + IN_JS_STATE = 1 + }; + static void HandleWakeUp(Isolate* isolate); void Optimize(JSFunction* function, bool eager, int delay); @@ -137,6 +135,7 @@ SamplerState state_window_[kStateWindowSize]; int state_window_position_; + int state_window_ticks_; int state_counts_[2]; // Possible state values: -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
