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

Serialize submodules info loading #6372

Merged
merged 11 commits into from
Apr 2, 2019
Merged

Conversation

jbialobr
Copy link
Member

@jbialobr jbialobr commented Mar 16, 2019

Fixes #6357

Proposed changes

  • Load submodules info with async api. It was not enough, the lag was smaller but still significant.
  • Load submodules info sequentially - this helped.

Screenshots

Before

image

After

image

Test methodology

  • Manual tests

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

@ghost ghost assigned jbialobr Mar 16, 2019
@ghost ghost added the status: ready label Mar 16, 2019
@codecov
Copy link

codecov bot commented Mar 16, 2019

Codecov Report

Merging #6372 into master will increase coverage by 0.17%.
The diff coverage is 58.78%.

@@            Coverage Diff            @@
##           master   #6372      +/-   ##
=========================================
+ Coverage   46.63%   46.8%   +0.17%     
=========================================
  Files         687     688       +1     
  Lines       51666   51927     +261     
  Branches     6807    6826      +19     
=========================================
+ Hits        24096   24306     +210     
- Misses      26262   26280      +18     
- Partials     1308    1341      +33
Flag Coverage Δ
#production 36.24% <48.3%> (+0.15%) ⬆️
#tests 97.52% <100%> (-0.03%) ⬇️

Encoding outputEncoding = null,
bool stripAnsiEscapeCodes = true)
{
var result = await executable.ExecuteAsync(arguments, writeInput, outputEncoding, stripAnsiEscapeCodes);
Copy link
Member Author

Choose a reason for hiding this comment

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

It is not an async stream, but at least is non blocking.

Copy link
Member

Choose a reason for hiding this comment

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

What kind of stream is it? What would it take to make it properly asynchronous?

Copy link
Member Author

Choose a reason for hiding this comment

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

GitCommands/Submodules/SubmoduleStatusProvider.cs Outdated Show resolved Hide resolved
@gerhardol
Copy link
Member

Thanks!
Works OK for me. There is still a little lag selecting commits while loading, but no "hanging" seen. 2.51 is still snappier loading the data, but 2.51 starts show the revision graph later, so there are other cons.
Would like to see this with #6359 that fixed my real life problem (but not the extreme setup)

Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

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

For c62d4f9, I prefer #6359 instead
There are quite some changes otherwise, mostly seem fine. I would like to see the outcome of the discussion in #6357 (comment) before merging.

@jbialobr
Copy link
Member Author

jbialobr commented Mar 17, 2019

For c62d4f9, I prefer #6359 instead

👍

There are quite some changes otherwise, mostly seem fine. I would like to see the outcome of the discussion in #6357 (comment) before merging.

Even if we go for a dedicated task scheduler for background tasks, running tens of background tasks simultaneously will degrade the overall system performance.

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

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

👍

{
var args = new GitArgumentBuilder("show") { $"HEAD:{path.ToPosixPath().Quote()}" };
var result = _gitExecutable.Execute(args);
var result = await _gitExecutable.ExecuteAsync(args).ConfigureAwaitRunInline();
Copy link
Member

Choose a reason for hiding this comment

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

Could you please explain how you chose when to use ConfigureAwaitRunInline() and when ConfigureAwait(false) calls?

I've found microsoft/vs-threading#292 (via dotnet/project-system#3662), however it is not clear to me why we aren't using one or the other.

Copy link
Member Author

Choose a reason for hiding this comment

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

I use ConfigureAwait(false) when I don't want the continuation to be executed on the main thread.
I use ConfigureAwaitRunInline when I know it is safe to continue on the thread that completed the awaited task (regarding both: accessing variables and continuation's duration time).

GitCommands/Submodules/SubmoduleStatusProvider.cs Outdated Show resolved Hide resolved
@RussKie
Copy link
Member

RussKie commented Mar 20, 2019 via email

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

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

LGTM, but I don't work with any repos with submodules (except the GE), so have no real opinion.

@gerhardol
Copy link
Member

How to continue this?
In everyday use #6359 is solving most issues for me. However, with just a few more submodules than what I use (or something else changed), the problem will occur.

This PR goes after the core problem even if there may be some issues left. From what I can tell, the changes are improvements anyway. Should this be merged anyway?
(At least first commit seem necessary.)

@jbialobr @RussKie
How to proceed?

I rebased and removed one change in c62d4f9 (rest of the commit is probably OK):
https://github.com/gerhardol/gitextensions/tree/jbialobr/_jb/fix%236357
Builds here:
https://ci.appveyor.com/project/gerhardol/gitextensions/builds/23473927/artifacts

There are other ways to limit job (#6373 to minor extent, some suggestions in #5369) too, but that will not handle situations with many submodule changes.

@RussKie
Copy link
Member

RussKie commented Mar 31, 2019

I don't currently work with any repos that have submodules (other than GE), so I have no skin in the game.
The changes look sensible to me, hence my approval.

If you're happy with the changes, let's merge them.

@gerhardol
Copy link
Member

If you're happy with the changes, let's merge them.

There are roughly three parts to this PR (partly from the PR description):

  1. Load submodules info with async api. It was not enough, the lag was smaller but still significant.
    First half, except 2nd commit

Good from what I know about async handling, but I am not the expert here, the existing GE code is my reference. If I were the maintainer, I would have squash merged these commits.

  1. Pre-load module encoding.
    2nd commit

Not needed after #6359. At least one line should be removed, maybe the other are an improvement.

  1. Load submodules info sequentially
    Second half of the commits

Probably OK change, no need to make massive starts of background requests.
However, the change should not be needed according to the discussions in #6357, but if it is an improvement, it should be merged.

@jbialobr @sharwell @drewnoakes @spdr870 @RussKie
How to proceed?

@jbialobr
Copy link
Member Author

jbialobr commented Apr 1, 2019

I would have squash merged these commits.

I see no value in squashing commits. It was already discussed.

Pre-load module encoding.
2nd commit

It is no longer a part of this PR.

However, the change should not be needed according to the discussions in #6357, but if it is an improvement, it should be merged.

In my opinion this change is not needed only if we implement refreshing those submodules which actually have changed. Otherwise querying for all the submodules at once puts an unnecessary pressure on the system resources.

(char code, ObjectId commitId) = moduleSub.GetSuperprojectCurrentCheckout();
Assert.AreEqual(32, code);
Assert.AreEqual(commitRef, commitId.ToString());
ThreadHelper.JoinableTaskFactory.Run(async () =>
Copy link
Member

@sharwell sharwell Apr 1, 2019

Choose a reason for hiding this comment

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

💡 Can we just make the containing test method asynchronous?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know. Is doing so compatible with JTF?

… we have to recheck if cancellation was requested.

Co-Authored-By: jbialobr <jbialobr@o2.pl>
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

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

Thanks. Lets merge this!

I am updating to only request submodule status for trees with changes which also will serialize requests, but this is not in conflict with this PR

@jbialobr jbialobr merged commit 703f607 into gitextensions:master Apr 2, 2019
@ghost ghost removed the status: ready label Apr 2, 2019
@jbialobr jbialobr deleted the jb/fix#6357 branch April 2, 2019 17:43
var cmd = GitCommandHelpers.GetAllChangedFilesCmd(true, UntrackedFilesMode.Default,
noLocks: true);
var output = module.GitExecutable.GetOutput(cmd);
var output = await module.GitExecutable.GetOutputAsync(cmd).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

This change causes git-status to run on the UI thread. Is this really necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you observe any issues related to this? This is an async call and does not block the UI.

Copy link
Member

Choose a reason for hiding this comment

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

No problem seem, just confused by it.

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.

None yet

4 participants