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

Benchmark to test GEODE-7763 #127

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

kohlmu-pivotal
Copy link

This benchmark is to test the use case where many threads (on the same client) try to access/modify the same key. With the removal of the client's Future cache in 1.10, there was a performance degradation that went unnoticed and unmeasured.
This benchmark is there to make sure that this does not go unnoticed again.

Udo Kohlmeyer and others added 2 commits March 9, 2020 12:33
In this benchmark a client has many thread (180)
which all try and access/modify the same key. This is to
test the performance of GEODE since the removal of the
client Futures cache, which was removed in 1.10.
public void run(TestContext context) throws Exception {
PoolFactory poolFactory = PoolManager.createFactory();
poolFactory
.addLocator("localhost", 10334)
Copy link
Contributor

Choose a reason for hiding this comment

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

See other tests on how to get the locator and port. This falsely assumes the locator is localhost but when running on multiple hosts this may not be the case.

}
}

private class CreateClientPool implements Task {
Copy link
Contributor

Choose a reason for hiding this comment

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

May want to consider extending the existing CreateClient Task.

@Override
public TestConfig configure() {
TestConfig config = GeodeBenchmark.createConfig();
config.threads(180);
Copy link
Contributor

Choose a reason for hiding this comment

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

See the tests where these are not hard coded.

public boolean test(Map<Object, Object> ctx) throws Exception {
int sessionAttributeCount = runSessionWorkload();

assert sessionAttributeCount == this.existingSessionAttributeNames.size();
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave assert out of here. We never run with asserts enabled. Write a unit test for this benchmark that asserts the behavior you expect.

return session;
}

private int runSessionWorkload() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The workload is fixed and small so this seems like an overly complicated version of:

return workload1() + workload2() + workload3();

We end up benchmarking the cost of streams and lambdas too.

private final List<String> existingSessionAttributeNames =
new ArrayList<>();

private final Random random = new Random(System.currentTimeMillis());
Copy link
Contributor

Choose a reason for hiding this comment

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

Random isn't re-entrant and can be a bottleneck if 180 threads are trying to access it. Consider ThreadLocalRandom.

return () -> {
Session session = findById(this.sessionId.get());

String name = UUID.randomUUID().toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

UUID.randomUUID() utilizes secure random to generate an array of bytes, which is not only more computationally more complex it also suffered similar contention issues that Random has. Also keeping in mind that those bytes are transient allocations and have impact on the GC and benchmark measurements.

If UUID is desired then you may want to construct UUIDs byte fetching 2 longs from ThreadLocalRandom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants