Skip to content

Commit

Permalink
chore: updated readme and added more stats to loadgen
Browse files Browse the repository at this point in the history
  • Loading branch information
pratik151192 committed Aug 2, 2023
1 parent 693ff93 commit edfaaf0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Running tests

Unless you are testing older .NET runtimes on Windows, you should run the tests against the newer runtimes as follows:
- https://dotnet.microsoft.com/en-us/download/dotnet/6.0

```
make test-net6
Expand Down
24 changes: 21 additions & 3 deletions examples/MomentoLoadGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Momento.Sdk;
using Momento.Sdk.Auth;
using Momento.Sdk.Config;
using Momento.Sdk.Config.Transport;
using Momento.Sdk.Exceptions;
using Momento.Sdk.Responses;

Expand All @@ -30,7 +31,9 @@ enum AsyncSetGetResult
UNAVAILABLE,
TIMEOUT,
LIMIT_EXCEEDED,
RST_STREAM
RST_STREAM,
UNKNOWN,
CANCELLED
};

internal class CsharpLoadGeneratorContext
Expand All @@ -45,6 +48,8 @@ internal class CsharpLoadGeneratorContext
public int GlobalUnavailableCount;
public int GlobalTimeoutExceededCount;
public int GlobalLimitExceededCount;
public int GlobalUnknownCount;
public int GlobalCancelledCount;
public int GlobalRstStreamCount;

public CsharpLoadGeneratorContext()
Expand All @@ -58,6 +63,8 @@ public CsharpLoadGeneratorContext()
GlobalSuccessCount = 0;
GlobalTimeoutExceededCount = 0;
GlobalLimitExceededCount = 0;
GlobalUnknownCount = 0;
GlobalCancelledCount = 0;
GlobalRstStreamCount = 0;
GlobalUnavailableCount = 0;
}
Expand All @@ -67,7 +74,7 @@ public CsharpLoadGeneratorContext()
public class CsharpLoadGenerator
{
const int CACHE_ITEM_TTL_SECONDS = 60;
const string CACHE_NAME = "momento-loadgen";
const string CACHE_NAME = "dotnet-momento-loadgen";
const int NUM_REQUESTS_PER_OPERATION = 2;

private readonly ILoggerFactory _loggerFactory;
Expand Down Expand Up @@ -189,6 +196,8 @@ private void PrintStats(LongHistogram setsAccumulatingHistogram, LongHistogram g
unavailable: {context.GlobalUnavailableCount} ({PercentRequests(context, context.GlobalUnavailableCount)}%)
timeout exceeded: {context.GlobalTimeoutExceededCount} ({PercentRequests(context, context.GlobalTimeoutExceededCount)}%)
limit exceeded: {context.GlobalLimitExceededCount} ({PercentRequests(context, context.GlobalLimitExceededCount)}%)
cancelled: {context.GlobalCancelledCount} ({PercentRequests(context, context.GlobalCancelledCount)}%)
unknown: {context.GlobalUnknownCount} ({PercentRequests(context, context.GlobalUnknownCount)}%)
rst stream: {context.GlobalRstStreamCount} ({PercentRequests(context, context.GlobalRstStreamCount)}%)
cumulative set latencies:
Expand Down Expand Up @@ -306,9 +315,16 @@ private AsyncSetGetResult ConvertErrorToAsyncSetGetResult(MomentoErrorCode error
{
return AsyncSetGetResult.LIMIT_EXCEEDED;
}
else if (errorCode is MomentoErrorCode.UNKNOWN_ERROR or MomentoErrorCode.UNKNOWN_SERVICE_ERROR)
{
return AsyncSetGetResult.UNKNOWN;
}
else if (errorCode == MomentoErrorCode.CANCELLED_ERROR)
{
return AsyncSetGetResult.CANCELLED;
}
_logger.LogError("UNCAUGHT EXCEPTION: {}", ex);
throw new ApplicationException($"Unsupported error code: {errorCode}");

}

private static void UpdateContextCountsForRequest(
Expand All @@ -324,6 +340,8 @@ AsyncSetGetResult result
AsyncSetGetResult.TIMEOUT => Interlocked.Increment(ref context.GlobalTimeoutExceededCount),
AsyncSetGetResult.LIMIT_EXCEEDED => Interlocked.Increment(ref context.GlobalLimitExceededCount),
AsyncSetGetResult.RST_STREAM => Interlocked.Increment(ref context.GlobalRstStreamCount),
AsyncSetGetResult.UNKNOWN => Interlocked.Increment(ref context.GlobalUnknownCount),
AsyncSetGetResult.CANCELLED => Interlocked.Increment(ref context.GlobalCancelledCount),
_ => throw new Exception($"Unrecognized result: {result}"),
};
return;
Expand Down
8 changes: 8 additions & 0 deletions examples/MomentoLoadGen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ Within the `MomentoLoadGen` directory you can run:
# Run example load generator
MOMENTO_AUTH_TOKEN=<YOUR AUTH TOKEN> dotnet run
```

If you make modifications to the code, remember to do a clean otherwise
the program might not run.

```bash
dotnet clean
MOMENTO_AUTH_TOKEN=<YOUR AUTH TOKEN> dotnet run
```

0 comments on commit edfaaf0

Please sign in to comment.