Bug 726002 - Clear some big nsTArrays as early as possible in updates. r=dcamp
This commit is contained in:
@@ -531,6 +531,7 @@ Classifier::ApplyTableUpdates(nsTArray<TableUpdate*>* aUpdates,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = store->AugmentAdds(AddPrefixHashes);
|
rv = store->AugmentAdds(AddPrefixHashes);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
AddPrefixHashes.Clear();
|
||||||
|
|
||||||
uint32 applied = 0;
|
uint32 applied = 0;
|
||||||
bool updateFreshness = false;
|
bool updateFreshness = false;
|
||||||
|
|||||||
@@ -120,10 +120,10 @@ public:
|
|||||||
|
|
||||||
ChunkSet& AddChunks() { return mAddChunks; }
|
ChunkSet& AddChunks() { return mAddChunks; }
|
||||||
ChunkSet& SubChunks() { return mSubChunks; }
|
ChunkSet& SubChunks() { return mSubChunks; }
|
||||||
const AddPrefixArray& AddPrefixes() const { return mAddPrefixes; }
|
AddPrefixArray& AddPrefixes() { return mAddPrefixes; }
|
||||||
const AddCompleteArray& AddCompletes() const { return mAddCompletes; }
|
AddCompleteArray& AddCompletes() { return mAddCompletes; }
|
||||||
const SubPrefixArray& SubPrefixes() const { return mSubPrefixes; }
|
SubPrefixArray& SubPrefixes() { return mSubPrefixes; }
|
||||||
const SubCompleteArray& SubCompletes() const { return mSubCompletes; }
|
SubCompleteArray& SubCompletes() { return mSubCompletes; }
|
||||||
|
|
||||||
// =======
|
// =======
|
||||||
// Updates
|
// Updates
|
||||||
|
|||||||
@@ -171,8 +171,8 @@ LookupCache::Reset()
|
|||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
LookupCache::Build(const AddPrefixArray& aAddPrefixes,
|
LookupCache::Build(AddPrefixArray& aAddPrefixes,
|
||||||
const AddCompleteArray& aAddCompletes)
|
AddCompleteArray& aAddCompletes)
|
||||||
{
|
{
|
||||||
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_COMPLETIONS,
|
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_COMPLETIONS,
|
||||||
static_cast<PRUint32>(aAddCompletes.Length()));
|
static_cast<PRUint32>(aAddCompletes.Length()));
|
||||||
@@ -182,6 +182,7 @@ LookupCache::Build(const AddPrefixArray& aAddPrefixes,
|
|||||||
for (uint32 i = 0; i < aAddCompletes.Length(); i++) {
|
for (uint32 i = 0; i < aAddCompletes.Length(); i++) {
|
||||||
mCompletions.AppendElement(aAddCompletes[i].CompleteHash());
|
mCompletions.AppendElement(aAddCompletes[i].CompleteHash());
|
||||||
}
|
}
|
||||||
|
aAddCompletes.Clear();
|
||||||
mCompletions.Sort();
|
mCompletions.Sort();
|
||||||
|
|
||||||
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_PREFIXES,
|
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_PREFIXES,
|
||||||
@@ -679,7 +680,7 @@ bool LookupCache::IsPrimed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
LookupCache::ConstructPrefixSet(const AddPrefixArray& aAddPrefixes)
|
LookupCache::ConstructPrefixSet(AddPrefixArray& aAddPrefixes)
|
||||||
{
|
{
|
||||||
Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_PS_CONSTRUCT_TIME> timer;
|
Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_PS_CONSTRUCT_TIME> timer;
|
||||||
|
|
||||||
@@ -693,8 +694,8 @@ LookupCache::ConstructPrefixSet(const AddPrefixArray& aAddPrefixes)
|
|||||||
for (uint32 i = 0; i < aAddPrefixes.Length(); i++) {
|
for (uint32 i = 0; i < aAddPrefixes.Length(); i++) {
|
||||||
array.AppendElement(aAddPrefixes[i].PrefixHash().ToUint32());
|
array.AppendElement(aAddPrefixes[i].PrefixHash().ToUint32());
|
||||||
}
|
}
|
||||||
|
aAddPrefixes.Clear();
|
||||||
|
|
||||||
// clear old tree
|
|
||||||
if (array.IsEmpty()) {
|
if (array.IsEmpty()) {
|
||||||
// DB is empty, but put a sentinel to show that we looked
|
// DB is empty, but put a sentinel to show that we looked
|
||||||
array.AppendElement(0);
|
array.AppendElement(0);
|
||||||
|
|||||||
@@ -137,8 +137,9 @@ public:
|
|||||||
|
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
nsresult Open();
|
nsresult Open();
|
||||||
nsresult Build(const AddPrefixArray& aAddPrefixes,
|
// This will Clear() the passed arrays when done.
|
||||||
const AddCompleteArray& aAddCompletes);
|
nsresult Build(AddPrefixArray& aAddPrefixes,
|
||||||
|
AddCompleteArray& aAddCompletes);
|
||||||
nsresult GetPrefixes(nsTArray<PRUint32>* aAddPrefixes);
|
nsresult GetPrefixes(nsTArray<PRUint32>* aAddPrefixes);
|
||||||
|
|
||||||
#if DEBUG && defined(PR_LOGGING)
|
#if DEBUG && defined(PR_LOGGING)
|
||||||
@@ -160,9 +161,10 @@ private:
|
|||||||
nsresult ReadHeader();
|
nsresult ReadHeader();
|
||||||
nsresult EnsureSizeConsistent();
|
nsresult EnsureSizeConsistent();
|
||||||
nsresult ReadCompletions();
|
nsresult ReadCompletions();
|
||||||
// Construct a Prefix Set with known prefixes
|
|
||||||
nsresult LoadPrefixSet();
|
nsresult LoadPrefixSet();
|
||||||
nsresult ConstructPrefixSet(const AddPrefixArray& aAddPrefixes);
|
// Construct a Prefix Set with known prefixes.
|
||||||
|
// This will Clear() aAddPrefixes when done.
|
||||||
|
nsresult ConstructPrefixSet(AddPrefixArray& aAddPrefixes);
|
||||||
|
|
||||||
struct Header {
|
struct Header {
|
||||||
uint32 magic;
|
uint32 magic;
|
||||||
|
|||||||
Reference in New Issue
Block a user