Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@chinmaygarde
Copy link
Member

Moves signaled checks and callbacks out of the wait set mutex critical section.

The signaled checked can apparently be super slow on Qualcomm devices and the callback may hit allocators that could be slow as well.

… mutex critical section.

Moves signaled checks and callbacks out of the wait set mutex critical
section.

The signaled checked can apparently be super slow on Qualcomm devices
and the callback may hit allocators that could be slow as well.
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Love reading your PRs, I get to learn more C++

TIL about copy_if!

std::scoped_lock lock(wait_set_mutex_);
std::copy_if(wait_set_.begin(), wait_set_.end(),
std::back_inserter(erased_entries), is_signalled);
wait_set_.erase(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't you still calling the callback in the while inside the lock? The last reference deleted should be here (inside of a lock). On the other PR you said you wanted to remove the callback outside of the lock.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the easiest fix is to make UpdateSignalStatus call the callback.

This code would probably be easier to follow if it was converted to use std::unique_ptr then holding raw pointers on the stack in wait_set.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entries are shared pointers to WaitSetEntry. These have been copied over to the erased_entries set. That set is cleared outside the critical section. The scoped cleanup closures get dropped in WaitSetEntry dtor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I missed erased_entries. LGTM.

{
TRACE_EVENT0("impeller", "ClearSignaledFences");
// Erase the erased entries which will invoke callbacks.
erased_entries.clear(); // Bit redundant because of scope but hey.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaaclarke Here is where the callbacks are invoked.

@chinmaygarde
Copy link
Member Author

TIL about copy_if!

"105 STL Algorithms in Less Than an Hour" is not a bad watch.

@chinmaygarde chinmaygarde added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2023
@auto-submit auto-submit bot merged commit feeef96 into flutter:main Jun 23, 2023
@chinmaygarde chinmaygarde deleted the nocrit branch June 23, 2023 18:40
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller needs tests

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants