Browse Source

MinimumContiguousBlockBytes -> MinimumContiguousBlockSizeBytes

af/UniformUnmanagedMemoryPoolMemoryAllocator-02-MemoryGuards
Anton Firszov 5 years ago
parent
commit
172b0a0ca2
  1. 2
      src/ImageSharp/Memory/Allocators/MemoryAllocator.cs
  2. 8
      src/ImageSharp/Memory/Allocators/MemoryAllocatorOptions.cs
  3. 6
      tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs
  4. 2
      tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs
  5. 2
      tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs

2
src/ImageSharp/Memory/Allocators/MemoryAllocator.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Memory
/// <param name="options">The <see cref="MemoryAllocatorOptions"/>.</param> /// <param name="options">The <see cref="MemoryAllocatorOptions"/>.</param>
/// <returns>The <see cref="MemoryAllocator"/>.</returns> /// <returns>The <see cref="MemoryAllocator"/>.</returns>
public static MemoryAllocator CreateDefault(MemoryAllocatorOptions options) => public static MemoryAllocator CreateDefault(MemoryAllocatorOptions options) =>
new UniformUnmanagedMemoryPoolMemoryAllocator(options.MaximumPoolSizeMegabytes, options.MinimumContiguousBlockBytes); new UniformUnmanagedMemoryPoolMemoryAllocator(options.MaximumPoolSizeMegabytes, options.MinimumContiguousBlockSizeBytes);
/// <summary> /// <summary>
/// Allocates an <see cref="IMemoryOwner{T}" />, holding a <see cref="Memory{T}"/> of length <paramref name="length"/>. /// Allocates an <see cref="IMemoryOwner{T}" />, holding a <see cref="Memory{T}"/> of length <paramref name="length"/>.

8
src/ImageSharp/Memory/Allocators/MemoryAllocatorOptions.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Memory
public class MemoryAllocatorOptions public class MemoryAllocatorOptions
{ {
private int? maximumPoolSizeMegabytes; private int? maximumPoolSizeMegabytes;
private int? minimumContiguousBlockBytes; private int? minimumContiguousBlockSizeBytes;
/// <summary> /// <summary>
/// Gets or sets a value defining the maximum size of the <see cref="MemoryAllocator"/>'s internal memory pool /// Gets or sets a value defining the maximum size of the <see cref="MemoryAllocator"/>'s internal memory pool
@ -38,9 +38,9 @@ namespace SixLabors.ImageSharp.Memory
/// Overriding this value is useful for interop scenarios /// Overriding this value is useful for interop scenarios
/// ensuring <see cref="Image{TPixel}.TryGetSinglePixelSpan"/> succeeds. /// ensuring <see cref="Image{TPixel}.TryGetSinglePixelSpan"/> succeeds.
/// </remarks> /// </remarks>
public int? MinimumContiguousBlockBytes public int? MinimumContiguousBlockSizeBytes
{ {
get => this.minimumContiguousBlockBytes; get => this.minimumContiguousBlockSizeBytes;
set set
{ {
if (value.HasValue) if (value.HasValue)
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Memory
Guard.MustBeGreaterThanOrEqualTo(value.Value, 65536, nameof(this.MaximumPoolSizeMegabytes)); Guard.MustBeGreaterThanOrEqualTo(value.Value, 65536, nameof(this.MaximumPoolSizeMegabytes));
} }
this.minimumContiguousBlockBytes = value; this.minimumContiguousBlockSizeBytes = value;
} }
} }
} }

6
tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs

@ -48,9 +48,9 @@ namespace SixLabors.ImageSharp.Benchmarks.LoadResizeSave
public int[] ParallelismValues { get; } = public int[] ParallelismValues { get; } =
{ {
Environment.ProcessorCount, Environment.ProcessorCount,
Environment.ProcessorCount / 2, // Environment.ProcessorCount / 2,
Environment.ProcessorCount / 4, // Environment.ProcessorCount / 4,
1 // 1
}; };
[Benchmark(Baseline = true)] [Benchmark(Baseline = true)]

2
tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests
{ {
Configuration.Default.MemoryAllocator = MemoryAllocator.CreateDefault(new MemoryAllocatorOptions() Configuration.Default.MemoryAllocator = MemoryAllocator.CreateDefault(new MemoryAllocatorOptions()
{ {
MinimumContiguousBlockBytes = sizeof(Rgba32) * 8192 * 4096 MinimumContiguousBlockSizeBytes = sizeof(Rgba32) * 8192 * 4096
}); });
using Image<Rgba32> image = new Image<Rgba32>(8192, 4096); using Image<Rgba32> image = new Image<Rgba32>(8192, 4096);
Assert.True(image.TryGetSinglePixelSpan(out Span<Rgba32> span)); Assert.True(image.TryGetSinglePixelSpan(out Span<Rgba32> span));

2
tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs

@ -158,7 +158,7 @@ namespace SixLabors.ImageSharp.Tests.Memory.Allocators
var allocator = MemoryAllocator.CreateDefault(new MemoryAllocatorOptions() var allocator = MemoryAllocator.CreateDefault(new MemoryAllocatorOptions()
{ {
MaximumPoolSizeMegabytes = bool.Parse(poolAllocationStr) ? 64 : 0, MaximumPoolSizeMegabytes = bool.Parse(poolAllocationStr) ? 64 : 0,
MinimumContiguousBlockBytes = fortyEightMegabytes MinimumContiguousBlockSizeBytes = fortyEightMegabytes
}); });
MemoryGroup<byte> g = allocator.AllocateGroup<byte>(fortyEightMegabytes, 1024); MemoryGroup<byte> g = allocator.AllocateGroup<byte>(fortyEightMegabytes, 1024);

Loading…
Cancel
Save