[Internal] Query: Refactors ParallelCrossPartitionQueryPipelineStage to improve perf (#4548)

* init

* revert test

* remove sw

* nit

* cleanup
This commit is contained in:
Maya Painter 2024-06-18 12:25:44 -07:00 коммит произвёл GitHub
Родитель 035d2297bf
Коммит c5ac103a63
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 5 добавлений и 6 удалений

Просмотреть файл

@ -78,14 +78,12 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Pipeline.CrossPartition.Parallel
else
{
// left most and any non null continuations
IOrderedEnumerable<FeedRangeState<QueryState>> feedRangeStates = crossPartitionState
.Value
.ToArray()
.OrderBy(tuple => ((FeedRangeEpk)tuple.FeedRange).Range.Min);
FeedRangeState<QueryState>[] feedRangeStates = crossPartitionState.Value.ToArray();
Array.Sort<FeedRangeState<QueryState>>(feedRangeStates, (x, y) => string.CompareOrdinal(((FeedRangeEpk)x.FeedRange).Range.Min, ((FeedRangeEpk)y.FeedRange).Range.Min));
List<ParallelContinuationToken> activeParallelContinuationTokens = new List<ParallelContinuationToken>();
{
FeedRangeState<QueryState> firstState = feedRangeStates.First();
FeedRangeState<QueryState> firstState = feedRangeStates[0];
ParallelContinuationToken firstParallelContinuationToken = new ParallelContinuationToken(
token: firstState.State != null ? ((CosmosString)firstState.State.Value).Value : null,
range: ((FeedRangeEpk)firstState.FeedRange).Range);
@ -93,10 +91,11 @@ namespace Microsoft.Azure.Cosmos.Query.Core.Pipeline.CrossPartition.Parallel
activeParallelContinuationTokens.Add(firstParallelContinuationToken);
}
foreach (FeedRangeState<QueryState> feedRangeState in feedRangeStates.Skip(1))
for (int i = 1; i < feedRangeStates.Length; i++)
{
cancellationToken.ThrowIfCancellationRequested();
FeedRangeState<QueryState> feedRangeState = feedRangeStates[i];
if (feedRangeState.State != null)
{
ParallelContinuationToken parallelContinuationToken = new ParallelContinuationToken(