This project has moved and is read-only. For the latest updates, please go here.

Composition Performance

Feb 26, 2009 at 1:53 PM
I just measured the composition time of an app I'm working on. It's discovery involves 22 assemblies in three directories accessed via a directory catalog.

My rough measurement was that this took 1.87 seconds, which ia a fairly long time. OTOH, it does make sense to be slow exploring 22 assemblies.

- Is the perf we get in Preview 4 roughly what we can expect at RTM or are you still working on optimization?
- Have you explored running composition in a secondary thread? Would there be issues? Would it help? My thought is that a chunk of that 1.8 seconds is reading the disk, and therefore a second thread might help.
- Short of removing assemblies from discovery, are there any ways to speed the process.
Feb 26, 2009 at 5:10 PM
Have you considered using the catalog caching services?

If the catalog does not change each time then using caching should speed things up.

Of course, it can make it a little more difficult in use cases where you want to be able to just drop an assembly in a directory and have it detected - in this case you would have to detect this somehow and perform discovery and update the cache.


Feb 26, 2009 at 5:29 PM
Thank you.

It's the onion process, I have not yet peeled back to look at catalog caching, but its now on my rather long list.

Feb 27, 2009 at 3:12 AM
Our current performance is not representative of where we will be at RTM - it could change based on a couple of features that we want to add.

Also don't take a dependency on the catalog caching in its current form - we will not be shipping it in V1. In saying that though, it will be still be possible to write caching upon our existing infrastructure in our next drop, its just that we will not be shipping catalogs that can be cached out of the box.

Depending on your parts to normal types ratio, we found a huge benefit for one our internal partner's applications simply by caching the names of the types that were actual parts (ie types that had an [Export] on them), and making sure that the catalog only received those. When measuring do you know if the time is spent in composition (SetImport/GetExportedObject), discovery (Reflection) or your own code? If your application seems to be spending a lot of time in discovery, then caching will definitely benefit it.
Feb 27, 2009 at 4:56 PM
davkean, can you give a bit more detail on how you would use caching of the type names in order to speed up performance?

Are you indicating a process where you would first import using e.g. a DirectoryCatalog and then once you have retrieved the exported objects, get their type, store this information and then later use a TypeCatalog to import the known exports??

BTW, seems a shame you're not going to ship caching - I've been using it extensively.