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

[148] Transfer settings optimizer #219

Merged
merged 2 commits into from
May 10, 2023
Merged

[148] Transfer settings optimizer #219

merged 2 commits into from
May 10, 2023

Conversation

giventocode
Copy link
Contributor

This PR includes:

}
}

public long TotalMemory
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this in bytes or a different unit? Would be helpful to name variable as such

{
get
{
return (long)(Convert.ToUInt64(File.ReadLines(ProcMemInfo).First(line => line.StartsWith("MemTotal")).Split(' ', StringSplitOptions.RemoveEmptyEntries)[1]) * 1024);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could Convert.ToInt64 instead of casting ulong as long? Also could store this in a static variable so the file system is only used once

private readonly ISystemInfoProvider systemInfoProvider;
private const double MemoryBufferCapacityFactor = 0.4; // 40% of total memory
private const long MaxMemoryBufferSizeInBytes = BlobSizeUtils.GiB * 2; // 2 GiB of total memory
private const int MaxNumberOfWorkingOfThreads = 90;
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe rename to MaxWorkingThreadsCount. I'm surprised it's not valuable to vary this based on core count?

private BlobPipelineOptions CreateOptimizedOptions(BlobPipelineOptions options)
{
var blockSize = GetBlockSize(options.BlockSizeBytes);
var bufferCapacity = GetOptimizedMemoryBufferCapacity(blockSize);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what unit is this? If bytes, helpful to have variable name include it


private BlobPipelineOptions CreateOptimizedOptions(BlobPipelineOptions options)
{
var blockSize = GetBlockSize(options.BlockSizeBytes);
Copy link
Collaborator

Choose a reason for hiding this comment

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

unit?

return ToTens((int)(Convert.ToInt64(memoryBuffer) / blockSize));
}

private int ToTens(int value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

RoundDownToNearestTen() might be more descriptive

{
get
{
return File.ReadLines(ProcCpuInfo).Count(line => line.StartsWith("processor"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe just do this once, and then store it in a static variable, since this will never change in the process lifetime, and multiple invocations of the file system isn't ideal?

@giventocode giventocode merged commit 37b9030 into main May 10, 2023
@giventocode giventocode deleted the ja-148 branch May 10, 2023 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants