This project has moved. For the latest updates, please go here.

Performance issue in SmallSparseInitonlyArray



I have found a significant performance issue when using lost of Shared parts. 50% of composition time is spent inside System.Composition.Hosting.Util.SmallSparseInitonlyArray.Add on string.Format calls. The error is obvious: the method has 2 calls like
Assumes.IsTrue(e.Index != index, string.Format("An item with the key '{0}' has already been added.", index));
No matter what the condition is, string.Format gets evaluated every time.

So, MEF is spending 50% time on producing garbage. Definitely not the task a high performance framework should do. :)

file attachments


nblumhardt wrote Jun 7, 2014 at 10:39 PM

Very true - this should be a debug-only assertion, thanks for the note. Hopefully someone on the current team's spotted this one too :) Cheers!