Make cc:RenderingStats a move-only type.
It contains six std::vector<> members, so the implicit copy in TakeImplThreadRenderingStats() may end up doing six memory allocations while holding a lock. Change-Id: I46b20c83679b44a334a8905fd6e76204bf3e2854 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5982361 Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org> Cr-Commit-Position: refs/heads/main@{#1376659}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b548694c36
commit
40d3913cdc
@ -10,8 +10,10 @@ namespace cc {
|
||||
|
||||
RenderingStats::TimeDeltaList::TimeDeltaList() = default;
|
||||
|
||||
RenderingStats::TimeDeltaList::TimeDeltaList(const TimeDeltaList& other) =
|
||||
default;
|
||||
RenderingStats::TimeDeltaList::TimeDeltaList(TimeDeltaList&& other) = default;
|
||||
|
||||
RenderingStats::TimeDeltaList& RenderingStats::TimeDeltaList::operator=(
|
||||
TimeDeltaList&& other) = default;
|
||||
|
||||
RenderingStats::TimeDeltaList::~TimeDeltaList() = default;
|
||||
|
||||
@ -39,7 +41,9 @@ base::TimeDelta RenderingStats::TimeDeltaList::GetLastTimeDelta() const {
|
||||
|
||||
RenderingStats::RenderingStats() = default;
|
||||
|
||||
RenderingStats::RenderingStats(const RenderingStats& other) = default;
|
||||
RenderingStats::RenderingStats(RenderingStats&& other) = default;
|
||||
|
||||
RenderingStats& RenderingStats::operator=(RenderingStats&& other) = default;
|
||||
|
||||
RenderingStats::~RenderingStats() = default;
|
||||
|
||||
|
@ -21,7 +21,10 @@ struct CC_DEBUG_EXPORT RenderingStats {
|
||||
class CC_DEBUG_EXPORT TimeDeltaList {
|
||||
public:
|
||||
TimeDeltaList();
|
||||
TimeDeltaList(const TimeDeltaList& other);
|
||||
TimeDeltaList(const TimeDeltaList& other) = delete;
|
||||
TimeDeltaList(TimeDeltaList&& other);
|
||||
TimeDeltaList& operator=(const TimeDeltaList& other) = delete;
|
||||
TimeDeltaList& operator=(TimeDeltaList&& other);
|
||||
~TimeDeltaList();
|
||||
|
||||
void Append(base::TimeDelta value);
|
||||
@ -37,7 +40,10 @@ struct CC_DEBUG_EXPORT RenderingStats {
|
||||
};
|
||||
|
||||
RenderingStats();
|
||||
RenderingStats(const RenderingStats& other);
|
||||
RenderingStats(const RenderingStats& other) = delete;
|
||||
RenderingStats(RenderingStats&& other);
|
||||
RenderingStats& operator=(const RenderingStats& other) = delete;
|
||||
RenderingStats& operator=(RenderingStats&& other);
|
||||
~RenderingStats();
|
||||
|
||||
int64_t frame_count = 0;
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
|
||||
namespace cc {
|
||||
@ -24,7 +26,7 @@ RenderingStatsInstrumentation::~RenderingStatsInstrumentation() = default;
|
||||
|
||||
RenderingStats RenderingStatsInstrumentation::TakeImplThreadRenderingStats() {
|
||||
base::AutoLock scoped_lock(lock_);
|
||||
auto stats = impl_thread_rendering_stats_;
|
||||
auto stats = std::move(impl_thread_rendering_stats_);
|
||||
impl_thread_rendering_stats_ = RenderingStats();
|
||||
return stats;
|
||||
}
|
||||
|
Reference in New Issue
Block a user