Skip to content

Commit 8c5e30d

Browse files
committed
Some perf improvements...
1 parent a1ee2c2 commit 8c5e30d

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

code/KustoCopyConsole/Kusto/DbCommandClient.cs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using KustoCopyConsole.Kusto.Data;
66
using System.Collections.Immutable;
77
using System.Data;
8+
using System.Diagnostics;
89

910
namespace KustoCopyConsole.Kusto
1011
{

code/KustoCopyConsole/Kusto/IngestClient.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Kusto.Data.Common;
22
using Kusto.Ingest;
3+
using System.Diagnostics;
34

45
namespace KustoCopyConsole.Kusto
56
{

code/KustoCopyConsole/Runner/AwaitExportedRunner.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class AwaitExportedRunner : RunnerBase
1717
private record ClusterBlocks(Uri ClusterUri, IEnumerable<BlockRowItem> BlockItems);
1818
#endregion
1919

20-
private const int MAX_OPERATIONS = 50;
20+
private const int MAX_OPERATIONS = 200;
2121
private static readonly IImmutableSet<string> FAILED_STATUS =
2222
ImmutableHashSet.Create(
2323
[
@@ -33,7 +33,7 @@ public AwaitExportedRunner(
3333
MainJobParameterization parameterization,
3434
RowItemGateway rowItemGateway,
3535
DbClientFactory dbClientFactory)
36-
: base(parameterization, rowItemGateway, dbClientFactory, TimeSpan.FromSeconds(5))
36+
: base(parameterization, rowItemGateway, dbClientFactory, TimeSpan.FromSeconds(3))
3737
{
3838
}
3939

code/KustoCopyConsole/Runner/ExportingRunner.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Extensions.Azure;
88
using System;
99
using System.Collections.Immutable;
10+
using System.Diagnostics;
1011
using System.Linq;
1112

1213
namespace KustoCopyConsole.Runner
@@ -36,11 +37,20 @@ public async Task RunAsync(CancellationToken ct)
3637
var exportLineUp = await GetExportLineUpAsync(capacityMap, ct);
3738
var exportCount = await StartExportAsync(exportLineUp, ct);
3839

39-
// Sleep
40-
await SleepAsync(ct);
40+
if (exportCount == 0)
41+
{
42+
// Sleep
43+
await SleepAsync(ct);
44+
}
4145
}
4246
}
4347

48+
protected override bool IsWakeUpRelevant(RowItemBase item)
49+
{
50+
return item is BlockRowItem b
51+
&& (b.State == BlockState.Planned || b.State == BlockState.Exported);
52+
}
53+
4454
private async Task<int> StartExportAsync(
4555
IEnumerable<ActivityFlatHierarchy> exportLineUp,
4656
CancellationToken ct)

code/KustoCopyConsole/Runner/QueueIngestRunner.cs

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using KustoCopyConsole.Kusto;
77
using KustoCopyConsole.Storage;
88
using System.Collections.Immutable;
9+
using System.Diagnostics;
910

1011
namespace KustoCopyConsole.Runner
1112
{
@@ -29,17 +30,27 @@ public async Task RunAsync(CancellationToken ct)
2930
i => i.RowItem.State != IterationState.Completed);
3031
var exportedBlocks = allBlocks
3132
.Where(h => h.Block.State == BlockState.Exported);
33+
var s = new Stopwatch(); s.Start();
3234
var ingestionTasks = exportedBlocks
3335
.Select(h => QueueIngestBlockAsync(h, ct))
3436
.ToImmutableArray();
3537

3638
await Task.WhenAll(ingestionTasks);
3739

38-
// Sleep
39-
await SleepAsync(ct);
40+
if (!ingestionTasks.Any())
41+
{
42+
// Sleep
43+
await SleepAsync(ct);
44+
}
4045
}
4146
}
4247

48+
protected override bool IsWakeUpRelevant(RowItemBase item)
49+
{
50+
return item is BlockRowItem b
51+
&& b.State == BlockState.Exported;
52+
}
53+
4354
private async Task QueueIngestBlockAsync(ActivityFlatHierarchy item, CancellationToken ct)
4455
{
4556
// It's possible, although unlikely, the temp table hasn't been created yet

code/KustoCopyConsole/Storage/AzureStorage/AzureBlobUriProvider.cs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System;
88
using System.Collections.Generic;
99
using System.Collections.Immutable;
10+
using System.Diagnostics;
1011
using System.IO;
1112
using System.Linq;
1213
using System.Text;

0 commit comments

Comments
 (0)