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

Generalize placement specifications for instances #159

Merged
merged 1 commit into from
May 25, 2022
Merged
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 @@ -517,12 +517,14 @@ async Task<ServiceState> TryStopAsync(bool quickly)
/// <returns>The partition id.</returns>
public uint GetPartitionId(string instanceId)
{
int placementSeparatorPosition = instanceId.LastIndexOf('!');

// if the instance id ends with !nn, where nn is a two-digit number, it indicates explicit partition placement
if (instanceId.Length >= 3
&& instanceId[instanceId.Length - 3] == '!'
&& uint.TryParse(instanceId.Substring(instanceId.Length - 2), out uint nn))
if (placementSeparatorPosition != -1
&& placementSeparatorPosition <= instanceId.Length - 2
&& uint.TryParse(instanceId.Substring(placementSeparatorPosition + 1), out uint index))
{
var partitionId = nn % this.NumberPartitions;
var partitionId = index % this.NumberPartitions;
//this.Logger.LogTrace($"Instance: {instanceId} was explicitly placed on partition: {partitionId}");
return partitionId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static async Task<List<long>> Run([OrchestrationTrigger] IDurableOrchestr
{
subOrchestratorTasks[i] = context.CallSubOrchestratorAsync<List<long>>(
nameof(DivideAndConquerSearch),
// $"{context.InstanceId}!{i:D2}",
// $"{context.InstanceId}!{i}",
new IntervalSearchParameters()
{
Target = input.Target,
Expand Down
2 changes: 1 addition & 1 deletion test/PerformanceTests/Benchmarks/Counter/HttpTriggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static async Task<IActionResult> CountParallelSignals(
int numberSignals = int.Parse(input.Substring(0, commaPosition));
int numberEntities = int.Parse(input.Substring(commaPosition + 1));
var entityPrefix = Guid.NewGuid().ToString("N");
EntityId MakeEntityId(int i) => new EntityId("Counter", $"{entityPrefix}-{i/100:D6}!{i%100:D2}");
EntityId MakeEntityId(int i) => new EntityId("Counter", $"{entityPrefix}-!{i:D6}");
DateTime startTime = DateTime.UtcNow;

if (numberSignals % numberEntities != 0)
Expand Down
2 changes: 1 addition & 1 deletion test/PerformanceTests/Benchmarks/WordCount/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum Ops

public static EntityId GetEntityId(int number)
{
return new EntityId(nameof(Mapper), $"{number}!{number % 100:D2}");
return new EntityId(nameof(Mapper), $"!{number}");
}

[FunctionName(nameof(Mapper))]
Expand Down
2 changes: 1 addition & 1 deletion test/PerformanceTests/Benchmarks/WordCount/Reducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class Reducer
{
public static EntityId GetEntityId(int number)
{
return new EntityId(nameof(Reducer), $"{number}!{number % 100:D2}");
return new EntityId(nameof(Reducer), $"!{number}");
}

public enum Ops
Expand Down
2 changes: 1 addition & 1 deletion test/PerformanceTests/Common/ManyOrchestrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ await Enumerable.Range(0, numberOrchestrations).ParallelForEachAsync(200, true,
while (pos < numberOrchestrations)
{
int portion = Math.Min(portionSize.Value, (numberOrchestrations - pos));
var entityId = new EntityId(nameof(LauncherEntity), $"launcher{launcher / 100:D6}!{launcher % 100:D2}");
var entityId = new EntityId(nameof(LauncherEntity), $"launcher!{launcher:D6}");
tasks.Add(client.SignalEntityAsync(entityId, nameof(LauncherEntity.Launch), (orchestrationName, prefix, portion, pos, input)));
pos += portion;
launcher++;
Expand Down
2 changes: 1 addition & 1 deletion test/PerformanceTests/Common/Ping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static async Task<IActionResult> Run(

async Task<string> Ping(int partition)
{
string instanceId = $"ping!{partition:D2}";
string instanceId = $"ping!{partition}";

var timeoutTask = Task.Delay(timeout);
var startTask = client.StartNewAsync(nameof(Pingee), instanceId);
Expand Down