upthewaterspout commented on a change in pull request #25: GEODE-6148: improve
performance of Prepopulate
URL: https://github.com/apache/geode-benchmarks/pull/25#discussion_r240837297
##########
File path:
geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PrePopulateRegion.java
##########
@@ -50,14 +56,36 @@ public PrePopulateRegion(long keyRangeToPrepopulate) {
public void run(TestContext context) {
Cache serverCache = (Cache) context.getAttribute("SERVER_CACHE");
Region region = serverCache.getRegion("region");
+
+ int numLocators = context.getHostsForRole(LOCATOR).size();
+ int numServers = context.getHostsForRole(SERVER).size();
+ int serverIndex = context.getJvmID() - numLocators;
+ int numPutsPerServer = (int) this.keyRangeToPrepopulate / numServers;
+
+ AtomicInteger lowBound = new AtomicInteger();
+ AtomicInteger highBound = new AtomicInteger();
+
+ // calculate non-overlapping key ranges for each server
+ lowBound.set(numPutsPerServer * serverIndex);
+ highBound.set(numPutsPerServer * (serverIndex + 1));
+ if (serverIndex == (numServers - 1)) {
+ highBound.getAndAdd((int) this.keyRangeToPrepopulate % (serverIndex +
1));
+ }
+
+ // build a map of to put to the server
+ Map<Long, PortfolioPdx> valueMap = new HashMap<>();
+ LongStream.range(lowBound.get(), highBound.get()).forEach(i -> {
+ long value = ThreadLocalRandom.current().nextLong(lowBound.get(),
highBound.get());
Review comment:
I don't think we really want to use ThreadLocalRandom - why not just put all
of the keys in our range?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services