22

Closed

Does anyone else have terrible performance with the editor in Visual Studio 2012?

description

(from https://typescript.codeplex.com/discussions/435257)

I have just started investigating TypeScript and the performance of the editor is horrid! It is so bad that I expected to see a flood of complaints but haven't been able to find any. I'm using the default template in VS2012 with a single code file that is only 100 lines long. The formatter (which I understand is written in TypeScript) takes an unacceptably long amount of time to indent and format code. For example, hitting enter 4 times at the bottom of the file which changes nothing in the file results in the following status messages:

Smart Indenting task took more than 1 second(s) to complete. Try again later.
Formatting task took more than 2 second(s) to complete. Try again later.
Smart Indenting task took more than 1 second(s) to complete. Try again later.
Formatting task took more than 2 second(s) to complete. Try again later.
Smart Indenting task took more than 1 second(s) to complete. Try again later.
Formatting task took more than 2 second(s) to complete. Try again later.
Smart Indenting task took more than 1 second(s) to complete. Try again later.
Formatting task took more than 2 second(s) to complete. Try again later.

The whole process of adding four blank lines takes 12 seconds. I've tried the Microsoft fix of restarting and reinstalling with no luck. I'm running a quad core i7-950, so I'm doubting it's that.

Am I the only one with this problem?

file attachments

Closed Jun 13, 2013 at 6:21 PM by RyanCavanaugh
Fixed in develop branch

comments

middlewest wrote Mar 4, 2013 at 2:48 PM

I have a clear way to reproduce the problem.
I am using TypeScript v.0.8.3
  1. Somewhere in a method in a class type the following:
var data = {}
  1. Now place your cursor between the curly brackets and press ENTER x2 times.
var data = {

}
  1. Get your cursor to the blank line between the curly brackets and type
var data = {
    value: 3
}
  1. Make sure your cursor is at the end of the "value: 3" line. Type ";" (semicolon). So your code looks like:
var data = {
   value: 3;
}
This is where (at step 4) the VS starts saying: Formatting task took more than 2 second(s) to complete. Try again later.

If you look at the running processes there will be another instance of "devenv.exe" which needs to be taken down manually because when you close your VS that process remains there running.

middlewest wrote Mar 4, 2013 at 3:07 PM

another test case that fails is when you type semicolon instead of comma as a separator in the list of the constructor parameters

Grajkowski wrote Mar 4, 2013 at 4:31 PM

Another test case that triggers poor performance:
class Foo extends Foo { }
//Formatting task took more than 2 second(s) to complete. Try again later. 

RyanCavanaugh wrote Mar 5, 2013 at 12:00 AM

Tracking for 0.9.x.

RyanCavanaugh wrote Mar 5, 2013 at 12:09 AM

Confirming middlewest's 'data' repro as a very good way to check this

rb126 wrote Mar 5, 2013 at 2:03 PM

I logged the following as a separate report that was marked a duplicate. Here's my reproducible (for me!) example that causes VS 2012 SR1 (with TS 0.8.3 and Web Essentials extension) to hang/lock up completely:

(1) Create a new HTML with TypeScript application.
(2) Open app.ts, Select All, then paste the following code over the top of the entire file and save it:
module M {
    export static class S {
        static f(): bool { return false; }
    }

    export class D extends S {
    }
}
For me, VS locks up and clicking anywhere in the editor window does nothing. Sometimes using the arrow keys lets you cursor around and remove the syntax error (the "static") and that then unlocks VS.

middlewest wrote Mar 8, 2013 at 12:37 PM

One more test case:

The following snippet
module foo {
    class Bar {
        doSomthing() {
        }
    }
}
breaks on typing ";" (semicolon) between the method brackets and the curly bracket of the method body
module foo {
    class Bar {
        doSomthing() ;{
        }
    }
}

middlewest wrote Mar 8, 2013 at 12:40 PM

Another test case

The following sinppet
module foo {
    class Bar {
        doSomthing() {

        }
    }
}
breaks on inserting ";" (semicolon) between method parameter list brackets
module foo {
    class Bar {
        doSomthing(;) {

        }
    }
}

middlewest wrote Mar 8, 2013 at 12:43 PM

Yet another test case

The following snippet:
module foo {
    class Bar {
        doSomething() {

            }
        }
    }
}
breaks on inserting a semicolon like this:
module foo {
    class Bar {
        doSomething() {
;
            }
        }
    }
}

ML33 wrote Mar 8, 2013 at 4:03 PM

Thanks for the repro, middlewest. Seeing the same thing here...

paulb wrote Mar 8, 2013 at 4:09 PM

