PERF: Adding more logging calls related to performance tracking

Also added a few "Disabled" checks in extension loaders to avoid
extra-work when they are disabled.

--HG--
branch : 1.x
This commit is contained in:
Renaud Paquay
2011-05-27 10:45:28 -07:00
parent 852d21fee9
commit c51f4ce2de
3 changed files with 57 additions and 8 deletions

View File

@@ -71,9 +71,14 @@ namespace Orchard.Environment.Extensions {
}
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
return featureDescriptors
Logger.Information("Loading features");
var result = featureDescriptors
.Select(descriptor => _cacheManager.Get(descriptor.Id, ctx => LoadFeature(descriptor)))
.ToArray();
Logger.Information("Done loading features");
return result;
}
private Feature LoadFeature(FeatureDescriptor featureDescriptor) {

View File

@@ -94,18 +94,26 @@ namespace Orchard.Environment.Extensions.Loaders {
}
public override IEnumerable<ExtensionReferenceProbeEntry> ProbeReferences(ExtensionDescriptor descriptor) {
if (Disabled)
return Enumerable.Empty<ExtensionReferenceProbeEntry>();
Logger.Information("Probing references for module '{0}'", descriptor.Id);
string projectPath = GetProjectPath(descriptor);
if (projectPath == null)
return Enumerable.Empty<ExtensionReferenceProbeEntry>();
var projectFile = _projectFileParser.Parse(projectPath);
return projectFile.References.Select(r => new ExtensionReferenceProbeEntry {
var result = projectFile.References.Select(r => new ExtensionReferenceProbeEntry {
Descriptor = descriptor,
Loader = this,
Name = r.SimpleName,
VirtualPath = _virtualPathProvider.GetProjectReferenceVirtualPath(projectPath, r.SimpleName, r.Path)
});
Logger.Information("Done probing references for module '{0}'", descriptor.Id);
return result;
}
public override void ReferenceActivated(ExtensionLoadingContext context, ExtensionReferenceProbeEntry referenceEntry) {
@@ -132,28 +140,43 @@ namespace Orchard.Environment.Extensions.Loaders {
}
public override Assembly LoadReference(DependencyReferenceDescriptor reference) {
if (Disabled)
return null;
Logger.Information("Loading reference '{0}'", reference.Name);
// DynamicExtensionLoader has 2 types of references: assemblies from module bin directory
// and .csproj.
Assembly result;
if (StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(reference.VirtualPath), ".dll"))
return _assemblyProbingFolder.LoadAssembly(reference.Name);
result = _assemblyProbingFolder.LoadAssembly(reference.Name);
else {
result = _buildManager.GetCompiledAssembly(reference.VirtualPath);
}
return _buildManager.GetCompiledAssembly(reference.VirtualPath);
Logger.Information("Done loading reference '{0}'", reference.Name);
return result;
}
public override ExtensionProbeEntry Probe(ExtensionDescriptor descriptor) {
if (Disabled)
return null;
Logger.Information("Probing for module '{0}'", descriptor.Id);
string projectPath = GetProjectPath(descriptor);
if (projectPath == null)
return null;
return new ExtensionProbeEntry {
var result = new ExtensionProbeEntry {
Descriptor = descriptor,
LastWriteTimeUtc = GetDependencies(projectPath).Max(f => _virtualPathProvider.GetFileLastWriteTimeUtc(f)),
Loader = this,
VirtualPath = projectPath
};
Logger.Information("Done probing for module '{0}'", descriptor.Id);
return result;
}
protected override ExtensionEntry LoadWorker(ExtensionDescriptor descriptor) {

View File

@@ -144,11 +144,16 @@ namespace Orchard.Environment.Extensions.Loaders {
}
public override IEnumerable<ExtensionReferenceProbeEntry> ProbeReferences(ExtensionDescriptor descriptor) {
if (Disabled)
return Enumerable.Empty<ExtensionReferenceProbeEntry>();
Logger.Information("Probing references for module '{0}'", descriptor.Id);
var assemblyPath = GetAssemblyPath(descriptor);
if (assemblyPath == null)
return Enumerable.Empty<ExtensionReferenceProbeEntry>();
return _virtualPathProvider
var result = _virtualPathProvider
.ListFiles(_virtualPathProvider.GetDirectoryName(assemblyPath))
.Where(s => StringComparer.OrdinalIgnoreCase.Equals(Path.GetExtension(s), ".dll"))
.Where(s => !StringComparer.OrdinalIgnoreCase.Equals(Path.GetFileNameWithoutExtension(s), descriptor.Id))
@@ -159,6 +164,9 @@ namespace Orchard.Environment.Extensions.Loaders {
VirtualPath = path
} )
.ToList();
Logger.Information("Done probing references for module '{0}'", descriptor.Id);
return result;
}
public override bool IsCompatibleWithModuleReferences(ExtensionDescriptor extension, IEnumerable<ExtensionProbeEntry> references) {
@@ -176,20 +184,33 @@ namespace Orchard.Environment.Extensions.Loaders {
if (Disabled)
return null;
Logger.Information("Probing for module '{0}'", descriptor.Id);
var assemblyPath = GetAssemblyPath(descriptor);
if (assemblyPath == null)
return null;
return new ExtensionProbeEntry {
var result = new ExtensionProbeEntry {
Descriptor = descriptor,
LastWriteTimeUtc = _virtualPathProvider.GetFileLastWriteTimeUtc(assemblyPath),
Loader = this,
VirtualPath = assemblyPath
};
Logger.Information("Done probing for module '{0}'", descriptor.Id);
return result;
}
public override Assembly LoadReference(DependencyReferenceDescriptor reference) {
return _assemblyProbingFolder.LoadAssembly(reference.Name);
if (Disabled)
return null;
Logger.Information("Loading reference '{0}'", reference.Name);
var result = _assemblyProbingFolder.LoadAssembly(reference.Name);
Logger.Information("Done loading reference '{0}'", reference.Name);
return result;
}
protected override ExtensionEntry LoadWorker(ExtensionDescriptor descriptor) {