Skip to content

Conversation

MaxKoll
Copy link
Contributor

@MaxKoll MaxKoll commented Jan 26, 2023

I noticed this while investigating #10672.

As I understand, the BackgroundUpdater waits for the current _operation() to complete before executing another task. Also, execution happens asynchronously. Therefore I cannot see a reason for the delay before executing the next task.

This makes the UI feel more responsive by removing a noticeable delay between scrolling the revision grid and the subsequent update of the revision graph.

Proposed changes

Remove the delay from BackgroundUpdater.

Test methodology

I compared the scrolling behaviour against v3.5.4.12724 and the current master using this repo, and had an eye on visual appearance and performance.

Test environment(s)

Windows 10.0.19045.0 (134dpi, 140% scaling)
VS2022 Community
Git 2.38.1

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

As the BackgroundUpdater waits for the current _operation() to complete
before executing another task anyway, the delay serves no purpose.

This makes the UI feel more responsive by removing a noticeable delay
between scrolling the revision grid and the subsequent update of the
revision graph.
@mstv
Copy link
Member

mstv commented Jan 27, 2023

The BackgroundUpdater executes only one operation: UpdateVisibleRowRangeInternalAsync.
This delay (of just 25 milliseconds) has been added on purpose in order to reduce the CPU load by consecutive display updates (while loading the revisions).
The first execution is never delayed.

@RussKie RussKie requested a review from mstv March 11, 2023 10:49
@mstv
Copy link
Member

mstv commented Mar 11, 2023

RussKie requested a review from mstv

My point has not been answered. I am not saying this part of #8809 should not be reconsidered. CC: @wischi-chr

The BackgroundUpdater executes only one operation: UpdateVisibleRowRangeInternalAsync.
This delay (of just 25 milliseconds) has been added on purpose in order to reduce the CPU load by consecutive display updates (while loading the revisions).
The first execution is never delayed.

@RussKie RussKie added 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity 💤 status: no recent activity The issue is stale labels Mar 29, 2023
@ghost ghost removed the 💤 status: no recent activity The issue is stale label Mar 29, 2023
@ghost ghost added the 💤 status: no recent activity The issue is stale label Apr 22, 2023
@ghost
Copy link

ghost commented Apr 22, 2023

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 14 days. It will be closed if no further activity occurs.

@ghost ghost closed this Apr 29, 2023
@ghost ghost added the status: abandoned label Apr 29, 2023
@mstv
Copy link
Member

mstv commented May 23, 2023

Do the graph updates of release 4.1.0 work well enough for you, @MaxKoll?

@ghost ghost removed the 💤 status: no recent activity The issue is stale label May 23, 2023
@MaxKoll
Copy link
Contributor Author

MaxKoll commented May 25, 2023

Hi, sorry for not getting back to you sooner.


Do the graph updates of release 4.1.0 work well enough for you, @MaxKoll?

The glitch that made it unusable for me is gone, which I'm happy about.

I still notice the delay between grid updates (i.e. after scrolling, the grid is stuck for a tiny moment, then updates). Also, when scrolling many rows at a time, there are visual glitches while the grid is in motion, as this screenshot shows (v4.1.0.16698):


These quirks are not obstructive, though. They just make the grid feel slightly sluggish. Before 02d5fdb it felt snappy and scrolling was instant (disregarding the bug that was fixed by this commit).


The BackgroundUpdater executes only one operation: UpdateVisibleRowRangeInternalAsync. This delay (of just 25 milliseconds) has been added on purpose in order to reduce the CPU load by consecutive display updates (while loading the revisions). The first execution is never delayed.

  • When I removed the delay I noticed the CPU load going up a little, but not in a way I think that mattered.
  • As soon as you scroll more than 1 row consecutively, the delay will be applied, I think?
  • I thought, as the BackgroundUpdater is running in an async background thread, it is unable to stall the rest of the application, no matter if it is called repeatedly without delay. But as I mentioned before, I don't know .Net or C#, so that's only my intuition.

Compared to the previous updating method which used CancellationTokens (before 02d5fdb), the BackgroundUpdater method seems kind of naive: When the BackgroundUpdater is triggered, it will work on some specific rows of the grid, no matter if they are still in the view when the update finishes. The previous method seemed more convoluted, but also more fine-tuned, aborting grid updates as soon as possible when they became obsolete. I understand that using exception handling as a means of controlling the flow is generally frowned upon, which might have been one of the incentives to get rid of the previous updating method. But looking into "official" code examples regarding CancellationTokens and related topics, this seems to be the intended way of implementing it.

@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label May 25, 2023
@mstv
Copy link
Member

mstv commented Jun 1, 2023

We can reconsider it for v4.2.

Unfortunately, RevisionGrid loading is a construction site yet, f.i. #10957 and #9418... The previous implementation using a manually created thread had its own issues.

@mstv mstv reopened this Jun 1, 2023
@RussKie
Copy link
Member

RussKie commented Jun 18, 2023

@MaxKoll is this something you are still working on?

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Jun 18, 2023
@MaxKoll
Copy link
Contributor Author

MaxKoll commented Jun 19, 2023

No. And should #11046 get merged, the delay is probably not going to matter in practice (in the context of scrolling the grid). I'm fine with this being closed, if that's what you're asking.

(I still believe there should be a better way than a forced delay between updates, but then again I'm unable to provide it.)

@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Jun 19, 2023
@RussKie
Copy link
Member

RussKie commented Oct 7, 2023

@MaxKoll is you still have plans for this - feel free to re-open.
Closing as stale.

@RussKie RussKie closed this Oct 7, 2023
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.

3 participants