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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/thread_load_tracker.h

Issue 2391593002: [scheduler] Change ThreadLoadTracker to use only recent data. (Closed)
Patch Set: Simplified Created 4 years, 2 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRAC KER_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRAC KER_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRAC KER_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_TRAC KER_H_
7 7
8 #include <queue>
alex clarke (OOO till 29th) 2016/10/05 15:25:23 Looks like this is no longer used.
altimin 2016/10/05 16:26:56 Done.
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "base/time/time.h" 12 #include "base/time/time.h"
11 #include "public/platform/WebCommon.h" 13 #include "public/platform/WebCommon.h"
12 14
13 namespace blink { 15 namespace blink {
14 namespace scheduler { 16 namespace scheduler {
15 17
16 // This class tracks thread load level, i.e. percentage of wall time spent 18 // This class tracks thread load level, i.e. percentage of wall time spent
17 // running tasks. 19 // running tasks.
18 // In order to avoid bias it reports load level at regular intervals. 20 // In order to avoid bias it reports load level at regular intervals.
21 // It reports every |reporting_interval_| average thread load level in
alex clarke (OOO till 29th) 2016/10/05 15:25:23 Every |reporting_interval_| time units, it reports
altimin 2016/10/05 16:26:56 Done.
22 // sliding window of |reporting_interval_| width.
19 class BLINK_PLATFORM_EXPORT ThreadLoadTracker { 23 class BLINK_PLATFORM_EXPORT ThreadLoadTracker {
20 public: 24 public:
21 // Callback is called with (current_time, load_level) parameters. 25 // Callback is called with (current_time, load_level) parameters.
22 using Callback = base::Callback<void(base::TimeTicks, double)>; 26 using Callback = base::Callback<void(base::TimeTicks, double)>;
23 27
24 ThreadLoadTracker(base::TimeTicks now, const Callback& callback); 28 ThreadLoadTracker(base::TimeTicks now, const Callback& callback);
25 ~ThreadLoadTracker(); 29 ~ThreadLoadTracker();
26 30
27 void Pause(base::TimeTicks now); 31 void Pause(base::TimeTicks now);
28 void Resume(base::TimeTicks now); 32 void Resume(base::TimeTicks now);
(...skipping 11 matching lines...) Expand all
40 44
41 // This function advances |time_| to |now|, calling |callback_| 45 // This function advances |time_| to |now|, calling |callback_|
42 // in the process (multiple times if needed). 46 // in the process (multiple times if needed).
43 void Advance(base::TimeTicks now, TaskState task_state); 47 void Advance(base::TimeTicks now, TaskState task_state);
44 48
45 double Load(); 49 double Load();
46 50
47 // |time_| is the last timestamp LoadTracker knows about. 51 // |time_| is the last timestamp LoadTracker knows about.
48 base::TimeTicks time_; 52 base::TimeTicks time_;
49 base::TimeTicks next_reporting_time_; 53 base::TimeTicks next_reporting_time_;
54 // Total period for which this LoadTracker was active. Needed to discard
55 // first |waiting_period_| time.
56 base::TimeDelta recorded_time_;
Sami 2016/10/05 15:28:13 Would |active_time_| or maybe |total_active_time_|
altimin 2016/10/05 16:26:56 Done.
50 57
51 ThreadState thread_state_; 58 ThreadState thread_state_;
52 base::TimeTicks last_state_change_time_; 59 base::TimeTicks last_state_change_time_;
53 60
54 base::TimeDelta total_time_;
55 base::TimeDelta total_runtime_;
56
57 // Start reporting values after |waiting_period_|. 61 // Start reporting values after |waiting_period_|.
58 base::TimeDelta waiting_period_; 62 base::TimeDelta waiting_period_;
59 base::TimeDelta reporting_interval_; 63 base::TimeDelta reporting_interval_;
60 64
65 // Recorded run time in bucket
Sami 2016/10/05 15:28:13 s/bucket/window./? (Just wanted to avoid mixing th
altimin 2016/10/05 16:26:56 Done.
66 // [next_reporting_time - reporting_interval, next_reporting_time].
67 base::TimeDelta run_time_inside_window_;
68
61 Callback callback_; 69 Callback callback_;
62 70
63 DISALLOW_COPY_AND_ASSIGN(ThreadLoadTracker); 71 DISALLOW_COPY_AND_ASSIGN(ThreadLoadTracker);
64 }; 72 };
65 73
66 } // namespace scheduler 74 } // namespace scheduler
67 } // namespace blink 75 } // namespace blink
68 76
69 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_T RACKER_H_ 77 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_RENDERER_LOAD_T RACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698