We're going to take a look, thanks for all the repros!

mhegazy wrote Mar 8, 2013 at 5:32 PM

This is caused by an infinite loop in the logic that detects the extent of the statement that needs formatting after semicolon. we did change that logic in a recent bug fix. I believe i have a fix for it. I am not sure yet how or when this fix will be released. but I presume sometime soon. for now, go to your Tools\Options dialog then to Text Editor\Typescript\Formatting and check off "Format completed statements on ;". this will disable formatting after semicolon obviously, but should make VS usable again; this should not affect other formatting trigger points like new line and closing parenthesis.

mhegazy wrote Mar 8, 2013 at 5:34 PM

This is caused by an infinite loop in the logic that detects the extent of the statement that needs formatting after semicolon. we did change that logic in a recent bug fix. I believe i have a fix for it. I am not sure yet how or when this fix will be released. but I presume sometime soon. for now, go to your Tools\Options dialog then to Text Editor\Typescript\Formatting and check off "Format completed statements on ;". this will disable formatting after semicolon obviously, but should make VS usable again; this should not affect other formatting trigger points like new line and closing parenthesis.

danijel wrote Mar 8, 2013 at 8:13 PM

Same problems encountered... let us know if there is any bug fix for this.

djarekg wrote Mar 11, 2013 at 3:45 PM

I am also experiencing the vs2012 ts editor freezing anywhere from 10-45 seconds when editing large ts script files. I tried breaking my ts file up into 7 different ts files and still am experiencing the same problem. It's very painful and impossible to work with. I can't get anything done. It is taking way to long.

djarekg wrote Mar 11, 2013 at 4:11 PM

I too am experiencing the same problem w/ large ts files. I tried breaking my ts file up into smaller ones, but still the same problem. Keep in mind that I have to reference all the ts files I broke up. I have actually tried turning off all formatting in the options and still to no luck.

rb126 wrote Mar 11, 2013 at 4:45 PM

@djarekg: I have 3,300 lines of TypeScript in 25 files. I only hit this bug when there are errors in the TypeScript. Valid TypeScript seems to build fine and not cause Visual Studio to hang.

djarekg wrote Mar 11, 2013 at 5:44 PM

@rb126 My ts file had about 6000 lines of code, which I now have split up into 9 ts files. And to no luck the same issue persist. This issue started at the end of last week. I don't know if I hit some threshold or what, but it is unbearable.

If it gets to bad, which it almost always is when it happens. I close and re-open VS and it goes away for a lil bit. But, within 5 mins or so it starts slowly getting worse again until I can't take it anymore and restart VS.

mhegazy wrote Mar 11, 2013 at 6:49 PM

djarekg wrote Mar 11, 2013 at 8:29 PM

I downloaded the fix to release 0.8.3 today and swapped out the typescriptservices.js with the one included in the latest fix and it hasn't fixed my issue. I've noticed that the VS IDE freezes more often when I click around with the mouse in the ts editor. It also does it when using the keyboard to type/navigate the ts file, but it definitely freezes the worst and almost all the time once it starts freezing when using the mouse in the ts editor.

rb126 wrote Mar 11, 2013 at 9:23 PM

On one of our projects we had around 30 TypeScript files with lots of errors in them (we were converting from JavaScript). Every time I saved a file and a build was initiated 30-odd copies of tsc.exe plus the same number of conhost.exe processes leaked, consuming up to 2GB or RAM. It seemed that these processes were started but failed to terminate. A colleague on a machine with 4GB of RAM rapidly found that his whole machine hung after a while as it started swapping. Fortunately for me I had 24GB RAM in my machine so I was able to make progress and make some changes and saves, losing 2GB of available RAM at a time, before available memory ran short. Closing and re-opening Visual Studio seemed to clear up all these leaked processes, allowing me to fix errors in batches, restarting VS periodically to release leaked memory. Eventually the number of errors was reduced such that these copies of tsc.exe stopped leaking and now we can all edit the code again.

Paul0515 wrote Mar 12, 2013 at 9:32 AM

how to obtain a new LKG which includes this fix?

mhegazy wrote Mar 12, 2013 at 8:27 PM

@djarekg a couple of questions:
  • When you said you swapped the typescriptservices.js included in the fix, I am assuming that you did build your own copy not that you used the checked in LKG version, is that correct?
  • Does the slowness change when you enable/disable formatting features through tools options?
  • Does it only happen when you hover over symbols to get type information or is that visible in other Language Service features like completion after dot, indentation on close curly.. etc.
@Paul0515 LKG updated in branch release 0.8.3:
http://typescript.codeplex.com/SourceControl/changeset/e44dbae94e04

