[impeller] gles: started storing the number of handle deletions to avoid reallocation (flutter/engine#56799)
I saw in profiles that we were spending a lot of time in push_back_slow_path. Reserving + emplacing removes that. test-except: no functional change, performance increase ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
This commit is contained in:
parent
45f4ca57b7
commit
8ad87e8401
@ -219,6 +219,9 @@ HandleGLES ReactorGLES::CreateHandle(HandleType type, GLuint external_handle) {
|
|||||||
void ReactorGLES::CollectHandle(HandleGLES handle) {
|
void ReactorGLES::CollectHandle(HandleGLES handle) {
|
||||||
WriterLock handles_lock(handles_mutex_);
|
WriterLock handles_lock(handles_mutex_);
|
||||||
if (auto found = handles_.find(handle); found != handles_.end()) {
|
if (auto found = handles_.find(handle); found != handles_.end()) {
|
||||||
|
if (!found->second.pending_collection) {
|
||||||
|
handles_to_collect_count_ += 1;
|
||||||
|
}
|
||||||
found->second.pending_collection = true;
|
found->second.pending_collection = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,10 +276,12 @@ bool ReactorGLES::ConsolidateHandles() {
|
|||||||
handles_to_name;
|
handles_to_name;
|
||||||
{
|
{
|
||||||
WriterLock handles_lock(handles_mutex_);
|
WriterLock handles_lock(handles_mutex_);
|
||||||
|
handles_to_delete.reserve(handles_to_collect_count_);
|
||||||
|
handles_to_collect_count_ = 0;
|
||||||
for (auto& handle : handles_) {
|
for (auto& handle : handles_) {
|
||||||
// Collect dead handles.
|
// Collect dead handles.
|
||||||
if (handle.second.pending_collection) {
|
if (handle.second.pending_collection) {
|
||||||
handles_to_delete.push_back(
|
handles_to_delete.emplace_back(
|
||||||
std::make_tuple(handle.first, handle.second.name));
|
std::make_tuple(handle.first, handle.second.name));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -292,7 +297,7 @@ bool ReactorGLES::ConsolidateHandles() {
|
|||||||
// Set pending debug labels.
|
// Set pending debug labels.
|
||||||
if (handle.second.pending_debug_label.has_value() &&
|
if (handle.second.pending_debug_label.has_value() &&
|
||||||
handle.first.type != HandleType::kFence) {
|
handle.first.type != HandleType::kFence) {
|
||||||
handles_to_name.push_back(std::make_tuple(
|
handles_to_name.emplace_back(std::make_tuple(
|
||||||
ToDebugResourceType(handle.first.type),
|
ToDebugResourceType(handle.first.type),
|
||||||
handle.second.name.value().handle,
|
handle.second.name.value().handle,
|
||||||
std::move(handle.second.pending_debug_label.value())));
|
std::move(handle.second.pending_debug_label.value())));
|
||||||
|
@ -284,6 +284,7 @@ class ReactorGLES {
|
|||||||
HandleGLES::Equal>;
|
HandleGLES::Equal>;
|
||||||
mutable RWMutex handles_mutex_;
|
mutable RWMutex handles_mutex_;
|
||||||
LiveHandles handles_ IPLR_GUARDED_BY(handles_mutex_);
|
LiveHandles handles_ IPLR_GUARDED_BY(handles_mutex_);
|
||||||
|
int32_t handles_to_collect_count_ IPLR_GUARDED_BY(handles_mutex_) = 0;
|
||||||
|
|
||||||
mutable Mutex workers_mutex_;
|
mutable Mutex workers_mutex_;
|
||||||
mutable std::map<WorkerID, std::weak_ptr<Worker>> workers_ IPLR_GUARDED_BY(
|
mutable std::map<WorkerID, std::weak_ptr<Worker>> workers_ IPLR_GUARDED_BY(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user