Skip to content

Commit

Permalink
perf: retrieve chunk size only once
Browse files Browse the repository at this point in the history
  • Loading branch information
aneojgurhem committed Dec 15, 2023
1 parent cc25d0c commit caed497
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Client/src/Common/Submitter/BaseClientSubmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using System.Threading.Tasks;

using ArmoniK.Api.Client;
using ArmoniK.Api.Client.Submitter;
using ArmoniK.Api.Common.Utils;
using ArmoniK.Api.gRPC.V1;
using ArmoniK.Api.gRPC.V1.Results;
Expand Down Expand Up @@ -63,6 +62,8 @@ public abstract class BaseClientSubmitter<T>
/// </summary>
private readonly int chunkSubmitSize_;

private readonly int configuration_;

private readonly Properties properties_;

/// <summary>
Expand Down Expand Up @@ -93,6 +94,9 @@ protected BaseClientSubmitter(Properties properties,
{
TaskOptions.PartitionId,
});

configuration_ = ChannelPool.WithChannel(channel => new Results.ResultsClient(channel).GetServiceConfiguration(new Empty())
.DataChunkMaxSize);
}

private ILoggerFactory LoggerFactory { get; }
Expand Down Expand Up @@ -288,9 +292,6 @@ private IEnumerable<string> ChunkSubmitTasksWithDependencies(IEnumerable<Tuple<s
var tasks = new List<SubmitTasksRequest.Types.TaskCreation>();
var tasksSubmitted = new List<string>();

var configuration = ChannelPool.WithChannel(channel => new Results.ResultsClient(channel).GetServiceConfiguration(new Empty())
.DataChunkMaxSize);

foreach (var (resultId, payload, dependencies) in payloadsWithDependencies)
{
for (var nbRetry = 0; nbRetry < maxRetries; nbRetry++)
Expand All @@ -302,7 +303,7 @@ private IEnumerable<string> ChunkSubmitTasksWithDependencies(IEnumerable<Tuple<s
{
// todo: migrate to ArmoniK.Api
string payloadId;
if (payload.Length > configuration)
if (payload.Length > configuration_)
{
payloadId = resultsClient.CreateResultsMetaData(new CreateResultsMetaDataRequest
{
Expand Down

0 comments on commit caed497

Please sign in to comment.