Skip to content

Conversation

loyldg
Copy link
Contributor

@loyldg loyldg commented Jul 17, 2025

When uploading files, too much memory is allocated. We can use MemoryPool<byte> to reduce memory allocation and improve performance.

Below is the performance comparison before and after optimization.

MinioClient.ReadFullAsync

.NET SDK 9.0.302
[Host] : .NET 9.0.7 (9.0.725.31616), X64 RyuJIT AVX-512F+CD+BW+DQ+VL
.NET 9.0 : .NET 9.0.7 (9.0.725.31616), X64 RyuJIT AVX-512F+CD+BW+DQ+VL

Job=.NET 9.0 Runtime=.NET 9.0

Method Size Mean Error StdDev Ratio RatioSD Gen0 Gen1 Gen2 Allocated Alloc Ratio
ReadFullAsync 65536 4.532 μs 0.0585 μs 0.0488 μs 1.00 0.01 3.7994 - - 65816 B 1.000
ReadFullAsync_New 65536 1.495 μs 0.0069 μs 0.0077 μs 0.33 0.00 0.0153 - - 264 B 0.004
ReadFullAsync 1048576 52.505 μs 0.2932 μs 0.2599 μs 1.00 0.01 333.3130 333.3130 333.3130 1049064 B 1.000
ReadFullAsync_New 1048576 1.600 μs 0.0151 μs 0.0142 μs 0.03 0.00 0.0153 - - 264 B 0.000
ReadFullAsync 16777216 477.361 μs 9.5429 μs 11.7195 μs 1.001 0.03 666.0156 666.0156 666.0156 16777923 B 1.000
ReadFullAsync_New 16777216 1.504 μs 0.0158 μs 0.0147 μs 0.003 0.00 0.0153 - - 264 B 0.000

S3utils.IsAmazonEndPoint

.NET SDK 9.0.302
[Host] : .NET 9.0.7 (9.0.725.31616), X64 RyuJIT AVX-512F+CD+BW+DQ+VL
.NET 9.0 : .NET 9.0.7 (9.0.725.31616), X64 RyuJIT AVX-512F+CD+BW+DQ+VL

Job=.NET 9.0 Runtime=.NET 9.0

Method Mean Error StdDev Ratio Rank Gen0 Allocated Alloc Ratio
IsAmazonEndPoint 4,762.6 ns 39.81 ns 33.24 ns 1.00 2 0.3204 5584 B 1.00
IsAmazonEndPoint_New 655.3 ns 1.13 ns 1.05 ns 0.14 1 - - 0.00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant