-
-
Notifications
You must be signed in to change notification settings - Fork 584
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
Improve latency, fix rectangular "tearing", better performance metrics with frame pacing #968
Conversation
Render times don't look good. It is ~5ms/frame here. Need to investigate what's so slow. |
I wonder how well this works for NVIDIA users. I would be surprised if this works for them at all 🤔 |
if there is no time limit for this pull request to be merged i can test it in maybe 5 days on an average nvidia gpu (gtx 1650). unfortunately, i’m ill now and my pc is not with me. also, is it possible to test/debug picom remotely? i think i could give you remote access to my pc from time to time via rdp or something like this. if you’re interested you can contact me in telegram with the same login. |
@absolutelynothelix no need to hurry! i still need to tweak this PR. i would be interested to see your results. |
for me, if i can get the render time down to reasonable levels ( |
With dual_kawase blur strength 20, the render time goes up to ~11ms 🥲 |
At least on my GTX 1070 with driver 515.43.04 it compiles and draws fine. 🤷 Just a very preliminary test though. Logs
followed by the occasional |
@tryone144 nice! i was worried that NVIDIA's present extension implementation might use a different time base from CLOCK_MONOTONIC. |
Codecov Report
@@ Coverage Diff @@
## next #968 +/- ##
==========================================
- Coverage 37.76% 37.64% -0.12%
==========================================
Files 48 49 +1
Lines 10869 11137 +268
==========================================
+ Hits 4105 4193 +88
- Misses 6764 6944 +180
|
fadea0f
to
572b17e
Compare
e9064a2
to
dfa9dbe
Compare
hmph, there is a raging memory leak somewhere i need to fix. |
640addb
to
d72f835
Compare
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Timer can sometimes drift randomly, like when the system is suspended. we don't want to disable frame pacing for that Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Sometimes X sends bogus complete notifies with invalid msc number. Instead use a saved msc number to get the next complete notify. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
So when the screen is off, we calls queue_redraw, hoping draw_callback will be called and unredirects the screen. However, queue_redraw doesn't queue another redraw when one is already queued. Redraws can be queued in two ways: one is timer based, which is fine, because it will be triggered no matter what; the other is frame based, which is triggered by Present events. When the screen is off, X server, depends on the driver, could send abnormal Present events, which we ignore. But that also means queued frame based redraw will stop being triggered. Those two factors combined means sometimes unredirection does not happen when the screen is off. Which means we aren't going to free the GL context, which are still receiving Present events, but can't handle them, because we are not rendering anything with GL. In the end all these causes memory usage to balloon, until the screen is turned on and we start rendering again. And all these is not caught by leak checkers because this technically is not a leak, as everything is eventually freed. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
We only checked render time. If we don't have frame time estimates, we would divide by zero and end up with wild scheduling delays. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
d72e80f
to
3872813
Compare
@absolutelynothelix hey, i made some effort to make things smoother. can you try to see if it's better for you? |
Add a render_statistics type to encapsulate all the statistics done on rendering times. And use that to estimate the time budget for rendering and frame pacing. Tweak the rolling window utilities a bit so we can reuse one rolling window for multiple statistics. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Sometimes a scheduled render can end up doing nothing, e.g. if the damage region is empty. In that case we don't have valid data to collect and thus shouldn't update the statistics. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Make picom realtime to reduce latency, and make rendering times more predictable to help pacing. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
@yshui, i'd say it feels pretty much same. i can record a new video if you wish. |
@absolutelynothelix the logs would be more useful. |
@yshui, are you interested in particular messages or in all messages introduced with this pull request? |
@absolutelynothelix just throw the whole trace logs here, i know how to use grep ;) |
i was moving a small terminal window from where i launched picom in front of a big terminal window with nonsense activity. i stopped picom some time after window movement started to lag, so all the interesting information should be somewhere in the end. p.s.:
|
@absolutelynothelix yeah the frames just took too long to render, that's a different problem we need to resolve aside from this PR
|
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
@EpsilonKu I joined! My discord username is yshui#7811, can you make me a moderator? I will also add a link to it in README. |
@tryone144 do you have a discord account by any chance? |
Latency
Rendering a frame too early can cause long latency. Generally we want to render a frame as late as possible, as long as it finishes in time before the vblank period.
Tearing
Sometimes user will see rectangular shaped tearing when
use-damage
is enabled. This is because we started rendering early, before all the damages for that frame has arrived. Resulting in only part of an updated window being presented on to the screen.Metrics
Previously, we never measured how long each frame takes to render. We need this information to pace the frames properly, i.e. to achieve the things listed above. So as a nice side effect, we now know exactly how inefficient we actually are 🥲
Known problem