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

Side by Side Diff: src/runtime-profiler.cc

Issue 6826026: Fix JS ratio computation on startup. (Closed)
Patch Set: Created 9 years, 8 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
« no previous file with comments | « src/runtime-profiler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 RuntimeProfiler::RuntimeProfiler(Isolate* isolate) 124 RuntimeProfiler::RuntimeProfiler(Isolate* isolate)
125 : isolate_(isolate), 125 : isolate_(isolate),
126 sampler_threshold_(kSamplerThresholdInit), 126 sampler_threshold_(kSamplerThresholdInit),
127 sampler_threshold_size_factor_(kSamplerThresholdSizeFactorInit), 127 sampler_threshold_size_factor_(kSamplerThresholdSizeFactorInit),
128 sampler_ticks_until_threshold_adjustment_( 128 sampler_ticks_until_threshold_adjustment_(
129 kSamplerTicksBetweenThresholdAdjustment), 129 kSamplerTicksBetweenThresholdAdjustment),
130 js_ratio_(0), 130 js_ratio_(0),
131 sampler_window_position_(0), 131 sampler_window_position_(0),
132 optimize_soon_list_(NULL), 132 optimize_soon_list_(NULL),
133 state_window_position_(0) { 133 state_window_position_(0),
134 state_counts_[0] = kStateWindowSize; 134 state_window_ticks_(0) {
135 state_counts_[1] = 0; 135 state_counts_[IN_NON_JS_STATE] = kStateWindowSize;
Vyacheslav Egorov (Chromium) 2011/04/09 17:00:21 Wild idea: when going idle we stop profiler. Why d
Vitaly Repeshko 2011/04/10 08:13:27 I agree. As we discussed, we should revisit the he
Kasper Lund 2011/04/11 06:10:06 Before this change, we were intentionally being le
Vitaly Repeshko 2011/04/11 19:43:53 The slow start is still here, because even if we o
136 state_counts_[IN_JS_STATE] = 0;
137 STATIC_ASSERT(IN_NON_JS_STATE == 0);
136 memset(state_window_, 0, sizeof(state_window_)); 138 memset(state_window_, 0, sizeof(state_window_));
137 ClearSampleBuffer(); 139 ClearSampleBuffer();
138 } 140 }
139 141
140 142
141 bool RuntimeProfiler::IsEnabled() { 143 bool RuntimeProfiler::IsEnabled() {
142 return V8::UseCrankshaft() && FLAG_opt; 144 return V8::UseCrankshaft() && FLAG_opt;
143 } 145 }
144 146
145 147
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 339
338 #ifdef ENABLE_LOGGING_AND_PROFILING 340 #ifdef ENABLE_LOGGING_AND_PROFILING
339 void RuntimeProfiler::UpdateStateRatio(SamplerState current_state) { 341 void RuntimeProfiler::UpdateStateRatio(SamplerState current_state) {
340 SamplerState old_state = state_window_[state_window_position_]; 342 SamplerState old_state = state_window_[state_window_position_];
341 state_counts_[old_state]--; 343 state_counts_[old_state]--;
342 state_window_[state_window_position_] = current_state; 344 state_window_[state_window_position_] = current_state;
343 state_counts_[current_state]++; 345 state_counts_[current_state]++;
344 ASSERT(IsPowerOf2(kStateWindowSize)); 346 ASSERT(IsPowerOf2(kStateWindowSize));
345 state_window_position_ = (state_window_position_ + 1) & 347 state_window_position_ = (state_window_position_ + 1) &
346 (kStateWindowSize - 1); 348 (kStateWindowSize - 1);
349 state_window_ticks_ = Min(kStateWindowSize, state_window_ticks_ + 1);
Vyacheslav Egorov (Chromium) 2011/04/09 17:00:21 Our RuntimeProfiler is full of magic and very hard
Vitaly Repeshko 2011/04/10 08:13:27 It's not too late to make it readable :) Added a c
347 NoBarrier_Store(&js_ratio_, state_counts_[IN_JS_STATE] * 100 / 350 NoBarrier_Store(&js_ratio_, state_counts_[IN_JS_STATE] * 100 /
348 kStateWindowSize); 351 state_window_ticks_);
349 } 352 }
350 #endif 353 #endif
351 354
352 355
353 void RuntimeProfiler::NotifyTick() { 356 void RuntimeProfiler::NotifyTick() {
354 #ifdef ENABLE_LOGGING_AND_PROFILING 357 #ifdef ENABLE_LOGGING_AND_PROFILING
355 // Record state sample. 358 // Record state sample.
356 SamplerState state = IsSomeIsolateInJS() 359 SamplerState state = IsSomeIsolateInJS()
357 ? IN_JS_STATE 360 ? IN_JS_STATE
358 : IN_NON_JS_STATE; 361 : IN_NON_JS_STATE;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } else { 472 } else {
470 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); 473 return RuntimeProfiler::WaitForSomeIsolateToEnterJS();
471 } 474 }
472 } 475 }
473 #endif 476 #endif
474 return false; 477 return false;
475 } 478 }
476 479
477 480
478 } } // namespace v8::internal 481 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime-profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698