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

chore: updated readme and added more stats to loadgen #462

Merged
merged 3 commits into from
Aug 7, 2023
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I've never had to do this. but it's probably harmless?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep harmless

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing that always throws me off when working on .NET is that Visual Studio doesn't auto-save the file so if you re-run without explicitly saving then your changes won't get picked up. Any chance that that is what happened to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no I was using Rider.. it was actually not running at all from my terminal after it got saved.. it seems pretty common based on quick google searches https://stackoverflow.com/questions/61253916/net-core-dotnet-run-is-not-running-the-last-modified-source-code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow. okay!

MOMENTO_AUTH_TOKEN=<YOUR AUTH TOKEN> dotnet run
```
Loading