Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <azure/core/modified_conditions.hpp>
#include <azure/storage/common/access_conditions.hpp>
#include <azure/storage/common/crypt.hpp>
#include <azure/storage/common/internal/concurrent_transfer.hpp>

#include <chrono>
#include <cstdint>
Expand Down Expand Up @@ -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;
Comment on lines +780 to +782
} TransferOptions;

/**
Expand Down Expand Up @@ -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;
Comment on lines +1029 to +1030
} TransferOptions;

/**
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/azure-storage-blobs/src/block_blob_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/azure-storage-common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Azure { namespace Storage { namespace _internal {

int GetHardwareConcurrency();

inline void ConcurrentTransfer(
Comment on lines 14 to 18
int64_t offset,
int64_t length,
Expand Down
16 changes: 16 additions & 0 deletions sdk/storage/azure-storage-common/src/concurrent_transfer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "azure/storage/common/internal/concurrent_transfer.hpp"

#include <thread>

namespace Azure { namespace Storage { namespace _internal {

int GetHardwareConcurrency()
{
static int c = std::thread::hardware_concurrency();
return c;
}

}}} // namespace Azure::Storage::_internal
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <azure/core/nullable.hpp>
#include <azure/storage/blobs/blob_options.hpp>
#include <azure/storage/common/access_conditions.hpp>
#include <azure/storage/common/internal/concurrent_transfer.hpp>

#include <cstdint>
#include <memory>
Expand Down Expand Up @@ -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;
Comment on lines +1021 to +1022
} TransferOptions;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <azure/core/internal/extendable_enumeration.hpp>
#include <azure/core/nullable.hpp>
#include <azure/storage/common/access_conditions.hpp>
#include <azure/storage/common/internal/concurrent_transfer.hpp>

#include <memory>
#include <string>
Expand Down Expand Up @@ -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;
Comment on lines +1334 to +1336
} TransferOptions;
};

Expand Down Expand Up @@ -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;
Comment on lines +1405 to +1406
} TransferOptions;
};

Expand Down
Loading