From fde9a3294997662c45b51cc13ae9bf1fa5954328 Mon Sep 17 00:00:00 2001 From: "shess@chromium.org" Date: Thu, 7 Feb 2013 04:55:26 +0000 Subject: [PATCH] Convert SBSubPrefix vectors to deques. The vector version was frequently caught by OOM killer simply because it's a big allocation. This won't allocate less total memory, but it can pack into available spaces better. BUG=169922 Review URL: https://chromiumcodereview.appspot.com/12207050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181208 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/safe_browsing/safe_browsing_store.cc | 2 +- chrome/browser/safe_browsing/safe_browsing_store.h | 4 +++- chrome/browser/safe_browsing/safe_browsing_store_file.cc | 2 +- chrome/browser/safe_browsing/safe_browsing_store_file.h | 4 ++-- chrome/browser/safe_browsing/safe_browsing_store_unittest.cc | 6 +++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/chrome/browser/safe_browsing/safe_browsing_store.cc b/chrome/browser/safe_browsing/safe_browsing_store.cc index 6a5470d1c89b..0d3f5595a61e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store.cc @@ -165,7 +165,7 @@ void SBCheckPrefixMisses(const SBAddPrefixes& add_prefixes, } void SBProcessSubs(SBAddPrefixes* add_prefixes, - std::vector* sub_prefixes, + SBSubPrefixes* sub_prefixes, std::vector* add_full_hashes, std::vector* sub_full_hashes, const base::hash_set& add_chunks_deleted, diff --git a/chrome/browser/safe_browsing/safe_browsing_store.h b/chrome/browser/safe_browsing/safe_browsing_store.h index d88fedb69fd8..95b3761c361b 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store.h +++ b/chrome/browser/safe_browsing/safe_browsing_store.h @@ -67,6 +67,8 @@ struct SBSubPrefix { SBPrefix GetAddPrefix() const { return add_prefix; } }; +typedef std::deque SBSubPrefixes; + struct SBAddFullHash { int32 chunk_id; int32 received; @@ -138,7 +140,7 @@ bool SBAddPrefixHashLess(const T& a, const U& b) { // but it might make sense to make sorting an API requirement so that // the storage can optimize for it. void SBProcessSubs(SBAddPrefixes* add_prefixes, - std::vector* sub_prefixes, + SBSubPrefixes* sub_prefixes, std::vector* add_full_hashes, std::vector* sub_full_hashes, const base::hash_set& add_chunks_deleted, diff --git a/chrome/browser/safe_browsing/safe_browsing_store_file.cc b/chrome/browser/safe_browsing/safe_browsing_store_file.cc index 76a8958aad0b..e7f377ae78cd 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_file.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store_file.cc @@ -510,7 +510,7 @@ bool SafeBrowsingStoreFile::DoUpdate( CHECK(add_full_hashes_result); SBAddPrefixes add_prefixes; - std::vector sub_prefixes; + SBSubPrefixes sub_prefixes; std::vector add_full_hashes; std::vector sub_full_hashes; diff --git a/chrome/browser/safe_browsing/safe_browsing_store_file.h b/chrome/browser/safe_browsing/safe_browsing_store_file.h index 3b55b358b84a..f590655c7c3e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_file.h +++ b/chrome/browser/safe_browsing/safe_browsing_store_file.h @@ -233,7 +233,7 @@ class SafeBrowsingStoreFile : public SafeBrowsingStore { // pre-reserved space is probably reasonable between each chunk // collected. SBAddPrefixes().swap(add_prefixes_); - std::vector().swap(sub_prefixes_); + SBSubPrefixes().swap(sub_prefixes_); std::vector().swap(add_hashes_); std::vector().swap(sub_hashes_); return true; @@ -252,7 +252,7 @@ class SafeBrowsingStoreFile : public SafeBrowsingStore { // Buffers for collecting data between BeginChunk() and // FinishChunk(). SBAddPrefixes add_prefixes_; - std::vector sub_prefixes_; + SBSubPrefixes sub_prefixes_; std::vector add_hashes_; std::vector sub_hashes_; diff --git a/chrome/browser/safe_browsing/safe_browsing_store_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_store_unittest.cc index 2c973e7e547a..9c73f384ea76 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store_unittest.cc @@ -114,7 +114,7 @@ TEST(SafeBrowsingStoreTest, SBSubFullHashLess) { TEST(SafeBrowsingStoreTest, SBProcessSubsEmpty) { SBAddPrefixes add_prefixes; std::vector add_hashes; - std::vector sub_prefixes; + SBSubPrefixes sub_prefixes; std::vector sub_hashes; const base::hash_set no_deletions; @@ -150,7 +150,7 @@ TEST(SafeBrowsingStoreTest, SBProcessSubsKnockout) { SBAddPrefixes add_prefixes; std::vector add_hashes; - std::vector sub_prefixes; + SBSubPrefixes sub_prefixes; std::vector sub_hashes; // An add with prefix and a couple hashes, plus a sub for the prefix @@ -228,7 +228,7 @@ TEST(SafeBrowsingStoreTest, SBProcessSubsDeleteChunk) { SBAddPrefixes add_prefixes; std::vector add_hashes; - std::vector sub_prefixes; + SBSubPrefixes sub_prefixes; std::vector sub_hashes; // An add with prefix and a couple hashes, plus a sub for the prefix -- 2.11.4.GIT