djarekg wrote Mar 12, 2013 at 9:03 PM

◾When you said you swapped the typescriptservices.js included in the fix, I am assuming that you did build your own copy not that you used the checked in LKG version, is that correct?

Answer: I downloaded the latest LKG source and copied the typescriptservices.js from that bin directory and overwrote the one in the VS2012 directory per instructions... http://blogs.msdn.com/b/typescript/archive/2013/01/29/trying-the-latest-typescript-build.aspx

◾Does the slowness change when you enable/disable formatting features through tools options?

Answer: I disabled on formatting options and that didn't make any difference.

◾ Does it only happen when you hover over symbols to get type information or is that visible in other Language Service features like completion after dot, indentation on close curly.. etc.

Answer: It slowly gets worse as I work in the ts files. Within about 2-3 mins after restarting VS it starts to get worse and worse again. The navigating around and editing the ts file with the keyboard does not freeze VS as much as navigating around with the mouse in the ts file. Once the freezing starts to get bad, anytime I click around the ts file w/ the mouse it freezes everytime. For example once the freezing has started again I may be able to edit a couple of words or create a few new lines of code before it freezes, but then as soon as I click in that same ts file w/ the mouse it freezes up for quite a while. And during this time of freezing the VS cpu process is running at about 53% until it stops.

I have removed a lot of the references from my ts files to other ts files and created interfaces for classes that exists in other ts files that I am no longer referencing and that seems to have helped a lil....I guess.

djarekg wrote Mar 12, 2013 at 9:03 PM

for my second answer I meant to say...

Answer: I disabled ALL formatting options and that didn't make any difference.

rb126 wrote Mar 12, 2013 at 10:28 PM

@djarekg: Have you checked the RAM usage on your machine? Is it leaking memory like I had happen on my project, each time a build is initiated (possibly in the background)? If so you'll soon start swapping, which will cause everything to grind to a halt. And shutting down and restarting VS would produce a temporary fix like what you see because that leaked memory would be reclaimed (until the memory usage starts creeping up again). A colleague of mine saw exactly this behaviour - after just a minute or two's use the VS and the machine started grinding to a halt and restarting VS solver the problem. It turned out to be leaking tsc.exe processes, easily visible in Task Manager.

djarekg wrote Mar 13, 2013 at 12:30 PM

