Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions MergerLogic/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public static class ServiceCollectionExtensions
{
public static IServiceCollection RegisterMergerLogicType(this IServiceCollection collection, bool includeServiceProvider = true)
{
ConfigureImageMagick();

if (includeServiceProvider)
{
collection = collection.RegisterServiceProvider();
Expand All @@ -48,6 +50,15 @@ public static IServiceCollection RegisterImageProcessors(this IServiceCollection
.AddSingleton<ITileScaler, TileScaler>();
}

// Process-global ImageMagick tuning. Applied once at composition root, kept out of the DI
// registration methods so runtime side effects aren't hidden behind a "register services" call.
private static void ConfigureImageMagick()
{
// Tiles are already processed in parallel at the app level, so keep ImageMagick single-threaded
// per operation to avoid thread oversubscription.
ImageMagick.ResourceLimits.Thread = 1;
}

public static IServiceCollection RegisterMergerUtils(this IServiceCollection collection)
{
return collection
Expand Down
3 changes: 3 additions & 0 deletions MergerService/MergerService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<!-- Throughput-oriented GC for the long-running, allocation-heavy merge service. -->
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
Expand Down
Loading