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

Side by Side Diff: remoting/client/plugin/chromoting_instance.cc

Issue 1181743005: Report video and network stats averaged over 1s, and create corresponding UMA metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify metric names. Better document UMA min-max and boundary settings. Created 5 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "remoting/client/plugin/chromoting_instance.h" 5 #include "remoting/client/plugin/chromoting_instance.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #if defined(OS_NACL) 10 #if defined(OS_NACL)
(...skipping 14 matching lines...) Expand all
25 #include "base/threading/thread.h" 25 #include "base/threading/thread.h"
26 #include "base/values.h" 26 #include "base/values.h"
27 #include "crypto/random.h" 27 #include "crypto/random.h"
28 #include "jingle/glue/thread_wrapper.h" 28 #include "jingle/glue/thread_wrapper.h"
29 #include "media/base/yuv_convert.h" 29 #include "media/base/yuv_convert.h"
30 #include "net/socket/ssl_server_socket.h" 30 #include "net/socket/ssl_server_socket.h"
31 #include "ppapi/cpp/completion_callback.h" 31 #include "ppapi/cpp/completion_callback.h"
32 #include "ppapi/cpp/dev/url_util_dev.h" 32 #include "ppapi/cpp/dev/url_util_dev.h"
33 #include "ppapi/cpp/image_data.h" 33 #include "ppapi/cpp/image_data.h"
34 #include "ppapi/cpp/input_event.h" 34 #include "ppapi/cpp/input_event.h"
35 #include "ppapi/cpp/private/uma_private.h"
35 #include "ppapi/cpp/rect.h" 36 #include "ppapi/cpp/rect.h"
36 #include "ppapi/cpp/var_array_buffer.h" 37 #include "ppapi/cpp/var_array_buffer.h"
37 #include "ppapi/cpp/var_dictionary.h" 38 #include "ppapi/cpp/var_dictionary.h"
38 #include "remoting/base/constants.h" 39 #include "remoting/base/constants.h"
39 #include "remoting/base/util.h" 40 #include "remoting/base/util.h"
40 #include "remoting/client/chromoting_client.h" 41 #include "remoting/client/chromoting_client.h"
41 #include "remoting/client/plugin/delegating_signal_strategy.h" 42 #include "remoting/client/plugin/delegating_signal_strategy.h"
42 #include "remoting/client/plugin/normalizing_input_filter_cros.h" 43 #include "remoting/client/plugin/normalizing_input_filter_cros.h"
43 #include "remoting/client/plugin/normalizing_input_filter_mac.h" 44 #include "remoting/client/plugin/normalizing_input_filter_mac.h"
44 #include "remoting/client/plugin/pepper_audio_player.h" 45 #include "remoting/client/plugin/pepper_audio_player.h"
(...skipping 21 matching lines...) Expand all
66 67
67 // Default DPI to assume for old clients that use notifyClientResolution. 68 // Default DPI to assume for old clients that use notifyClientResolution.
68 const int kDefaultDPI = 96; 69 const int kDefaultDPI = 96;
69 70
70 // Interval at which to sample performance statistics. 71 // Interval at which to sample performance statistics.
71 const int kPerfStatsIntervalMs = 1000; 72 const int kPerfStatsIntervalMs = 1000;
72 73
73 // URL scheme used by Chrome apps and extensions. 74 // URL scheme used by Chrome apps and extensions.
74 const char kChromeExtensionUrlScheme[] = "chrome-extension"; 75 const char kChromeExtensionUrlScheme[] = "chrome-extension";
75 76
77 // The boundary value for the FPS histogram: we don't expect video frame-rate to
78 // be greater than 40fps.
79 // Histograms expect samples to be less than the boundary value, so set to 41.
80 const int kMaxFrameRate = 41;
81 // For bandwidth, we'll use a histogram ranging from 0 to 1MB/s, spread across
82 // 1000 buckets.
83 // Histograms are log-scaled by default. This results in fine-grained buckets at
84 // lower values and wider-ranged buckets closer to the maximum.
85 // Values above the maximum defined here end up in the right-most bucket.
86 // See $/src/base/metrics/histogram.h for more details.
87 const int kBandwidthHistogramMin = 1;
88 const int kBandwidthHistogramMax = 1024000;
89 const int kBandwidthHistogramNumBuckets = 1000;
90
91 // For the latency metrics, we'll set the max histogram value to 20,000ms, split
92 // over 1000 buckets.
93 const int kLatencyHistogramMin = 1;
94 const int kLatencyHistogramMax = 20000;
95 const int kLatencyHistogramNumBuckets = 1000;
96
76 #if defined(USE_OPENSSL) 97 #if defined(USE_OPENSSL)
77 // Size of the random seed blob used to initialize RNG in libjingle. Libjingle 98 // Size of the random seed blob used to initialize RNG in libjingle. Libjingle
78 // uses the seed only for OpenSSL builds. OpenSSL needs at least 32 bytes of 99 // uses the seed only for OpenSSL builds. OpenSSL needs at least 32 bytes of
79 // entropy (see http://wiki.openssl.org/index.php/Random_Numbers), but stores 100 // entropy (see http://wiki.openssl.org/index.php/Random_Numbers), but stores
80 // 1039 bytes of state, so we initialize it with 1k or random data. 101 // 1039 bytes of state, so we initialize it with 1k or random data.
81 const int kRandomSeedSize = 1024; 102 const int kRandomSeedSize = 1024;
82 #endif // defined(USE_OPENSSL) 103 #endif // defined(USE_OPENSSL)
83 104
84 std::string ConnectionStateToString(protocol::ConnectionToHost::State state) { 105 std::string ConnectionStateToString(protocol::ConnectionToHost::State state) {
85 // Values returned by this function must match the 106 // Values returned by this function must match the
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 void ChromotingInstance::SendPerfStats() { 1068 void ChromotingInstance::SendPerfStats() {
1048 if (!video_renderer_.get()) { 1069 if (!video_renderer_.get()) {
1049 return; 1070 return;
1050 } 1071 }
1051 1072
1052 plugin_task_runner_->PostDelayedTask( 1073 plugin_task_runner_->PostDelayedTask(
1053 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, 1074 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats,
1054 weak_factory_.GetWeakPtr()), 1075 weak_factory_.GetWeakPtr()),
1055 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); 1076 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
1056 1077
1078 // Update performance stats, averaged over the past few seconds.
1079 // These are eventually upstreamed to the web-app, and also available for
1080 // display to the user.
1057 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 1081 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
1058 ChromotingStats* stats = video_renderer_->GetStats(); 1082 ChromotingStats* stats = video_renderer_->GetStats();
1059 data->SetDouble("videoBandwidth", stats->video_bandwidth()->Rate()); 1083 data->SetDouble("videoBandwidth",
1060 data->SetDouble("videoFrameRate", stats->video_frame_rate()->Rate()); 1084 stats->video_Bps_webapp()->Rate());
1085 data->SetDouble("videoFrameRate", stats->video_fps_webapp()->Rate());
1061 data->SetDouble("captureLatency", stats->video_capture_ms()->Average()); 1086 data->SetDouble("captureLatency", stats->video_capture_ms()->Average());
1062 data->SetDouble("encodeLatency", stats->video_encode_ms()->Average()); 1087 data->SetDouble("encodeLatency", stats->video_encode_ms()->Average());
1063 data->SetDouble("decodeLatency", stats->video_decode_ms()->Average()); 1088 data->SetDouble("decodeLatency", stats->video_decode_ms()->Average());
1064 data->SetDouble("renderLatency", stats->video_paint_ms()->Average()); 1089 data->SetDouble("renderLatency", stats->video_paint_ms()->Average());
1065 data->SetDouble("roundtripLatency", stats->round_trip_ms()->Average()); 1090 data->SetDouble("roundtripLatency", stats->round_trip_ms()->Average());
1066 PostLegacyJsonMessage("onPerfStats", data.Pass()); 1091 PostLegacyJsonMessage("onPerfStats", data.Pass());
1092
1093 // Update UMA histograms for video frame-rate, bandwidth and latencies.
1094 // These metrics will be averaged over the last second.
1095 pp::UMAPrivate uma_interface(this);
1096 uma_interface.HistogramEnumeration(
1097 "Chromoting.Video.FrameRate", stats->video_Bps_UMA()->Rate(),
1098 kMaxFrameRate);
1099 uma_interface.HistogramEnumeration(
1100 "Chromoting.Video.FrameRate",
1101 stats->video_packets_per_s_UMA()->Rate(), kMaxFrameRate);
1102 uma_interface.HistogramCustomCounts("Chromoting.Video.Bandwidth",
1103 stats->video_Bps_UMA()->Rate(), kBandwidthHistogramMin,
1104 kBandwidthHistogramMax, kBandwidthHistogramNumBuckets);
1105 uma_interface.HistogramCustomTimes("Chromoting.Video.CaptureLatency",
1106 stats->video_capture_ms()->Average(), kLatencyHistogramMin,
1107 kLatencyHistogramMax, kLatencyHistogramNumBuckets);
1108 uma_interface.HistogramCustomTimes("Chromoting.Video.EncodeLatency",
1109 stats->video_encode_ms()->Average(), kLatencyHistogramMin,
1110 kLatencyHistogramMax, kLatencyHistogramNumBuckets);
1111 uma_interface.HistogramCustomTimes("Chromoting.Video.RoundTripLatency",
1112 stats->round_trip_ms()->Average(), kLatencyHistogramMin,
1113 kLatencyHistogramMax, kLatencyHistogramNumBuckets);
1067 } 1114 }
1068 1115
1069 // static 1116 // static
1070 void ChromotingInstance::RegisterLogMessageHandler() { 1117 void ChromotingInstance::RegisterLogMessageHandler() {
1071 base::AutoLock lock(g_logging_lock.Get()); 1118 base::AutoLock lock(g_logging_lock.Get());
1072 1119
1073 VLOG(1) << "Registering global log handler"; 1120 VLOG(1) << "Registering global log handler";
1074 1121
1075 // Record previous handler so we can call it in a chain. 1122 // Record previous handler so we can call it in a chain.
1076 g_logging_old_handler = logging::GetLogMessageHandler(); 1123 g_logging_old_handler = logging::GetLogMessageHandler();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 1243
1197 #if !defined(OS_NACL) 1244 #if !defined(OS_NACL)
1198 // Log messages are forwarded to the webapp only in PNaCl version of the 1245 // Log messages are forwarded to the webapp only in PNaCl version of the
1199 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl 1246 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl
1200 // version. 1247 // version.
1201 ProcessLogToUI(message); 1248 ProcessLogToUI(message);
1202 #endif // !defined(OS_NACL) 1249 #endif // !defined(OS_NACL)
1203 } 1250 }
1204 1251
1205 } // namespace remoting 1252 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698