diff options
-rw-r--r-- | third_party/leveldatabase/env_chromium.cc | 44 | ||||
-rw-r--r-- | tools/metrics/histograms/histograms.xml | 27 |
2 files changed, 64 insertions, 7 deletions
diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc index 35a37a4..b14fc01 100644 --- a/third_party/leveldatabase/env_chromium.cc +++ b/third_party/leveldatabase/env_chromium.cc @@ -34,8 +34,10 @@ #include "base/win/win_util.h" #endif -#if !defined(OS_WIN) +#if defined(OS_POSIX) #include <fcntl.h> +#include <sys/resource.h> +#include <sys/time.h> #endif namespace { @@ -397,6 +399,15 @@ class ChromiumEnv : public Env, public UMALogger { } } + void RecordOpenFilesLimit(const std::string& type) { +#if defined(OS_POSIX) + struct rlimit nofile; + if (getrlimit(RLIMIT_NOFILE, &nofile)) + return; + GetMaxFDHistogram(type)->Add(nofile.rlim_cur); +#endif + } + virtual Status NewRandomAccessFile(const std::string& fname, RandomAccessFile** result) { int flags = ::base::PLATFORM_FILE_READ | ::base::PLATFORM_FILE_OPEN; @@ -404,13 +415,18 @@ class ChromiumEnv : public Env, public UMALogger { ::base::PlatformFileError error_code; ::base::PlatformFile file = ::base::CreatePlatformFile( CreateFilePath(fname), flags, &created, &error_code); - if (error_code != ::base::PLATFORM_FILE_OK) { - *result = NULL; - RecordOSError(kNewRandomAccessFile, error_code); - return Status::IOError(fname, PlatformFileErrorString(error_code)); + if (error_code == ::base::PLATFORM_FILE_OK) { + *result = new ChromiumRandomAccessFile(fname, file, this); + RecordOpenFilesLimit("Success"); + return Status::OK(); } - *result = new ChromiumRandomAccessFile(fname, file, this); - return Status::OK(); + if (error_code == ::base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED) + RecordOpenFilesLimit("TooManyOpened"); + else + RecordOpenFilesLimit("OtherError"); + *result = NULL; + RecordOSError(kNewRandomAccessFile, error_code); + return Status::IOError(fname, PlatformFileErrorString(error_code)); } virtual Status NewWritableFile(const std::string& fname, @@ -675,6 +691,7 @@ class ChromiumEnv : public Env, public UMALogger { base::HistogramBase* GetOSErrorHistogram(MethodID method, int limit) const; base::HistogramBase* GetRetryTimeHistogram(MethodID method) const; base::HistogramBase* GetMethodIOErrorHistogram() const; + base::HistogramBase* GetMaxFDHistogram(const std::string& type); base::FilePath test_directory_; size_t page_size_; @@ -727,6 +744,19 @@ base::HistogramBase* ChromiumEnv::GetMethodIOErrorHistogram() const { kNumEntries + 1, base::Histogram::kUmaTargetedHistogramFlag); } +base::HistogramBase* ChromiumEnv::GetMaxFDHistogram( + const std::string& type) { + std::string uma_name(name_); + uma_name.append(".MaxFDs.").append(type); + // These numbers make each bucket twice as large as the previous bucket. + const int kFirstEntry = 1; + const int kLastEntry = 65536; + const int kNumBuckets = 18; + return base::Histogram::FactoryGet( + uma_name, kFirstEntry, kLastEntry, kNumBuckets, + base::Histogram::kUmaTargetedHistogramFlag); +} + class Thread : public ::base::PlatformThread::Delegate { public: Thread(void (*function)(void* arg), void* arg) diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 6c10f8d..2c65a75 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -919,6 +919,13 @@ other types of suffix sets. <summary>Errno of errors encountered in WritableFileFlush.</summary> </histogram> +<histogram name="LevelDBEnv.IDB.MaxFDs" units="files"> + <summary> + File descriptor limit recorded every time LevelDB calls NewRandomAccessFile + for IndexedDB. + </summary> +</histogram> + <histogram name="LevelDBEnv.IDB.TimeTo" units="milliseconds"> <obsolete> Deprecated 2013-04. As of m28 use LevelDBEnv.IDB.TimeUntilSuccessFor. @@ -969,6 +976,13 @@ other types of suffix sets. <summary>Errno of errors encountered in WritableFileFlush.</summary> </histogram> +<histogram name="LevelDBEnv.MaxFDs" units="files"> + <summary> + File descriptor limit recorded every time LevelDB calls NewRandomAccessFile + for clients other than IndexedDB. + </summary> +</histogram> + <histogram name="LevelDBEnv.TimeTo" units="milliseconds"> <obsolete> Deprecated 2013-04. As of m28 use LevelDBEnv.TimeUntilSuccessFor. @@ -10910,6 +10924,19 @@ other types of suffix sets. <affected-histogram name="LevelDBEnv.TimeUntilSuccessFor"/> </fieldtrial> +<fieldtrial name="LevelDBEnvMaxFDs" separator="."> + <group name="Success" + label="This histogram shows the limit when open succeeded."/> + <group name="TooManyOpened" + label="This histogram shows the limit when open failed because the + limit had been reached."/> + <group name="OtherError" + label="This histogram shows the limit when open failed for reasons + other than exceeding the limit."/> + <affected-histogram name="LevelDBEnv.IDB.MaxFDs"/> + <affected-histogram name="LevelDBEnv.MaxFDs"/> +</fieldtrial> + <fieldtrial name="LevelDBEnvPlatformFileErrors" separator=""> <group name="NewRandomAccessFile" label="NewRandomAccessFile"/> <group name="LockFile" label="LockFile"/> |