开发者

Seemingly infinite stack trace in EF 4.0 and poor query performance under load

On a large EF 4.0 model (700+ entities), we are getting poor performance on System.Data.Objects.ObjectContext.CreateObjectSet(string). The call to this is triggered by a query like context.Users.FirstOrDefault(u => u.userId = 100).

The query performs well in general, but under load the query does not do well. We are running a 20 concurrent user load against a page that uses this query. The application for this page is under profiling mode i.e. we are using Visual Studio 2010 performance profiler while running this small load test. The profiler is using the "Sampling" mode.

The application is built with ASP.NET 4.0 / ASP.NET MVC 3.0 and is hosted on IIS 7.5 on a Windows 7 server when the load test is being run.

The profiling report shows a call stack that seems "infinite" i.e. there are a lot of calls to the below lines over and over.

System.Data.Mapping.DefaultObjectMappingItemCollection.LoadObjectMapping
    System.Data.Mapping.DefaultObjectMappingItemCollection.LoadAssociationTypeMapping
        System.Data.Mapping.DefaultObjectMappingItemCollection.LoadObjectMapping
            开发者_运维百科System.Data.Mapping.DefaultObjectMappingItemCollection.LoadAssociationTypeMapping

What could be the cause for poor performance and such infinite looking call stacks?


Another thing to try is the excellent Entity Framework Profiler - has saved us many headaches in debugging performance issues like these - gives you a lot more than SQL Profiler and you can see what queries/objects are created per ObjectContext and method/source line, etc - http://efprof.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