Print Page | Close Window

Slow Saves

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1483
Printed Date: 17-Apr-2025 at 10:27am


Topic: Slow Saves
Posted By: mbevins1
Subject: Slow Saves
Date Posted: 21-Sep-2009 at 6:48am

When ever we save anything, the very first time we call entityManager.SaveChanges, it take a long time. After checking out the log files, I notices these two entries.

Unable to locate an implementation of: IdeaBlade.EntityModel.Server.IEntityServerSaving
Unable to locate an implementation of: IdeaBlade.EntityModel.Server.IEntityServerSaved

Could this be why it is taking  long time to save?  Also, how do you implement these because I added them to my save class and I still received these messages?

Here is what I added:

Added IEntityServerSaving, IEntityServerSaved to my Save Class


public class SavingService : EntityBaseService, IEntityServerSaving, IEntityServerSaved

Then added these 2 methods

public void OnSaving(EntityServerSavingEventArgs e)

{

if (!e.Principal.Identity.IsAuthenticated)

{

e.Cancel = true;

}

}

public void OnSaved(EntityServerSavedEventArgs e)

{
}



Replies:
Posted By: GregD
Date Posted: 21-Sep-2009 at 12:59pm
In addition to implementing the interfaces, you must list the assembly where they reside in the list of top-level (not edmKey) probe assemblies in the app.config file.

Re the performance issues:

There is a performance hit the first time DevForce engages the Entity Framework; both EF and DevForce need to set up their metadata.  There should not be any appreciable performance hit associated with probing for the IEntityServiceSaving and IEntityServiceSaved classes, whether or not they're found. But we'll check into it.



Posted By: mbevins1
Date Posted: 22-Sep-2009 at 4:16am
I added it to the app.config file and we are no longer getting the error. 
 
So, in addition to the first time devforce starts up and you log in, the very first time you save you will see this delay? The reason this is an issue is due to it takeing over 10 seconds the first time and then everytime after that it is fine.
 
 


Posted By: GregD
Date Posted: 22-Sep-2009 at 10:03am
It's not the first time you save: it's the first time you hit the Entity Framework. Could also be a data retrieval.


Posted By: mbevins1
Date Posted: 22-Sep-2009 at 10:10am
This is actually when we save too, at the time we are saving we have already hit the framework and have retrieved some data.


Posted By: pucsoftware
Date Posted: 23-Sep-2009 at 12:59pm
We are experiencing this exact behavior too. The first save with the entity manager takes 5-10 seconds to complete. To echo mbevins1, why is this still happening after we've retrieved data from the framework? GregD, is there a trick to initializing the EF during application load so that the user can expect the delay as a normal part of application start-up?

-------------
puctx


Posted By: kimj
Date Posted: 23-Sep-2009 at 7:36pm
We have long thought that the only performance hit was in the first time the EF metadata was loaded as EF performed view generation.  Based on testing today with a customer's database where the hit was 20-30 seconds for both the first query AND the first save, we now think otherwise. 
 
The workaround is to use pre-generated views, which you can read about here - http://msdn.microsoft.com/en-us/library/bb896240.aspx - http://msdn.microsoft.com/en-us/library/bb896240.aspx .  This is actually pretty easy to set up, and can improve performance dramatically for both the first query and the first save performed.
 
We'll be investigating further why the double hit is occurring and what we can do to mitigate it.
 


Posted By: skingaby
Date Posted: 24-Sep-2009 at 8:36am
There is a wrinkle when pre-generating views for Entity Model projects with embedded metadata. (And it is definitely easier to work with embedded metadata in and Ideablade solution.) I posted an explanation here: http://onemanwenttomow.wordpress.com/2009/09/24/pre-generating-entity-framework-views-with-embedded-metadata/ - Pre-Generating Entity Framework Views with Embedded Metadata



Print Page | Close Window