Thank you. I did not have time today to produce a minimal repro, but your unit test basically covers my scenario. I appreciate you adding performance regression tests.
Hi, the slowdown appears to be in calling the UpdateNavigationEntries() function. With my changes below, the performance is back to 650ms or so. It seems to call that function many times per singular entity which I think is the real problem.
I have this at the top of the ef core navigation helper class:
protected Dictionary<string, MyAbpEntityEntry> MyEntityEntriesNavUpdated { get; } = new();
Then this in DetectChanges
:
if (!MyEntityEntriesNavUpdated.ContainsKey(entryId))
{
myAbpEntityEntry.UpdateNavigationEntries();
MyEntityEntriesNavUpdated.Add(entryId, myAbpEntityEntry);
}
So it only runs that function once per entity entry, and that also fixed the performance back to 650ms. But I do not know if this would cause any bugs. I don't know the use case of all of this navigation helper code, nor do I have access to your guys' tests.
I will try today. For what it's worth, the query in 9.0.4 took ~600ms. If I add in this code to EfCoreNavigationHelper in ChangeTracker_Tracked:
if (e.Entry.Entity is Partner or PartnerStudent or Student) return;
Effectively ignoring everything that happens in EntityEntryTrackedOrStateChanged and DetectChanges, it takes ~300ms. That is the baseline I'd expect performance to be at, or close to. Not double.
I appreciate your assistance.
Hi, that is definitely a lot better - now on my local machine (very powerful), the query takes 1.36s instead of several minutes. That still feels pretty slow given how simple the query is, but it is ok for now. I would like to see some work done in the next major version of ABP around performance.
Thank you.
Thanks. Is there anything I can do until 9.2.3 is released? When will that be? I saw your unit test - you have reproduced the problem I was having. Any minimal repro I send you would look exactly like that test.
Thank you, I appreciate it
Thank you. I'm confident you'll see the performance issue if you do a test with one blog that has several thousand posts.
If you don't see the performance issue with that test, I'll produce a minimal repro in the morning. Thanks.
I edited my response after I took a closer look at your test. Please see my edit where I point out the difference in the scenarios.
Hi, that is not my experience. I'm on 9.2.2. When I revert to 9.0.4, the performance is back to normal. When I use 9.2.2, but the 9.0.4's version of the abp ef core navigation helper, the performance is back to normal. When I simply use 9.2.2, the performance is horrible.
Additionally, your unit test is not accurate to my problem. Please write a test where there is a single blog with several thousand posts, then try to load that blog including those posts. Your test as it stands is 5000 blogs, each with one post.
Hi all, I recently upgraded my project from 9.0.4 to 9.2.2. I have the following entities:
Partner - has a List<PartnerStudent> PartnerStudent - Entity with PartnerId, Partner, StudentId, Student. Key being [PartnerId,StudentId] Student - has a List<PartnerStudent>
It's a very standard many-to-many relationship. One of my partners has 2000 students. When I do .Include(x => x.PartnerStudents)
when querying for that specific partner, the app slows to a crawl. This is ONLY if I have tracking on. If I do .AsNoTracking()
, it is fine. Something you guys changed recently in AbpEfCoreNavigationHelper, or somewhere near it, has caused this performance regression. It used to be immediate, and now it takes several minutes, or it just crashes the api. I replaced the service locally with the 9.0 versions I found on github and it is normal. I then use the 9.2 versions and it is incredibly slow, again, if it even manages to finish at all. I'm talking in the realm of 5-10+ minutes, or again, just crashes the app. Please investigate and fix. This is not the first time we have had issues with the AbpDbContext-related code and performance issues - please add more thorough testing to your release processes as well. I want to stay on the latest versions of ABP, but it is getting scarier to upgrade when stuff like this happens.
I've gotta assume it's this: https://github.com/abpframework/abp/commit/17c4e6be5364c13fe788216d68dbcab8a5b63fac