Skip to content

Commit

Permalink
Merge pull request #462 from momentohq/readme-stats
Browse files Browse the repository at this point in the history
chore: updated readme and added more stats to loadgen
  • Loading branch information
pratik151192 authored Aug 7, 2023
2 parents 693ff93 + 3479dde commit 7e246b3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 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
31 changes: 21 additions & 10 deletions examples/MomentoLoadGen/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Diagnostics;
using System.Diagnostics.Metrics;
using System.Security.Cryptography;
using System.Text;
using Grpc.Core;
using System.Diagnostics;
using HdrHistogram;
using Microsoft.Extensions.Logging;
using Momento.Sdk;
Expand All @@ -30,7 +25,9 @@ enum AsyncSetGetResult
UNAVAILABLE,
TIMEOUT,
LIMIT_EXCEEDED,
RST_STREAM
RST_STREAM,
UNKNOWN,
CANCELLED
};

internal class CsharpLoadGeneratorContext
Expand All @@ -45,6 +42,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 +57,8 @@ public CsharpLoadGeneratorContext()
GlobalSuccessCount = 0;
GlobalTimeoutExceededCount = 0;
GlobalLimitExceededCount = 0;
GlobalUnknownCount = 0;
GlobalCancelledCount = 0;
GlobalRstStreamCount = 0;
GlobalUnavailableCount = 0;
}
Expand All @@ -67,8 +68,7 @@ public CsharpLoadGeneratorContext()
public class CsharpLoadGenerator
{
const int CACHE_ITEM_TTL_SECONDS = 60;
const string CACHE_NAME = "momento-loadgen";
const int NUM_REQUESTS_PER_OPERATION = 2;
const string CACHE_NAME = "dotnet-momento-loadgen";

private readonly ILoggerFactory _loggerFactory;
private readonly ILogger<CsharpLoadGenerator> _logger;
Expand Down Expand Up @@ -189,6 +189,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 +308,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 +333,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 7e246b3

Please sign in to comment.