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

more profiling less calls and local copies #8300

Merged
merged 6 commits into from
Oct 30, 2024
Merged

Conversation

gulafaran
Copy link
Contributor

more profiling of erraticly moving mouse and generally looking at the most cpu demanding functions appearing doing so.

const ref the things we can, move various objects and variables down in scope to where its actually being used, reduce amount of calls to functions and try reuse already looped and fetched object. mousemoveunified itself could use a refactor but its scary big and i will eventually break something, maybe il attempt it in the future.

add one more for loop in renderWorkspaceWindows and store the windows in a vector with reference wrappers that should be rendered, this adds a loop but reduces the amount of repeated calls to shouldRenderWindow and also makes the rest of the loops go over way smaller vector when many windows exist.

this could use some testing so i didnt actually break something non obvious, works here locally so far. and made marginal gains in the profiling.

mousemoveunified can call this very frequently, the cbox copying
actually shows up as an impact in such cases, move it down in the scope
and only do it when necessery.
profiling shows these as frequent called functions try to reduce the
amount of copies with references and const the variables.
remove unneded local copies and const ref cursorsize.
the amount of calls to g_pCompositor->vectorToWindowUnified fast ramps
up in cpu usage with enough windows existing and moving the mouse, move
the PWINDOWIDEAL up and reuse it if its already the same.
remove unused local copy of accumulateCurrentBufferDamage and const
previousBuffer.
src/render/Renderer.cpp Outdated Show resolved Hide resolved
@vaxerski
Copy link
Member

also wondering, how are you profiling? callgrind has been kinda dog on my end, and tracy broke a while back.

@gulafaran
Copy link
Contributor Author

also wondering, how are you profiling? callgrind has been kinda dog on my end, and tracy broke a while back.

pretty much like this,

profiling.mp4

keep in mind it has tons of various parameters and options to fiddle with, but basicly get pid , perf top -K -p $PID and you can step into the various functions and calls that is averaging the most and trickle down why or what its doing.

@vaxerski
Copy link
Member

dope, thanks

move a few variables down in their scopes to reduce the amount of calls
and copies when not needed, also add one more for loop in
renderWorkspaceWindows and store the windows in a vector with
weakpointers that should be rendered, this adds a loop but reduces the
amount of repeated calls to shouldRenderWindow and also makes the rest
of the loops go over way smaller vector when many windows exist.
Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

tack!

@vaxerski vaxerski merged commit 7c7a84f into hyprwm:main Oct 30, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants