summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-02 04:40:22 +0000
committerttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-02 04:40:22 +0000
commitf48b17719df9c2b5fbd1dc955ee2bf9017b95e72 (patch)
tree14bbbd0d6d3a35116a3a52097265953c865e1283 /net
parent5b0400247d9d5949915d8b4fcaa3798f81e0cb02 (diff)
downloadchromium_src-f48b17719df9c2b5fbd1dc955ee2bf9017b95e72.zip
chromium_src-f48b17719df9c2b5fbd1dc955ee2bf9017b95e72.tar.gz
chromium_src-f48b17719df9c2b5fbd1dc955ee2bf9017b95e72.tar.bz2
Add file descriptor limit histogram to Simple Cache
We want to compare the open entry count to the file descriptor limit to see if we're in danger of running the system out of fds. BUG= Review URL: https://chromiumcodereview.appspot.com/20117002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215212 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/disk_cache/simple/simple_backend_impl.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/net/disk_cache/simple/simple_backend_impl.cc b/net/disk_cache/simple/simple_backend_impl.cc
index c8a8e7c..1a0fef7 100644
--- a/net/disk_cache/simple/simple_backend_impl.cc
+++ b/net/disk_cache/simple/simple_backend_impl.cc
@@ -7,6 +7,10 @@
#include <algorithm>
#include <cstdlib>
+#if defined(OS_POSIX)
+#include <sys/resource.h>
+#endif
+
#include "base/bind.h"
#include "base/callback.h"
#include "base/file_util.h"
@@ -14,6 +18,7 @@
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
+#include "base/metrics/sparse_histogram.h"
#include "base/single_thread_task_runner.h"
#include "base/sys_info.h"
#include "base/task_runner_util.h"
@@ -71,6 +76,46 @@ void MaybeCreateSequencedWorkerPool() {
}
}
+bool g_fd_limit_histogram_has_been_populated = false;
+
+void MaybeHistogramFdLimit() {
+ if (g_fd_limit_histogram_has_been_populated)
+ return;
+
+ // Used in histograms; add new entries at end.
+ enum FdLimitStatus {
+ FD_LIMIT_STATUS_UNSUPPORTED = 0,
+ FD_LIMIT_STATUS_FAILED = 1,
+ FD_LIMIT_STATUS_SUCCEEDED = 2,
+ FD_LIMIT_STATUS_MAX = 3
+ };
+ FdLimitStatus fd_limit_status = FD_LIMIT_STATUS_UNSUPPORTED;
+ int soft_fd_limit = 0;
+ int hard_fd_limit = 0;
+
+#if defined(OS_POSIX)
+ struct rlimit nofile;
+ if (!getrlimit(RLIMIT_NOFILE, &nofile)) {
+ soft_fd_limit = nofile.rlim_cur;
+ hard_fd_limit = nofile.rlim_max;
+ fd_limit_status = FD_LIMIT_STATUS_SUCCEEDED;
+ } else {
+ fd_limit_status = FD_LIMIT_STATUS_FAILED;
+ }
+#endif
+
+ UMA_HISTOGRAM_ENUMERATION("SimpleCache.FileDescriptorLimitStatus",
+ fd_limit_status, FD_LIMIT_STATUS_MAX);
+ if (fd_limit_status == FD_LIMIT_STATUS_SUCCEEDED) {
+ UMA_HISTOGRAM_SPARSE_SLOWLY("SimpleCache.FileDescriptorLimitSoft",
+ soft_fd_limit);
+ UMA_HISTOGRAM_SPARSE_SLOWLY("SimpleCache.FileDescriptorLimitHard",
+ hard_fd_limit);
+ }
+
+ g_fd_limit_histogram_has_been_populated = true;
+}
+
// Must run on IO Thread.
void DeleteBackendImpl(disk_cache::Backend** backend,
const net::CompletionCallback& callback,
@@ -177,6 +222,7 @@ SimpleBackendImpl::SimpleBackendImpl(const FilePath& path,
SimpleEntryImpl::OPTIMISTIC_OPERATIONS :
SimpleEntryImpl::NON_OPTIMISTIC_OPERATIONS),
net_log_(net_log) {
+ MaybeHistogramFdLimit();
}
SimpleBackendImpl::~SimpleBackendImpl() {