Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage] Reduce number of allocations in upload. #21243

Merged
Merged
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
19 changes: 15 additions & 4 deletions sdk/storage/Azure.Storage.Blobs/src/BlobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,8 +1629,6 @@ internal async Task<Response<BlobContentInfo>> StagedUploadInternal(
.ClientSideEncryptInternal(content, options.Metadata, async, cancellationToken).ConfigureAwait(false);
}

var client = new BlockBlobClient(Uri, ClientConfiguration);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wasn't even used :O


var uploader = GetPartitionedUploader(
transferOptions: options?.TransferOptions ?? default,
operationName: $"{nameof(BlobClient)}.{nameof(Upload)}");
Expand Down Expand Up @@ -1710,11 +1708,24 @@ internal async Task<Response<BlobContentInfo>> StagedUploadInternal(
}
#endregion Upload

private BlockBlobClient _blockBlobClient;

private BlockBlobClient BlockBlobClient
{
get
{
if (_blockBlobClient == null)
{
_blockBlobClient = new BlockBlobClient(Uri, ClientConfiguration);
}
return _blockBlobClient;
}
}

internal PartitionedUploader<BlobUploadOptions, BlobContentInfo> GetPartitionedUploader(
StorageTransferOptions transferOptions,
ArrayPool<byte> arrayPool = null,
string operationName = null)
=> new BlockBlobClient(Uri, ClientConfiguration)
.GetPartitionedUploader(transferOptions, arrayPool, operationName);
=> BlockBlobClient.GetPartitionedUploader(transferOptions, arrayPool, operationName);
}
}