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

Perf/reduce mem allocations #1346

Merged
merged 8 commits into from
Apr 7, 2024

Conversation

cmeissl
Copy link
Collaborator

@cmeissl cmeissl commented Feb 25, 2024

attempt on reducing mem allocations in hot-code paths and some performance improvements

not sure how to best handle the Space::refresh/Output::enter/Output::leave stuff. this is called way to often
imo and we need to get the alive checks out of enter/leave.

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.

A couple of small nitpicks and questions, but otherwise this looks like a really nice improvement so far.

src/backend/renderer/gles/mod.rs Outdated Show resolved Hide resolved
let mut element_render_states = RenderElementStates {
states: HashMap::with_capacity(elements.len()),
};

let mut damage = std::mem::take(&mut self.damage);
let mut element_damage = std::mem::take(&mut self.element_damage);
Copy link
Member

Choose a reason for hiding this comment

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

This will cause new Vec's to be created, no? Why are we not directly using self.damage here, we just cleared it anyway?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is returned here:

std::mem::swap(&mut self.damage, &mut damage);
and an empty Vec does not allocate. Anyway, this is also just some leftover from searching for a error and we can just use self.damage, yeah.

Copy link
Member

Choose a reason for hiding this comment

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

Right and empty Vec does nothing, but it is still confusing to read. If there is no reason to do it this way, I would prefer to just use the value directly in all these cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mostly done, we need to take element_damage as we move it around a bit

@cmeissl cmeissl force-pushed the perf/reduce_mem_allocations branch 3 times, most recently from da48922 to b418255 Compare February 28, 2024 21:21
@codecov-commenter
Copy link

codecov-commenter commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 86 lines in your changes are missing coverage. Please review.

Project coverage is 20.50%. Comparing base (47a8d5b) to head (f4d5874).

Files Patch % Lines
src/backend/renderer/utils/mod.rs 55.88% 30 Missing ⚠️
src/backend/renderer/damage/mod.rs 69.86% 22 Missing ⚠️
src/wayland/output/mod.rs 50.00% 11 Missing ⚠️
src/backend/renderer/element/memory.rs 0.00% 6 Missing ⚠️
src/backend/renderer/element/texture.rs 0.00% 5 Missing ⚠️
src/backend/renderer/element/utils/elements.rs 0.00% 5 Missing ⚠️
src/backend/renderer/element/mod.rs 33.33% 4 Missing ⚠️
src/backend/renderer/utils/wayland.rs 84.61% 2 Missing ⚠️
src/backend/renderer/damage/shaper.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1346      +/-   ##
==========================================
- Coverage   20.61%   20.50%   -0.11%     
==========================================
  Files         161      161              
  Lines       26145    25987     -158     
==========================================
- Hits         5390     5329      -61     
+ Misses      20755    20658      -97     
Flag Coverage Δ
wlcs-buffer 17.91% <59.53%> (-0.13%) ⬇️
wlcs-core 17.60% <54.41%> (-0.11%) ⬇️
wlcs-output 7.32% <14.41%> (-0.16%) ⬇️
wlcs-pointer-input 19.47% <53.48%> (-0.11%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cmeissl cmeissl force-pushed the perf/reduce_mem_allocations branch from 9742b12 to f4d5874 Compare April 5, 2024 20:23
@cmeissl cmeissl marked this pull request as ready for review April 5, 2024 20:41
@cmeissl cmeissl requested a review from Drakulix April 5, 2024 20:47
@Drakulix Drakulix merged commit ba0121a into Smithay:master Apr 7, 2024
13 checks passed
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.

3 participants