0

I have been using T4MVC for quite a while now. I have a high traffic site that keeps growing every year and we have noticed some performance issues. We are using LeanSentry and we are seeing these type of CPU spikes with our T4MVC URL generation. Below is one high CPU userage snapshot with these codelines made available.

Is this a valid concern or something else?

enter image description here

Example of performance hit code generating URLS

protected virtual void PopulateScheduleGameLinks(List<ScheduleGroupDisplay<ScheduleGameDisplay>> gamesGroup)
        {
            gamesGroup.SelectMany(q => q.Games)
                .ToList()
                .ForEach(
                    q =>
                    {
                        foreach (var asset in q.Assets)
                        {
                            asset.Url = Helper.GetFilePath(asset.Url, asset.Version);
                        }

                        if (q.ExternalId != null)
                        {
                            long ticks;
                            if (long.TryParse(q.ExternalId, out ticks) &&
                                q.StatisticsType != StatisticsType.MyStatsOnline &&
                                q.StatisticsType != StatisticsType.ScorebookPlus &&
                                q.Assets.All(t => t.Type != GameAssetType.Scoresheet))
                            {
                                q.Assets.Add(new ScheduleGameAssetDisplay
                                {
                                    Type = GameAssetType.Scoresheet,
                                    Url = Url.Action(MVC.EventReports.GameStatistics(q.EventId, null, q.Id.ToString()).AddReportPdf().AddRouteValue(Config.QueryString.Version, ticks))
                                });
                            }
                        }

                        q.LiveGameLink = this.BuildScoreCastUrl(q.StatisticsType, q.ExternalId, null, q.Id, q.EventId, q.SportHost, q.EventName.GenerateSlug());
                        q.CalendarLink = Url.Action(MVC.Calendar.Game(q.Id));
                    });

        }

enter image description here

enter image description here

Mike Flynn
  • 22,342
  • 54
  • 182
  • 341

1 Answers1

0

T4MVC itself is not doing much here beyond calling UrlHelper.RouteUrl, which is part of MVC. So I suspect you would see the same thing if you were to use UrlHelper.RouteUrl directly to generate URLs without using T4MVC.

It could be that this MVC method is somewhat expensive, and that the perf issue comes as a result of having too many calls to it to render a single page (e.g. if the page is very complex and contains many generated URLs).

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • I am running Perfview and see the same thing with long processing times. I go through large lists of say 1000 games and attach strongly typed links to them. This may not be the best option for lots of url creations. Yes T4MVC isnt the direct cause of the performance hit, but it points to other code that is. I updated the question with example code. – Mike Flynn May 17 '21 at 22:14