Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] make host buffer state internally ref counted. #48303

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

jonahwilliams
Copy link
Member

std::shared_from_this is actually incredibly slow, and dominates the cost of host buffer allocation at 20x more expensive than the memcpy. We can remove the usage of shared_from_this by making an internal class hold the actual allocation/buffer state instead.

Before

image

146 ms / 647ms = ~20%

After

33 ms / 540 ms = ~6%

image

@jonahwilliams
Copy link
Member Author

Fun before times:

image

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

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

LGTM modulo missing symbol

size_t generation_ = 1u;
std::string label_;
class HostBufferState : public Buffer, public Allocation {
public:
Copy link
Member

Choose a reason for hiding this comment

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

Nit: mark as struct and remove access modifier?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


void Reset();

size_t GetSize() const;
Copy link
Member

Choose a reason for hiding this comment

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

I think the definition is missing for this symbol and it's not being used by anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -116,14 +114,42 @@ class HostBuffer final : public std::enable_shared_from_this<HostBuffer>,
void Reset();

//----------------------------------------------------------------------------
/// @brief Returns the size of the HostBuffer in memory in bytes.
/// @brief Returns the capacity of the HostBuffer in memory in bytes.
size_t GetSize() const;
Copy link
Member

Choose a reason for hiding this comment

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

(Just a drive-by comment, but this name is weird for what it is. It looks like the functionality is the same as it was before, though.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, should be called capacity. I changed the doc comment so it was approximately accurate...

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 22, 2023
@auto-submit auto-submit bot merged commit 1a16fcd into flutter:main Nov 22, 2023
27 checks passed
fluttermirroringbot pushed a commit to flutter/flutter that referenced this pull request Nov 22, 2023
…138872)

flutter/engine@1ae1d53...dda2499

2023-11-22 skia-flutter-autoroll@skia.org Roll Skia from cebd44423589 to 143b6b5b91a5 (1 revision) (flutter/engine#48305)
2023-11-22 skia-flutter-autoroll@skia.org Roll Skia from 23b9316efd20 to cebd44423589 (1 revision) (flutter/engine#48304)
2023-11-22 jonahwilliams@google.com [Impeller] make host buffer state internally ref counted. (flutter/engine#48303)
2023-11-22 skia-flutter-autoroll@skia.org Roll Skia from b6f33389cefa to 23b9316efd20 (2 revisions) (flutter/engine#48302)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jacksongardner@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
caseycrogers pushed a commit to caseycrogers/flutter that referenced this pull request Dec 29, 2023
…lutter#138872)

flutter/engine@1ae1d53...dda2499

2023-11-22 skia-flutter-autoroll@skia.org Roll Skia from cebd44423589 to 143b6b5b91a5 (1 revision) (flutter/engine#48305)
2023-11-22 skia-flutter-autoroll@skia.org Roll Skia from 23b9316efd20 to cebd44423589 (1 revision) (flutter/engine#48304)
2023-11-22 jonahwilliams@google.com [Impeller] make host buffer state internally ref counted. (flutter/engine#48303)
2023-11-22 skia-flutter-autoroll@skia.org Roll Skia from b6f33389cefa to 23b9316efd20 (2 revisions) (flutter/engine#48302)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jacksongardner@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller
Projects
No open projects
Archived in project
3 participants