Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On local PC IIS and Browser maxes out CPU with large result set

I just upgraded to VS 2013 and also started a new MVC project, and am being faced with 99% CPU usage for a couple minutes by IIS while debugging on my local PC. (Happens in both Release and Debug mode) I just realized that the problem is proportional to the number of lines returned by by Linq Query. If I use Take(1) or Take(10) it's fine. If I use Take(100) the problem occurs.

Here is my actionresult (with private info altered):

    public ActionResult Summary(string daystoshow, DateTime? day = null)
    {
        int daysToShow = daystoshow.ToSafeInt();
        if (daysToShow < 1) daysToShow = 2;
        if (day == null) day = Convert.ToDateTime("4/14/2014");  
        SummaryViewModel m = new SummaryViewModel();
        string warnings = "";
        var ef1 = new carshowEntities();

        DateTime dayAtMidnight = Convert.ToDateTime(((DateTime)day).AddDays(daysToShow).ToShortDateString());

        var diplayItems = (from x in ef1.islands
                             join y in ef1.cars on x.serid equals y.serid where x.dt==12  
                             join z in ef1.ITEMS on y.serviceno equals z.ITEMNO
                             join x2 in ef1.islands on x.serid equals x2.serid where x2.dt==8 
                             join i in ef1.INVOICES on x.carStyle equals i.carStyle where i.STATUS==8
                             where x.LiscenceDate > day && x.LiscenceDate < dayAtMidnight
                             orderby x.LiscenceDate, y.serviceno, x.serid
                             select new ReturnedItem()
                             {
                                 CarOrderDate = (DateTime)x.LiscenceDate,
                                 serial = x.serid,
                                 ItemCode = y.serviceno,
                                 Description = z.Color,
                                 DateSold = (DateTime)x2.LiscenceDate,
                                 ID = i.IX_ID
                             }).Take(100).ToList();



        m.daystoshow = daysToShow;
        m.day = day;
        m.diplayItems = diplayItems;
        m.warnings = warnings;
        return View(m);
    }

I haven't found any other posts that describe the exact circumstances here.

1) When the site is published, it works perfectly fine from the server.

2) CPU usage goes up to 99% when running my MVC project in debug mode.

3) The problem does not happen if I publish locally.

4) This happens in both IIS and IIS Express when run from VS in Debug or Release mode.

5) It doesn't happen with other sites, just this one project so far.

6) It's a simple project, one actionresult, and one page with a table of about 200 lines, populated with a Linq query.

Is there any way for the debugger to at least show me what it's doing?

EDIT:

With further investigation, I notice that if I wait 2 minutes the CPU comes back from IIS, but THEN the Web Browser (Firefox or Chrome) takes up 99% CPU for another 2 minutes.

like image 820
Dave Avatar asked Dec 19 '22 14:12

Dave


1 Answers

I found that the solution was simply to turn off "Browser Link" which was a new feature in VS 2013, after much debugging and searching.

Browser Link can be turned off in the toolbar by clicking the down arrow on the icon that looks like a refresh button.

Browser link is some way of making changes to the page in the browser itself, which seems to be CPU intensive, so doing that with a large number of elements causes the CPU to spike.

like image 53
Dave Avatar answered May 14 '23 07:05

Dave