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

Visual Studio hangs for several minutes when reorganizing/cleaning with Spade open #556

Open
mteknight opened this Issue May 16, 2018 · 8 comments

Comments

Projects
None yet
2 participants
@mteknight

mteknight commented May 16, 2018

Environment

  • Visual Studio version: Enterprise 2017 15.7.1
  • CodeMaid version: 10.4
  • Code language: C#

Description

Visual Studio hangs for several minutes when reorganizing/cleaning in bulk with Spade open. I've tested several times with around 20 classes open, app C#. I tried disabling the reorganizing feature and even the Spade code synchronization.
It only happens IF Spade is open, as when I closed it all worked well. It seems that when cleaning in bulk Spade tries to updated for each file and it becomes very slow, around 10 minutes to do all files.

Steps to recreate

  1. Make changes to many classes. In my case, I have changed their namespaces after moving to a folder;
  2. Enable Automatic Cleanup On and Open Spade having it docked (always open) somewhere;
  3. Click save all changes for all open classes. It will save each file while opening them on Spade, then reorganize/cleanup each and at some point, it starts hanging for a while on each file.

Current behavior

Same as Description above.

Expected behavior

When I close Spade, it saves and reorganizes/cleans up quickly all files. I'd expect it to be the same with Spade open, as when this process occurs Spade refreshing should be disabled. It should refresh again in the end for the last open file.

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented May 19, 2018

Thanks for reporting the issue. I have seen it as well. There isn't currently any logic that "suspends" Spade when bulk operations are beginning. I do expect the Spade window to be significantly more responsive when we move to the Roslyn APIs which can provide us change deltas vs. the current APIs which require a full rebuild (i.e. there's no change state, so every refresh is a full file refresh).

@mteknight

This comment has been minimized.

mteknight commented May 23, 2018

Well, then the current API requiring the full rebuild could be the reason it hangs. When is the new implementation with Roslyn API happening?
If it's that soon, a workaround that could fix it is suspending Spade updates until the bulk operation is done. Technically, it'd force it to update with the full rebuild only for the last file.

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented May 27, 2018

There isn't a current timeline. Roslyn is going to be far more helpful/powerful than the old APIs, but it does also require a very significant rewrite of a lot of functionality.

codecadwallader added a commit that referenced this issue Jun 9, 2018

Reduce the maximum wait time for building a code model from 30 second…
…s to 3 seconds when blocking the UI thread. Related to Issue #556
@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Jun 9, 2018

I looked into this and what I'm seeing is that while Spade is building the code model, the cleaning (and/or reorganizing) process is waiting for that code model to be built. It currently blocks for up to 30 seconds before giving up. As a short-term fix, I've reduced that maximum block from 30 seconds to 3 seconds so it will at least fail faster when this situation is hit.. reducing the UI impact.

I think a better/longer term fix would be to leverage Roslyn's async libraries (the older APIs are all synchronous).

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Jun 9, 2018

This change will be in the upcoming v10.5 release.. but I'm going to leave this issue open as it's not fully resolved.

@mteknight

This comment has been minimized.

mteknight commented Jun 10, 2018

Sounds good! I'll give another try with this new version to see how much it may impact my work. probably just 3s won't hurt much.

@mteknight

This comment has been minimized.

mteknight commented Jun 12, 2018

@codecadwallader I managed to give it a quick try today and this fix worked very well. I'll keep using it from now on again to see how it behaves with larger classes (for now I tested with very small dtos).
I expect it to be way faster when saving without hanging.

Thanks for that and keep up the great work!

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Jun 15, 2018

Great, I'm glad to hear it's helping some. It's not the best fix, but a band-aid is better than nothing. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment