RFR: 8292679: Simplify thread creation in gtest and port 2 tests to new way

Thomas Stuefe stuefe at openjdk.org
Mon Aug 22 15:33:21 UTC 2022


On Mon, 22 Aug 2022 10:53:27 GMT, Johan Sjölén <duke at openjdk.org> wrote:

> This PR removes a lot of boilerplate that was required when creating multi-threaded tests and ports 2 tests to show that the number of lines of code is significantly reduced and that porting is fairly trivial. The ported tests also serve as an introduction to others who're looking into writing their own multi-threaded tests.
> 
> Testing: Ran the ported tests on my machine, also running the tests on x64 {Windows, Linux, Mac OS X],  aarch64 { Linux, Mac OS X} and tier1 for "completeness".

I have tried to understand for the last half hour the interworkings of the State, the Stategenerator, and what the lambda arguments to TTG try to be. For the latter, I only see two cases: `[]() { return 0; }` and `[&]() { return &test; }`. So what purpose does have the state generator, if all we use it for is just generating constants? 

I worry that many of these improvements just increase the cognitive load, especially for the casual developer that does test fixes and backports, without bringing many benefits to the table.

test/hotspot/gtest/threadHelper.inline.hpp line 148:

> 146: };
> 147: 
> 148: // A TestThreadGroup tracks multiple threads running the same function.

So we have F, which is kind of clear, S, which is a state?, and then also a state generator? Which apparently needs to define operator () and return a state? Could you please document what the template parameters are and what is expected of them?

Does N really need to be a template parameter? You lose flexibility, and it is less readable too.

-------------

PR: https://git.openjdk.org/jdk/pull/9962


More information about the hotspot-dev mailing list