diff options
author | Etienne Pierre-doray <etiennep@chromium.org> | 2021-09-14 17:31:51 +0000 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2021-09-14 10:48:48 -0700 |
commit | aff408603b3db5b7974c522db2ad8c5ce2a0f3c1 (patch) | |
tree | 4366ce54a82c7aa38617942292f0a30b08a775cd /targets_affinity.h | |
parent | 9ff43f558d334f100a92bf93d764f32293f9c5aa (diff) | |
download | zucchini-aff408603b3db5b7974c522db2ad8c5ce2a0f3c1.tar.gz |
[zucchini]: Convert TargetPool to deque.
shrink_to_fit with vector tends to cause high memory peak.
Changing deque is a simple change that reduces memory peak at the cost of
loss of guarantee (contiguous storage).
Similar to https://chromium-review.googlesource.com/c/chromium/src/+/2830864
which dramatically reduced crach rate
https://crash.corp.google.com/browse?q=product_name%3D%27Chrome%27+AND+EXISTS+%28SELECT+1+FROM+UNNEST%28CrashedStackTrace.StackFrame%29+WHERE+FunctionName%3D%27installer%3A%3AArchivePatchHelper%3A%3AZucchiniEnsemblePatch%27%29+AND+expanded_custom_data.ChromeCrashProto.magic_signature_1.name%3D%27%5BOut+of+Memory%5D+zucchini%3A%3ADisassemblerWin32%3Czucchini%3A%3AWin32X64Traits%3E%3A%3AParseAndStoreRel32%27
An alternative is to look ahead to determine vector size. The is hard to do
with SortAndUniquify, which performs in-place modifications.
Bug: 1247633
Change-Id: I624c360ee1f2bf18bd584d1aafdde0f0c2ffb61e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3149810
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/main@{#921292}
NOKEYCHECK=True
GitOrigin-RevId: 380557e6b592531eb360513791968dd7ab0ee77d
Diffstat (limited to 'targets_affinity.h')
-rw-r--r-- | targets_affinity.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/targets_affinity.h b/targets_affinity.h index dff1741..163b015 100644 --- a/targets_affinity.h +++ b/targets_affinity.h @@ -8,6 +8,7 @@ #include <stddef.h> #include <stdint.h> +#include <deque> #include <vector> #include "components/zucchini/image_utils.h" @@ -30,8 +31,8 @@ class TargetsAffinity { // affinity scores. Both |old_targets| and |new_targets| are targets in the // same pool and are sorted in ascending order. void InferFromSimilarities(const EquivalenceMap& equivalence_map, - const std::vector<offset_t>& old_targets, - const std::vector<offset_t>& new_targets); + const std::deque<offset_t>& old_targets, + const std::deque<offset_t>& new_targets); // Assigns labels to targets based on associations previously inferred, using // |min_affinity| to reject associations with weak |affinity|. Label 0 is |