@rb126 I am pretty sure it's a memory leak, but it doesn't appear to be related to the ts complier process (but don't quote me on that). When VS is hanging and you look at the running threads in Process Explorer for the devenv.exe process, the thread "clr.dll!DllGetClassObjectInternal" is always consuming 50-60% of the cpu and then when VS stops hanging, that thread's cpu consumption drops.

djarekg wrote Mar 14, 2013 at 2:17 PM

Here is a screen shot of the devenv.exe process and the running threads sorted by CPU consumption using process explorer when VS is in the middle of freezing due to TS. Hope this helps.

djarekg wrote Mar 14, 2013 at 2:22 PM

I also opened up a new issue (#815) about intellisense getting really really slow too. Not sure, but seems like it may be related to this same problem here.

jonturner wrote Mar 14, 2013 at 2:47 PM

@djarekg - what is the size of the project you're working with when the intellisense gets slow?

djarekg wrote Mar 14, 2013 at 3:20 PM

If you mean file size the total size of all my TS files (includes TS files being referenced) is 343KB. I attached to this issue a screen shot of the devenv process which should show its memory consumption and cpu consumption during the issue as well the screen shot image is called "VS Process Screen Shot.JPG"

jonturner wrote Mar 14, 2013 at 3:42 PM

@djarekg - in terms of project size, how many lines of code is that?

I ask because the current TypeScript language service can only handle between 8,000 - 10,000 lines before you will notice significant slowness. We're working to dramatically improve that limit in the coming release, but for the 0.8.x series that's the most it will comfortably handle for any one project.

djarekg wrote Mar 14, 2013 at 5:05 PM

Just my project TS files totals 7888 lines. If you include the jQuery and Kendo declaration files because they are be referenced, that's adding another 5713 lines of code to the 7888. And obviously more if I were to also include other smaller declaration files for libraries that I use in my project (i.e. ampliy, toastr, etc.).

I really hope you guys get this resolved quickly for an 8-10k line of code limit it pretty easy to reach and this "slowness" if unbarable. Its hard to get anything done. What should take me 10 mins is taking me 30 mins to do. That's absolutely crazy.

Do you guys have any fixes related to this in your development branches yet that I could try using. I would rather deal with other bugs then have to work with a VS studio that freezes every 30 secs for 30-60 secs at a time?????

jonturner wrote Mar 14, 2013 at 5:41 PM

@djarekg - for what I described, you should see some slowness, but you shouldn't be seeing long pauses. If you see those, it sounds like this is a different issue that we should track down. I just wanted to make sure you weren't trying to do a 100k+ line project, because then you would be seeing substantial delays.

Also, have you tried the same project in 0.8.2 to see if the delays are present? That would help give us another data point as to when it was introduced.

paulb wrote Mar 18, 2013 at 11:21 PM

@djarekg are you running WebEssentials or another extension for Visual Studio. Do you have Compile on Save enabled either in the TypeScript or the WebEssential options?

djarekg wrote Mar 19, 2013 at 12:42 PM

@paulb I am using Web Essentials and I have WE compile on save turned on and the TS compile on save turned off.

My last comment I said that I created declaration files for all of my TS files that just has my public APIs and it seemed to fix my slowness problem w/ VS, but yesterday afternoon it started slowing up again. It was quite as bad, but was still freezing up. Referencing the declaration files instead of the actual TS has reduced the number of lines from roughly 7800 to 2346.

billti wrote Mar 19, 2013 at 10:07 PM

@djarekg Thanks for persevering and taking the time to post your updates. We really want to get this resolved. At this point, looking back over the thread and having investigated similar issues, I see two candidates a likely causes (assuming you have applied the formatting fix discussed in this thread)
  1. Issues with Web Essentials 'compile-on-save' (or other conflict). Is it possible for you to uninstall Web Essentials to see if you can repro (should be really quick and easy to uninstall, then reinstall after testing).
  2. Some other syntax issue causing crashing/looping we are not aware of. Are you seeing this in all projects? Or just one project? Are you able to repro the issue with a different code base? If not, are you able to reduce the problem project to the minimal problematic code?
Sorry you are hitting issues trying to use TypeScript. We'll try and get this resolved ASAP.

djarekg wrote Mar 20, 2013 at 1:35 PM

@billti

I mentioned yesterday that it seemed like the issue was still occurring even though I had created declaration files for each of my TS files and referenced those instead of the actual TS file and this was based on some slowness I experienced Monday, but it was for only a brief time and I don't think it was related to TS now thinking back. All yesterday I didn't have any problems. The TS editor was working fast (i.e. intellisense and code editing). So, I strongly believe it has to do with the number of lines of code, which was mentioned by another one of your team members that I was talking to last week on this post. Because, once I created declaration files for each of my TS files and reference those instead, the issue has gone away.

Unfortunately, I have no other projects even close to this size in regards to using TS. I have another experimental projects that I toy around with, but they are much smaller and I have not encountered any TS editing issues with those projects.

Also, yes I am using the latest LKG 0.8.3 (March 12th build)

idev71 wrote Mar 21, 2013 at 8:00 AM

middlewest, thanks for the easy reproduction.
I have the same odd behavior here. :-(

Are there any plans or hints for a solution?

middlewest wrote Mar 22, 2013 at 7:53 AM

@idev71
Uncheck formatting on ";" in the Options.

middlewest wrote Mar 22, 2013 at 7:57 AM

@djarekg

I started getting freezes in TypeScript right after I installed WebEssentials.
After removing it everything went back to normal.
Just get rid of that crap.

MichaelShakarov wrote Mar 24, 2013 at 1:21 PM

I had the same issue since I've installed "productivity power tools 2012" extension. Disabling the power tools fixed it for me.

middlewest wrote Apr 1, 2013 at 7:01 PM

Yay! The semicolon issue has been fixed in the latest hotfix: http://blogs.msdn.com/b/typescript/archive/2013/04/01/announcing-typescript-0-8-3-1.aspx

danieljsinclair wrote Jul 25, 2013 at 3:57 PM

I get really terrible performance with TypeScript 0.9 in VS2012 after upgrading from 0.8 too. The metadata seems to struggle to overcome compile errors that were fixed ages ago (close and reopen the file fixes this) and intellisense takes several seconds to come up.

Anupheaus wrote Apr 17 at 10:04 PM

Sorry to bring this old thread back to life but I'm getting the exact same errors in TS 1.0 VS2012, don't really know how to reproduce but it is happening usually when I create a new enum. The only solution I have found so far is to close VS and re-open it (obviously not ideal) but it gets rid of the issue for a while.

ZSAndrewLong wrote Mon at 3:24 PM

I'm joining in on the this bug is dead bandwagon.(I guess this could be an unrelated issue)

ZSAndrewLong wrote Mon at 5:42 PM

*not dead