You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2022/02/12 00:17:14 UTC
[thrift] branch master updated: THRIFT-5514 netstd test client slow in multithread mode Client: netstd Patch: Jens Geyer
This is an automated email from the ASF dual-hosted git repository.
jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push:
new d2c28b3 THRIFT-5514 netstd test client slow in multithread mode Client: netstd Patch: Jens Geyer
d2c28b3 is described below
commit d2c28b349d94e99327a402ce52bcb66f8ab9c769
Author: Jens Geyer <je...@apache.org>
AuthorDate: Thu Feb 10 23:03:02 2022 +0100
THRIFT-5514 netstd test client slow in multithread mode
Client: netstd
Patch: Jens Geyer
---
test/netstd/Client/TestClient.cs | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs
index 0c80b9c..29c0d2e 100644
--- a/test/netstd/Client/TestClient.cs
+++ b/test/netstd/Client/TestClient.cs
@@ -411,15 +411,28 @@ namespace ThriftTest
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)
{
@@ -490,7 +503,7 @@ namespace ThriftTest
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;