I'm having big performance problems saving large EntityCollections. The DetermineActionQueues(entityCollectionToSave,...) is taking a looooong time to finish, and it looks like it is because of two things. First,
ArrayList sortedGraphList = this.ProduceTopologyOrderedList(entityToSave);
if(inQueue.ContainsKey(entityToSave.ObjectID))
{
return;
}
executes for every entity in the collection, so a Topo list is created for every entity in the collection, even if that entity is already in "inQueue"
next,
inQueue.Add(toSave.ObjectID, null);
happens only for "dirty" entities, so entities in the root entity collection that are not dirty do not get added, even if they have been traversed already by a previous call to DetermineActionQueues.
I'm guessing InQueue is supposed to be a quick lookup for entities that are already in "some kind" of queue, so putting them in only for dirty entities seems fair so that they don't get added more than once. However, wouldn't keeping a hashtable of traversed entities be useful so that DetermineActionQueues(entityCollectionToSave,...) doesn't end up repeating traversal code in the case where entities in entityCollectionToSave are part of the same graph? Because of how it works now, I have 1200 entities in a collection I am saving, and they are all part of the same Topo list, and the Topo list gets created for each and every one of them inside DetermineActionQueues(entityToSave,...). This takes an unbelievable amount of time at the moment