-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
GitModule Encoding lazy encoding #6359
GitModule Encoding lazy encoding #6359
Conversation
2076bce
to
dfbd471
Compare
CodeFactor reports complexity on methods where the signature was changed only, no logic changed. |
dfbd471
to
07b797b
Compare
Codecov Report
@@ Coverage Diff @@
## master #6359 +/- ##
==========================================
+ Coverage 46.62% 46.67% +0.05%
==========================================
Files 687 687
Lines 51666 51670 +4
Branches 6807 6807
==========================================
+ Hits 24087 24118 +31
+ Misses 26268 26222 -46
- Partials 1311 1330 +19
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think the proposed API changes are safe, and in the long run they may become very problematic.
If we wish to stop re-querying the encoding, how about we pass encoding as an optional parameter when constructing a GitModule
instance?
90cacc6
to
8340d95
Compare
8340d95
to
4cd2a20
Compare
@RussKie @amaiorano |
I've looked over the diffs here in the browser, and I don't really understand this change. For instance, I see that |
When Encoding is passed as a parameter, it is evaluated directly when calling, which requires a git-rev-parse call. However, Encoding is only needed when there are actual differences, so most Encoding calculations are not needed. If Lazy is used, it is evaluated when it is first used. |
You mean that for every function call where Encoding was being passed, it gets evaluated? Like when it first gets passed to I feel like I'm missing something super obvious... sorry. |
Yes, I know what Lazy does, but in the specific use case I outline above, we create a Lazy around an instance that already exists and has been passed in: var patches = PatchProcessor.CreatePatchesFromString(patch, new Lazy<Encoding>(() => encoding)).ToList(); Normally, Lazy is provided with a factory function to create an instance lazily. That's what I don't understand here. If the instance has already been created, then what are we saving on? Passing a reference type as argument doesn't cost anything. EDIT: So looking over the change again, I can see that in most places, it makes sense to use Lazy. I think the problem is that the very first diff that GitHub shows is for one where it doesn't help at all: the one in EDIT 2: And to clarify, the problem that this patch fixes is the instantiation of Encoding instances via the static |
The EffectiveConfigFile getter will require git-rev-parse to get the current config. As the original code passed FilesEncoding reference, EffectiveConfigFile had to be evaluated. If the value is needed, not much other than to calculate it. So if all submodules are changed, this PR will not improve anything. However, the value is only required when there are changes (and the normal scenario with submodules is few changes, otherwise submodules are a pain): For other than submodules, GE normally knows when there are changes. For submodules we cannot know (without calling other commands first). |
Unless there are protests, I will merge this tomorrow |
The patch formatting may evaluate that no changes have been done As the encoding is an input to patch formatting, speculative evaluation of FileEncoding would require a separate git-rev-parse call. Especially for evaluating submodule status changes (where there are normally no changes), this would slow down the I/O.
4cd2a20
to
0341177
Compare
👍 from me
…On Thu, Mar 21, 2019, 9:04 AM Gerhard Olsson ***@***.*** wrote:
Unless there are protests, I will merge this tomorrow
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6359 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEMyXm8Hjfiw_c_2jpzNq-9XW1qgYaRdks5vYrBTgaJpZM4bnUHG>
.
|
Part of #6357
Proposed changes
- Optimize copy GitModule copyWIP Optimize create copy of GitModule() #6373This fixes the performance problem I see in my "real" repos even if the core problem should be fixed too.
Test methodology
See #6357 for a test setup
This is verified by git-rev-parse calls for only the modules with changes
Test environment(s)
See #6357 , a submodule with changes required
✒️ I contribute this code under The Developer Certificate of Origin.