Hi
Analysis of the performance of our method shows that there is a problem in XPO.
From profiling 70% of the time is the method FilterList. In this method most of the time are the methods ToUntypedPredicateand ToBoolLambda. They are called from XPBaseCollection.CreatePredicate and the decompiled code can not see them because they were probably substituted by the compiler inline. XPBaseCollection.CreatePredicate creates a method to filter the list items based on the Criteria, using methods of dynamic compilation, which is a costly operation. The problem is that XPBaseCollection.CreatePredicate called regardless of whether there are collection elements or not. In our use case add simple conditions in the presence of elements in collection before creating a filter vastly accelerate the performance of our methods.
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hello Sergey,
Thank you for contacting us. Would you please describe the issue in greater detail? The method you mentioned was implemented this way on purpose, and we need to know the problem in every detail to suggest an appropriate solution.
So, describe what task you wish to accomplish using the methods of your application demonstrated in the screenshot. Why do you want to accelerate the performance of these methods? Are you researching ways to optimize your code or did your users face a performance issue related to these methods?
Hello Uriah,
We have method which processes big data. This method takes approximately 2 hours, so we want to accelerate the performance of these methods. We are researching ways to optimize our code. We profiled our method, and saw, that DevExpress.Xpo.XpBaseCollection.FilterList takes 70% of all time. Method DevExpress.Xpo.XpoBaseCollection.FilterList create function for filtering list, and then call created function for each element from list.
But method DevExpress.Xpo.XpoBaseCollection.FilterList creates function also if list is empty. Creating function takes 90% of time of DevExpress.Xpo.XpoBaseCollection.FilterList work.
We attached a simple solution, which can demonstrate bad performance when we iterate list without elements.
internal class A : XPObject { private B _b; public A(Session session) : base(session) { } [Association("a-b"), NoForeignKey] public B B { get { return _b; } set { SetPropertyValue("B", ref _b, value); } } } internal class B : XPObject { public B(Session session) : base(session) { } [Association("a-b"), Delayed, NoForeignKey] public XPCollection<A> As { get { return GetCollection<A>("As"); } } } static void Main(string[] args) { XpoDefault.DataLayer = XpoDefault.GetDataLayer( @"Data Source=.;Initial Catalog=perf;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False", AutoCreateOption.DatabaseAndSchema); using (var uow = new UnitOfWork()) { for (int i = 0; i < 100000; i++) { var b = new B(uow); b.Oid = i; b.Save(); if (i%10000 == 0) { Console.WriteLine(i); } } uow.CommitChanges(); } using (var uow = new UnitOfWork()) { var coll = new XPQuery<B>(uow).ToList(); uow.PreFetch(coll, "As"); //start profiling foreach (var item in coll) { //FilterList takes 92% of time foreach (var a in item.As) Console.WriteLine(a.Oid); } //end profiling } }
Hello Sergey,
Thank you for the example. We can optimize the prefetch operation for the collection members of associations, and this improvement will indirectly improve the situation you described. However, this improvement will be added in version 15.1.8. We could not find the capability to add the corresponding changes to earlier versions. If you are fine with upgrading to version 15.1.8, I can provide you the link to the intermediate build for testing.
Hello Uriah,
Thanks for answer. We can update to version 15.1.8. Waiting fo the link…
Hello Sergey,
The intermediate build will be prepared in a few days. I will post a comment with the download link when it is ready.
Hello Sergey,
Use this link to download the intermediate build containing required changes: DevExpressComponents-15.1.7.15288.exe. As usual, we greatly appreciate your feedback.
Hello Uriah,
Ok, thanks.
Uriah,
We tested your build, so, the result is very good, your method no longer takes time. Thanks!
You are welcome, Sergey!
Please do not hesitate to contact us again in the future. We are always happy to help you.