пятница, 28 июня 2013 г.

Issues using EntLib and Unity developing Desktop apps and MS Office add-ins

Used EntLib and Untiy for development of big modular with plugins Desktop application.
Found next problems using aforemention libraries in such context
1. Static filed of EntLib conflicts.
2. Start up time of Unity (we do not use configuration, only runtime registration)
3. Start up time of EntLib (we use configuration)

1. First is easy. Elimintatin emplicit usage of static memebers is fully supported by EntLib [1]. Now our host never broken by plugins.
2. Unity container IsRegistered is slow. We got bad design where IsRegistered was triggered many times in many places before Register called. This design has its roots in developing mix for AppDomain/IPC /not isolated components and from using static shared propery service locator. We refactored into registration groups(ContainerConfigurator like class which does several related Register - SystemConfigurator, UpdatesConfigurator, OptionsConfiguratio, etc.)  and eliminated public static container. Now our objectrs graph is constucted and configured once while application bootstrap. Grouped configurations helps align components and their registrations with minumum amount of duplication. We not use most features of Unity (dependency ovverrides,injection attributes, configuration). I think unity can consume 100-500 ms of start of our application (depends how much modules is here), and because we not reconfigure Unity in runtime it could be good if Unity will employ some code generation during compilation. We use custom not unity based reconfiguration(needs app restart) of few high level components employing preventing method inlining (MethodImplOptions.NoInlining, prevents type loading of not used types and dlls) while doing feature variablity in our code.
3. Configuration takes time. Measurements show that instantiating EntLib(logging, exception handling) objects from configuration using service locator in one AppDomain takes ~100 milliseconds per block. Meassuremnts made using full/partial warm up of assemblies,types and config to eliminate influence of touching assemblies and files for the first time. Really, only several items from config are used configure objects after solutions were compiled. Recuducing configuration to custom adhoc small subset and creating objects using constuctors took ~5 milliseconds. I hope EntLib will provide simplified config suitalble for Desktop apps.

[1] http://msdn.microsoft.com/en-us/library/ff953191.aspx Getting Objects from Previous Versions of Enterprise Library


Комментариев нет:

Отправить комментарий