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

THRIFT-5514 netstd test client slow in multithread mode #2521

Merged
merged 1 commit into from
Feb 12, 2022
Merged
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
23 changes: 18 additions & 5 deletions test/netstd/Client/TestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,28 @@ public static async Task<int> Execute(List<string> args)
return ErrorUnknown;
}

var tests = Enumerable.Range(0, param.numThreads).Select(_ => new ClientTest(param)).ToArray();

//issue tests on separate threads simultaneously
var nThreads = Math.Max(param.numThreads, 1);
Console.Write("Starting {0} test thread(s) ", nThreads);
var tasks = new Task[nThreads];
var start = DateTime.Now;
var tasks = tests.Select(test => test.Execute()).ToArray();
var retcode = 0;
for (var i = 0; i < tasks.Length; ++i)
{
Console.Write('.');
tasks[i] = Task.Run(async () =>
{
var test = new ClientTest(param);
await test.Execute();
lock (tasks)
retcode |= test.ReturnCode;
});
}
Console.WriteLine(" OK");
Task.WaitAll(tasks);
Console.WriteLine("Total time: " + (DateTime.Now - start));
Console.WriteLine();
return tests.Select(t => t.ReturnCode).Aggregate((r1, r2) => r1 | r2);
return retcode;
}
catch (Exception outerEx)
{
Expand Down Expand Up @@ -490,7 +503,7 @@ public static byte[] PrepareTestData(bool randomDist, BinaryTestSize testcase)
return retval;
}

private static CancellationToken MakeTimeoutToken(int msec = 5000)
private static CancellationToken MakeTimeoutToken(int msec = 15_000)
{
var token = new CancellationTokenSource(msec);
return token.Token;
Expand Down