New Posts New Posts RSS Feed: BaseEntity.OnPropertyChanged--Performance Hit
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

BaseEntity.OnPropertyChanged--Performance Hit

 Post Reply Post Reply
Author
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Topic: BaseEntity.OnPropertyChanged--Performance Hit
    Posted: 10-Oct-2007 at 9:27am
I highly reccommend the ANTS Profiler from Red-Gate. It helped me with my performance problem and pointed dirtectly to the OnPropertyChanged which led me to the solution above. It's a great tool.
Back to Top
PJones View Drop Down
Newbie
Newbie
Avatar

Joined: 10-Oct-2007
Location: United States
Posts: 10
Post Options Post Options   Quote PJones Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 8:56am
I found the problem, I wasn't referencing IdeaBlade.Verification.  Once I did the property showed up as in your example.
 
Unfourtunately, I still have a huge performance issue writing bulk data.
 
Thanks,
 
Pete
Back to Top
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 8:42am
That's odd, here is the actual line of code I use:

MainPm.Manager.VerifierEngine.Enabled = False

Of course, I have defined MainPM as a class in my application which returns the primary perstistance managger through the Manager property. The following is the class:
 

''' <summary>Application's main PersistenceManager. Initializes. See <see cref="MainPm.Manager"/>.</summary>

Public NotInheritable Class MainPm

''' <summary>Do not allow new MainPm instances.</summary>

Private Sub New()

End Sub

''' <summary>Application's main PersistenceManager.</summary>

Public Shared ReadOnly Property Manager() As PersistenceManager

Get

If msManager Is Nothing Then

Initialize()

End If

Return msManager

End Get

End Property

Private Shared Sub Initialize()

msManager = PersistenceManager.DefaultManager

Model.Common.EntityTypeInfo.DefaultPersistenceManager = msManager

EntityAdapter.DefaultPersistenceManager = msManager

UpdateAuditColumnsOnChange()

End Sub

''' <summary>Update entity audit columns everytime the entity changes.</summary>

Private Shared Sub UpdateAuditColumnsOnChange()

msAuditColumnManagers = New AuditColumnManagerCollection(msManager)

End Sub

#Region "IsClientProcess"

''' <summary>Get or set if executing on the client.</summary>

Public Shared Property IsClientProcess() As Boolean

' No threading worry because only set once and always in the same direction.

Get

If msIsClientProcess.HasValue Then

Return msIsClientProcess.Value

End If

IsClientProcess = False ' assume is server process until know otherwise.

Return msIsClientProcess.Value

End Get

Set(ByVal value As Boolean)

If msIsClientProcess.HasValue Then

Throw New InvalidOperationException("'IsClientProcess' is already set; can only set it once.")

Else

msIsClientProcess = Value

' Tell DataSourceKeyResolver about it.

'AppHelper.DataSourceKeyResolver.IsClientProcess = msIsClientProcess.Value

End If

End Set

End Property

#End Region

#Region "Private Field Members"

Private Shared msManager As PersistenceManager

Private Shared msIsClientProcess As Nullable(Of Boolean)

Private Shared msAuditColumnManagers As AuditColumnManagerCollection

#End Region

End Class

Back to Top
PJones View Drop Down
Newbie
Newbie
Avatar

Joined: 10-Oct-2007
Location: United States
Posts: 10
Post Options Post Options   Quote PJones Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 5:14am
Um, in my persistencemanager object the VerifierEngine has no .Enabled properties...
 
Or am I looking in the wrong place?
 
Pete Jones
Back to Top
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2007 at 8:56am
Thanks for the help. I guess brilliant minds think alike :-), I had implemented just those changes but I did no post because I was still testing. Instead of overriding the OnPropertyChanged, I actually added a boolean to my base entity and then test the boolean in the OnPropertyChanged before executing. A little different but both solutions seem to work well.
Back to Top
owais,zahid View Drop Down
Newbie
Newbie
Avatar

Joined: 22-Aug-2007
Location: Pakistan
Posts: 8
Post Options Post Options   Quote owais,zahid Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2007 at 8:45am

Where can be couple of issues related to the performance hit. You should do the following things.

1) During batch update, make sure that the verifierengine of the entity or persistanceManager is disable. By this, the persistence Manager will not verify the entities to be updated (this can be bit risky but if normally batch updates are not prone to user related errors).
 
            PersistenceManager.VerifierEnginer.Enable = false;
 
2) Override the OnPropertyChanged on your batch entities and control the call to base using boolean variable.
 
Hope that works for you.
Back to Top
rclarke View Drop Down
Groupie
Groupie


Joined: 14-Jun-2007
Location: United States
Posts: 69
Post Options Post Options   Quote rclarke Quote  Post ReplyReply Direct Link To This Post Posted: 15-Aug-2007 at 8:29am
I use a base entity for my classes to inherit from in order to provide common behavior for all classes. In the base entity class I have the following code:
 

''' <summary>Raises OnPropertyChanged event for the property named pPropertyName.</summary>

''' <remarks>Typically called inside a custom property setter.</remarks>

Protected Overloads Sub OnPropertyChanged(ByVal pPropertyName As String)

OnPropertyChanged(New PropertyChangedEventArgs(pPropertyName))

End Sub

''' <summary>Raises OnPropertyChanged event for the property described by a pPropertyDescriptor.</summary>

''' <remarks>Typically called inside a custom property setter.</remarks>

Public Overloads Sub OnPropertyChanged(ByVal pPropertyDescriptor As PropertyDescriptor)

OnPropertyChanged(New PropertyChangedEventArgs(pPropertyDescriptor.Name))

End Sub

I was having a performance problem in a batch database update function which was taking much too long; the entire operation took over 15 min. After commenting out the OnPropertyChanged code above the same process ran in less that 30 sec. What a difference. So if ypu're experiencing similar performance issues and have implemented the above, you should consider what I did.
 
Unfortunately, I depend on the OnPropertyChanged event in other parts of my code so I need to look at dynamically turning it on and off depending of the need.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down