Commit b400464a authored by mtomasz's avatar mtomasz Committed by Commit bot

Add histograms about files copied or movied files from or to Drive.

This patch adds temporary histograms in order to investigate how to optimize
downloading and uploading multiple files.

NOTRY=true
TEST=Tested manually.
BUG=229650

Review URL: https://codereview.chromium.org/640543002

Cr-Commit-Position: refs/heads/master@{#299445}
parent c189d183
......@@ -4,7 +4,9 @@
#include "chrome/browser/chromeos/drive/job_scheduler.h"
#include "base/files/file_util.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
......@@ -133,6 +135,43 @@ google_apis::CancelCallback RunResumeUploadFile(
params.progress_callback);
}
// Collects information about sizes of files copied or moved from or to Drive
// Otherwise does nothing. Temporary for crbug.com/229650.
void CollectCopyHistogramSample(const std::string& histogram_name, int64 size) {
base::HistogramBase* const counter =
base::Histogram::FactoryGet(histogram_name,
1,
1024 * 1024 /* 1 GB */,
50,
base::Histogram::kUmaTargetedHistogramFlag);
counter->Add(size / 1024);
}
// Callback for GetSizeAndCollectCopyHistogramSample().
void OnGotSizeForCollectCopyHistogramSample(const std::string& histogram_name,
int64* size) {
if (*size != -1)
CollectCopyHistogramSample(histogram_name, *size);
}
// Collects information about sizes of files copied or moved from or to Drive
// Otherwise does nothing. Temporary for crbug.com/229650.
void GetSizeAndCollectCopyHistogramSample(
base::SequencedTaskRunner* blocking_task_runner,
const base::FilePath& local_file_path,
const std::string& histogram_name) {
int64* const size = new int64;
*size = -1;
blocking_task_runner->PostTaskAndReply(
FROM_HERE,
base::Bind(base::IgnoreResult(&base::GetFileSize),
local_file_path,
base::Unretained(size)),
base::Bind(&OnGotSizeForCollectCopyHistogramSample,
histogram_name,
base::Owned(size)));
}
} // namespace
// Metadata jobs are cheap, so we run them concurrently. File jobs run serially.
......@@ -158,16 +197,16 @@ struct JobScheduler::ResumeUploadParams {
std::string content_type;
};
JobScheduler::JobScheduler(
PrefService* pref_service,
EventLogger* logger,
DriveServiceInterface* drive_service,
base::SequencedTaskRunner* blocking_task_runner)
JobScheduler::JobScheduler(PrefService* pref_service,
EventLogger* logger,
DriveServiceInterface* drive_service,
base::SequencedTaskRunner* blocking_task_runner)
: throttle_count_(0),
wait_until_(base::Time::Now()),
disable_throttling_(false),
logger_(logger),
drive_service_(drive_service),
blocking_task_runner_(blocking_task_runner),
uploader_(new DriveUploader(drive_service, blocking_task_runner)),
pref_service_(pref_service),
weak_ptr_factory_(this) {
......@@ -574,6 +613,10 @@ JobID JobScheduler::DownloadFile(
const google_apis::GetContentCallback& get_content_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Temporary histogram for crbug.com/229650.
CollectCopyHistogramSample("Drive.DownloadFromDriveFileSize",
expected_file_size);
JobEntry* new_job = CreateNewJob(TYPE_DOWNLOAD_FILE);
new_job->job_info.file_path = virtual_path;
new_job->job_info.num_total_bytes = expected_file_size;
......@@ -607,6 +650,10 @@ void JobScheduler::UploadNewFile(
const google_apis::FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Temporary histogram for crbug.com/229650.
GetSizeAndCollectCopyHistogramSample(
blocking_task_runner_, local_file_path, "Drive.UploadToDriveFileSize");
JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_NEW_FILE);
new_job->job_info.file_path = drive_file_path;
new_job->context = context;
......@@ -645,6 +692,10 @@ void JobScheduler::UploadExistingFile(
const google_apis::FileResourceCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Temporary histogram for crbug.com/229650.
GetSizeAndCollectCopyHistogramSample(
blocking_task_runner_, local_file_path, "Drive.UploadToDriveFileSize");
JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_EXISTING_FILE);
new_job->job_info.file_path = drive_file_path;
new_job->context = context;
......@@ -718,6 +769,20 @@ void JobScheduler::QueueJob(JobID job_id) {
const QueueType queue_type = GetJobQueueType(job_info.job_type);
queue_[queue_type]->Push(job_id, job_entry->context.type);
// Temporary histogram for crbug.com/229650.
if (job_info.job_type == TYPE_DOWNLOAD_FILE ||
job_info.job_type == TYPE_UPLOAD_EXISTING_FILE ||
job_info.job_type == TYPE_UPLOAD_NEW_FILE) {
std::vector<JobID> jobs_with_the_same_priority;
queue_[queue_type]->GetQueuedJobs(job_entry->context.type,
&jobs_with_the_same_priority);
DCHECK(!jobs_with_the_same_priority.empty());
const size_t blocking_jobs_count = jobs_with_the_same_priority.size() - 1;
UMA_HISTOGRAM_COUNTS_10000("Drive.TransferBlockedOnJobs",
blocking_jobs_count);
}
const std::string retry_prefix = job_entry->retry_count > 0 ?
base::StringPrintf(" (retry %d)", job_entry->retry_count) : "";
logger_->Log(logging::LOG_INFO,
......
......@@ -388,6 +388,7 @@ class JobScheduler
EventLogger* logger_;
DriveServiceInterface* drive_service_;
base::SequencedTaskRunner* blocking_task_runner_;
scoped_ptr<DriveUploaderInterface> uploader_;
PrefService* pref_service_;
......
......@@ -5871,7 +5871,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<histogram name="Drive.CacheDBOpenStatus" enum="DriveCacheDBOpenStatus">
<obsolete>
Deperecated 8/2013.
Deprecated 8/2013.
</obsolete>
<owner>joshwoodward@google.com</owner>
<summary>Status of drive cache metadata database open.</summary>
......@@ -5885,6 +5885,14 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
<histogram name="Drive.DownloadFromDriveFileSize" units="KB">
<owner>mtomasz@chromium.org</owner>
<summary>
Sizes of files being downloaded from Drive. Temporary histogram for
gathering data for http://crbug.com/229650.
</summary>
</histogram>
<histogram name="Drive.EntireFeedLoadTime" units="microseconds">
<obsolete>
Deprecated 12/2013 due to the UMA stat bucket layout change. We'll use
......@@ -6031,6 +6039,23 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
<histogram name="Drive.TransferBlockedOnJobs" units="jobs">
<owner>mtomasz@chromium.org</owner>
<summary>
Number of jobs which have to be completed before a newly added download or
download from or to Drive is requested. Temporary histogram for gathering
data for http://crbug.com/229650.
</summary>
</histogram>
<histogram name="Drive.UploadToDriveFileSize" units="KB">
<owner>mtomasz@chromium.org</owner>
<summary>
Sizes of files being uploaded to Drive. Temporary histogram for gathering
data for http://crbug.com/229650.
</summary>
</histogram>
<histogram name="DriveOffline.CrosAutoEnableOutcome"
enum="CrosEnableDriveOfflineOutcome">
<owner>joshwoodward@google.com</owner>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment