Home

Slow Intellisense with Large Extension-Method Namespaces

I noticed the other day that my LINQPad intellisense had gotten very slow. It was taking 1.5-2 seconds to show the intellisense popup when it would normally be almost instantaneous. All of my references are in the local drive (C:\) and none of the references have subfolders that have to be recursed.

Turns out that I could track down the performance issue to a single namespace in my default query references. If I remove the one namespace, the performance returns back to instantaneous for the intellisense. This particular namespace contains a static class (TranslationExtensions) with extension methods auto-generated by a T4 template, which generates helper methods for each table in our ORM layer - for a total of about 410 extension methods. When I try to bring up the intellisense for this one static class, it takes 4-5 seconds to load.

Is it possible you could check and see if there's a performance optimization you can make for extremely large static classes, containing hundreds of methods? For comparison, in VS2010, the intellisense loads almost instantly even for that class, so I'd rather not have to refactor it into separate classes.

Thanks!

Comments

  • The short answer is that I expect the problem to go away later this year when LINQPad moves to Roslyn.

    The long answer is that there's probably no simple fix; the slowdown is not merely a result of having lots of extension methods. The following doesn't cause a problem:
    "public static class BloatedExtensions\r\n{\r\n" +
    string.Join ("\r\n", 
    	Enumerable.Range (0, 500).Select (e => "  public static string Foo" + e + "(this string s) {return s;}")) +
    "\r\n}"
    What I expect is the case is that your extension methods include generic delegates that require type inference for binding. Running the type inference engine over and over again on each candidate method would account for the problem. Am I correct?
  • Is this a problem only when showing intellisense? Could an option to disable temporarily intellisense suppress this issue?
  • edited October 2015
    I can confirm that this problem has been resolved with LINQPad 5+Roslyn (Yay!)

    However, I seem to have a new problem with an asynchronous delay in the Intellisense popup. I'm used to (from Visual Studio) typing the name of a class/method and the intellisense popping up a list as I'm typing. It seems to be 50-50 in LINQPad 5 whether the popup window actually shows, and I'm having to retype the trigger character ('.'), or manually press CTRL+Space to show the intellisense list. Kinda annoying really.
  • Does this happen always, or just with certain queries?

    If you type the following:

    "".

    does the autocompletion list come up only half the time for you?
  • edited October 2015
    It happens for any query. It seems to happen more often with more complex queries or inside nested lambda expressions. I tried retyping "".as over and over again in a blank query and once in awhile, it would not popup. Sometimes though it would popup a split second later, but because I'm no longer immediately after the period character, it doesn't recognize what I've typed so far, so it's not doing partial matches. Of course if I simply retype the . again it comes right back to normal

    For method names it's not as big of a deal, because a simple CTRL+Space will bring it back. It's more annoying when it happens for method signatures, because the only way to get it to pop up again is to delete everything and retype the left parenthesis... and of course if it happens multiple times in a row during a fairly complex method signature where you're relying on 4-5 intellisense lookups back to back, I end up with a mess of random partially written wrongly-cased expressions that I have to cleanup.

    I'm used to Visual Studio where it shows and responds reliably every single time, and if there is a delay for any reason, it's a *synchronous* delay so that it stops typing for a split second, then pops up and retroactively applies all the keystrokes you hit before the delay. It appears LINQPad is doing some sort of *asynchronous* intellisense popup where if it doesn't respond immediately between the two keypresses, then when it does popup it is not properly in sync with what has just been typed. It messes up my typing flow enough that I just about end up turning it off so at least the behavior is consistent!

    Note that my default query references are about 40 files all on a network drive, and about 60 namespaces, if that makes any difference.
  • Note I would also be willing to do a secure shared session to demonstrate if you would like.
  • It sounds like you're describing 3 distinct problems:

    1. Sometimes autocompletion does not pop up at all
    2. When it pops up, it sometimes ignores recent keypresses and matches incorrectly
    3. There's no way to bring up method signature lists with a keypress

    Problem #2 has been identified and is fixed in the most recent beta, which you can download from http://www.linqpad.net/download.aspx

    Problem #3 - have you tried Shift+Control+Space?

    Problem #1 - could this be related to the 40 references on the network drive that you have in all queries? Does the problem go away if you remove those references?
  • #2 - thanks!
    #3 - I was not aware of that shortcut.. awesome!
    #1 - yes, the problem goes away if I remove all the references. The issue seems to be related to having a large number of references and/or a complex code expression. It's tolerable given the solutions provided to #2 and #3.

    Thanks as always for your quick and helpful response! :)
Sign In or Register to comment.