diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp index 7ad7759071..1cbce7edfe 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -771,12 +772,14 @@ namespace Azure { namespace Storage { namespace Blobs { /** * @brief The maximum number of bytes in a single request. */ - int64_t ChunkSize = 4 * 1024 * 1024; + int64_t ChunkSize = 16 * 1024 * 1024; /** * @brief The maximum number of threads that may be used in a parallel transfer. */ - int32_t Concurrency = 5; + int32_t Concurrency = _internal::GetHardwareConcurrency() / 2 != 0 + ? _internal::GetHardwareConcurrency() / 2 + : 1; } TransferOptions; /** @@ -1023,7 +1026,8 @@ namespace Azure { namespace Storage { namespace Blobs { /** * @brief The maximum number of threads that may be used in a parallel transfer. */ - int32_t Concurrency = 5; + int32_t Concurrency + = _internal::GetHardwareConcurrency() != 0 ? _internal::GetHardwareConcurrency() : 1; } TransferOptions; /** diff --git a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp index 7401e5203f..2628c9f3b9 100644 --- a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp @@ -178,7 +178,7 @@ namespace Azure { namespace Storage { namespace Blobs { const UploadBlockBlobFromOptions& options, const Azure::Core::Context& context) const { - constexpr int64_t DefaultStageBlockSize = 4 * 1024 * 1024ULL; + constexpr int64_t DefaultStageBlockSize = 16 * 1024 * 1024ULL; constexpr int64_t MaxStageBlockSize = 4000 * 1024 * 1024ULL; constexpr int64_t MaxBlockNumber = 50000; constexpr int64_t BlockGrainSize = 1 * 1024 * 1024; @@ -270,7 +270,7 @@ namespace Azure { namespace Storage { namespace Blobs { const UploadBlockBlobFromOptions& options, const Azure::Core::Context& context) const { - constexpr int64_t DefaultStageBlockSize = 4 * 1024 * 1024ULL; + constexpr int64_t DefaultStageBlockSize = 16 * 1024 * 1024ULL; constexpr int64_t MaxStageBlockSize = 4000 * 1024 * 1024ULL; constexpr int64_t MaxBlockNumber = 50000; constexpr int64_t BlockGrainSize = 1 * 1024 * 1024; diff --git a/sdk/storage/azure-storage-common/CMakeLists.txt b/sdk/storage/azure-storage-common/CMakeLists.txt index a91e1baaf7..f31c1ce44d 100644 --- a/sdk/storage/azure-storage-common/CMakeLists.txt +++ b/sdk/storage/azure-storage-common/CMakeLists.txt @@ -70,6 +70,7 @@ set( set( AZURE_STORAGE_COMMON_SOURCE src/account_sas_builder.cpp + src/concurrent_transfer.cpp src/crypt.cpp src/file_io.cpp src/private/package_version.hpp diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/concurrent_transfer.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/concurrent_transfer.hpp index 9897c518ae..55f0ed6297 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/concurrent_transfer.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/internal/concurrent_transfer.hpp @@ -13,6 +13,8 @@ namespace Azure { namespace Storage { namespace _internal { + int GetHardwareConcurrency(); + inline void ConcurrentTransfer( int64_t offset, int64_t length, diff --git a/sdk/storage/azure-storage-common/src/concurrent_transfer.cpp b/sdk/storage/azure-storage-common/src/concurrent_transfer.cpp new file mode 100644 index 0000000000..d130eb69d8 --- /dev/null +++ b/sdk/storage/azure-storage-common/src/concurrent_transfer.cpp @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "azure/storage/common/internal/concurrent_transfer.hpp" + +#include + +namespace Azure { namespace Storage { namespace _internal { + + int GetHardwareConcurrency() + { + static int c = std::thread::hardware_concurrency(); + return c; + } + +}}} // namespace Azure::Storage::_internal \ No newline at end of file diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp index 26220a39ae..38eb156f03 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -1017,7 +1018,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { /** * The maximum number of threads that may be used in a parallel transfer. */ - int32_t Concurrency = 5; + int32_t Concurrency + = _internal::GetHardwareConcurrency() != 0 ? _internal::GetHardwareConcurrency() : 1; } TransferOptions; /** diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp index a4f808c31c..5d675303d1 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -1325,12 +1326,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { /** * The maximum number of bytes in a single request. */ - int64_t ChunkSize = 4 * 1024 * 1024; + int64_t ChunkSize = 16 * 1024 * 1024; /** * The maximum number of threads that may be used in a parallel transfer. */ - int32_t Concurrency = 5; + int32_t Concurrency = _internal::GetHardwareConcurrency() / 2 != 0 + ? _internal::GetHardwareConcurrency() / 2 + : 1; } TransferOptions; }; @@ -1399,7 +1402,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { /** * The maximum number of threads that may be used in a parallel transfer. */ - int32_t Concurrency = 5; + int32_t Concurrency + = _internal::GetHardwareConcurrency() != 0 ? _internal::GetHardwareConcurrency() : 1; } TransferOptions; };