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

cleanup texture cache #1064

Merged
merged 3 commits into from
Jul 7, 2024
Merged

Conversation

cmeissl
Copy link
Collaborator

@cmeissl cmeissl commented Jul 3, 2023

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Jul 3, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.10 🎉

Comparison is base (94f8627) 24.00% compared to head (8ff2320) 24.11%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1064      +/-   ##
==========================================
+ Coverage   24.00%   24.11%   +0.10%     
==========================================
  Files         140      140              
  Lines       21562    21481      -81     
==========================================
+ Hits         5177     5180       +3     
+ Misses      16385    16301      -84     
Flag Coverage Δ
wlcs-buffer 21.10% <0.00%> (+0.07%) ⬆️
wlcs-core 20.72% <0.00%> (+0.07%) ⬆️
wlcs-output 8.46% <0.00%> (+0.03%) ⬆️
wlcs-pointer-input 22.81% <0.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/backend/renderer/mod.rs 17.34% <0.00%> (-0.11%) ⬇️

... and 21 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

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

The first commit is certainly fine this way (apart from docs). I don't love the second, but I am not sure, if calling cleanup_texture_cache all the time is a better solution. It probably not negligible in terms of performance. Can we maybe do a more explicit "no rendering happened"-state than using damage.is_none as a proxy for that information.

// if we receive no damage we can assume no rendering took place
// and we should trigger a cleanup of the renderer texture cache
// to prevent holding textures longer then necessary
renderer.cleanup_texture_cache();
Copy link
Member

Choose a reason for hiding this comment

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

So that means, we kinda code the DrmCompositor around the assumption, that rendering will implicitly cleanup the texture cache? I kinda don't like that tbh, but I don't have a much better solution at hand.

Copy link
Member

Choose a reason for hiding this comment

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

This needs to be at least very well documented on the cleanup_texture_cache method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I don't like that either. But we are currently doing implicit cleanup which is probably OK. Removing that and relying on explicit cleanup with a separate function is worse imo. I am not sure there is an easy way to make the explicit cleanup less costly by only invoking it when really needed. But without it we potentially keep a lot of memory alive unnecessarily. Doing it the way I implemented will at least make sure we do not cleanup twice. I can extend the result of the output damage tracker to explicit tell us if rendering took place. But with the current api I don't see a way on how to encode the cleanup requirements (including the implicit cleanup) other then documenting it in the renderer trait docs. Would that be enough? Clarifying the implicit cleanup in the docs and adding a renderer bool to the result?

Copy link
Member

Choose a reason for hiding this comment

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

Clarifying the implicit cleanup in the docs and adding a renderer bool to the result?

Yeah I would be fine with it as an immediate measure. Maybe when the vulkan renderer finally materializes we can take a step back and evaluate that approach again.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, so while I am all for merging this, can we at least add a note of implicit cleanup happening on Frame::drop to the Frame-trait and Renderer::cleanup_texture_cache docs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I added some comment to the trait and the cleanup function.

@cmeissl cmeissl force-pushed the fix/cleanup_texture_cache branch from 8ff2320 to 83731bd Compare September 17, 2023 10:23
@cmeissl cmeissl force-pushed the fix/cleanup_texture_cache branch 5 times, most recently from 22f37c8 to 22735c7 Compare June 20, 2024 14:43
@cmeissl cmeissl marked this pull request as ready for review June 20, 2024 14:45
@cmeissl cmeissl force-pushed the fix/cleanup_texture_cache branch from 22735c7 to 60483f4 Compare June 20, 2024 21:07
@cmeissl cmeissl force-pushed the fix/cleanup_texture_cache branch from 60483f4 to feaef3a Compare July 7, 2024 10:51
@cmeissl cmeissl requested a review from Drakulix July 7, 2024 10:53
@Drakulix Drakulix merged commit f58a259 into Smithay:master Jul 7, 2024
13 checks passed
@cmeissl cmeissl deleted the fix/cleanup_texture_cache branch July 7, 2024 14:51
@@ -1224,6 +1240,10 @@ where
)
.map_err(Error::Target)?;
let sync = frame.finish().map_err(Error::Target)?;
render
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify, why does this call cleanup_texture_cache() explicitly, even though the new docs say that Frame::finish() does it automatically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The frame here is from the target, so the call to cleanup_texture_cache should clean-up the other renderer in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants