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

perf: Improve height calculation performance #99

Merged
merged 4 commits into from
Dec 18, 2019
Merged

perf: Improve height calculation performance #99

merged 4 commits into from
Dec 18, 2019

Conversation

zvirja
Copy link
Contributor

@zvirja zvirja commented Dec 16, 2019

Description

Changed algorithm to compare commit with previous one,
instead of always comparing with HEAD. This way complexity is dropping from O(n^2) to O(n), as each change is processed only once.

I've also changed while() loop with foreach, as:

  • foreach does the same and looks more natural
  • it was buggy as we didn't dispose iterator 😉

Let me know if you want me to revert that change.

Change Type

Bug Fix: Fixes an issue in implementation

Quality

  • Unit tests have been added/updated
  • Local builds/testing are successful
  • Code coverage has not decreased
  • Code comments have been provided (where appropriate)
  • Core styles have been followed
  • Documentation has been added/updated

@zvirja zvirja requested a review from Kieranties as a code owner December 16, 2019 16:33
Changed algorithm to compare commit with previous one,
instead of always comparing with HEAD. This way complexity is
dropping from O(n^2) to O(n), as each change is processed only once.
Kieranties
Kieranties previously approved these changes Dec 16, 2019
Copy link
Owner

@Kieranties Kieranties left a comment

Choose a reason for hiding this comment

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

Thanks for the additional catch with the enumerator!

@Kieranties
Copy link
Owner

The build is currently failing due to this issue in nuget: NuGet/Home#8692 I'll try to work around...

It takes time and we don't actually need it.
@zvirja
Copy link
Contributor Author

zvirja commented Dec 16, 2019

@Kieranties Ok. Just out of curiosity profiled app and found that actually the reason is rename detection. It hits previous code more because change set is larger all the time. Once I disable rename detection, both code variances perform at equivalent speed.

I pushed change to make code even faster (2 secs vs 4 secs).

If you want to get back to old code when you always use tip - it's also fine, as it will not degrade performance noticeably. But I still somehow feel that we will do extra work in that case... 🤔

@zvirja
Copy link
Contributor Author

zvirja commented Dec 17, 2019

@Kieranties Added one more improvement, so now it takes 1 second(wrong measurement; time is still comparable). Will stop here 😅

@Kieranties Kieranties mentioned this pull request Dec 17, 2019
11 tasks
@Kieranties
Copy link
Owner

@zvirja I've fixed up the build specifically targeting netcore 3.1 locally and things work - however the azure VMs don't have LTS 3.1 installed yet.
I've got this wrapped up in #100

It seems they've identified the fix for the issue over at NuGet/Home#8692 - hopefully we'll be able to pick that up soon. Once it's ready I can confirm with #100 (as it has some housekeeping anyway) then bring in this.

@Kieranties Kieranties added the 🐛 bug Something isn't working label Dec 17, 2019
@zvirja
Copy link
Contributor Author

zvirja commented Dec 17, 2019

Thanks for the update.

Even if they make the fix soon, it will take time to get it merged to .NET Core SDK, published, pushed to VMs. Am worried that it could take at least a month 😐

Do you see a way it might be speeded up? Is the issue you hit intermittent or stable? Could it just be worked around by running it again? 🤨

@Kieranties
Copy link
Owner

Kieranties commented Dec 18, 2019 via email

@Kieranties Kieranties changed the title Improve height calculation performance perf: Improve height calculation performance Dec 18, 2019
@Kieranties
Copy link
Owner

And we're good! I've updated the build to enforce the install of LTS (3.1.100 at this point in time).
Will get this merged and pushed soon.

@Kieranties Kieranties merged commit fc7bac0 into Kieranties:master Dec 18, 2019
@zvirja zvirja deleted the improve-height-calculation-performance branch December 18, 2019 17:13
@zvirja
Copy link
Contributor Author

zvirja commented Dec 18, 2019

Thank you for all the time you spent on this and for quick response time - it was a pleasure to contribute ☺️

See you around!

@Kieranties
Copy link
Owner

@zvirja
Copy link
Contributor Author

zvirja commented Dec 18, 2019

Perfect! 🤝

Do you know whether some actions are required to consume that in Brew/Cake? Does it happen automatically when having a proper Brew import?

@Kieranties
Copy link
Owner

I believe the brew builds are bringing in the latest pre-release version by default - If not, you should be able to specify in your packages.config for cake to overrride.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants