forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into pointrange_optimization
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
- Loading branch information
Showing
121 changed files
with
5,397 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
benchmarks/src/main/java/org/opensearch/benchmark/routing/allocation/RerouteBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.benchmark.routing.allocation; | ||
|
||
import org.opensearch.Version; | ||
import org.opensearch.cluster.ClusterName; | ||
import org.opensearch.cluster.ClusterState; | ||
import org.opensearch.cluster.metadata.IndexMetadata; | ||
import org.opensearch.cluster.metadata.Metadata; | ||
import org.opensearch.cluster.node.DiscoveryNodes; | ||
import org.opensearch.cluster.routing.RoutingTable; | ||
import org.opensearch.cluster.routing.ShardRouting; | ||
import org.opensearch.cluster.routing.allocation.AllocationService; | ||
import org.opensearch.common.logging.LogConfigurator; | ||
import org.opensearch.common.settings.Settings; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Param; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.opensearch.cluster.routing.ShardRoutingState.INITIALIZING; | ||
|
||
@Fork(1) | ||
@Warmup(iterations = 3) | ||
@Measurement(iterations = 3) | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
@State(Scope.Benchmark) | ||
@SuppressWarnings("unused") // invoked by benchmarking framework | ||
public class RerouteBenchmark { | ||
@Param({ | ||
// indices| nodes | ||
" 10000| 500|", }) | ||
public String indicesNodes = "1|1"; | ||
public int numIndices; | ||
public int numNodes; | ||
public int numShards = 10; | ||
public int numReplicas = 1; | ||
|
||
private AllocationService allocationService; | ||
private ClusterState initialClusterState; | ||
|
||
@Setup | ||
public void setUp() throws Exception { | ||
LogConfigurator.setNodeName("test"); | ||
final String[] params = indicesNodes.split("\\|"); | ||
numIndices = toInt(params[0]); | ||
numNodes = toInt(params[1]); | ||
|
||
int totalShardCount = (numReplicas + 1) * numShards * numIndices; | ||
Metadata.Builder mb = Metadata.builder(); | ||
for (int i = 1; i <= numIndices; i++) { | ||
mb.put( | ||
IndexMetadata.builder("test_" + i) | ||
.settings(Settings.builder().put("index.version.created", Version.CURRENT)) | ||
.numberOfShards(numShards) | ||
.numberOfReplicas(numReplicas) | ||
); | ||
} | ||
|
||
Metadata metadata = mb.build(); | ||
RoutingTable.Builder rb = RoutingTable.builder(); | ||
for (int i = 1; i <= numIndices; i++) { | ||
rb.addAsNew(metadata.index("test_" + i)); | ||
} | ||
RoutingTable routingTable = rb.build(); | ||
initialClusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)) | ||
.metadata(metadata) | ||
.routingTable(routingTable) | ||
.nodes(setUpClusterNodes(numNodes)) | ||
.build(); | ||
} | ||
|
||
@Benchmark | ||
public ClusterState measureShardAllocationEmptyCluster() throws Exception { | ||
ClusterState clusterState = initialClusterState; | ||
allocationService = Allocators.createAllocationService( | ||
Settings.builder() | ||
.put("cluster.routing.allocation.awareness.attributes", "zone") | ||
.put("cluster.routing.allocation.load_awareness.provisioned_capacity", numNodes) | ||
.put("cluster.routing.allocation.load_awareness.skew_factor", "50") | ||
.put("cluster.routing.allocation.node_concurrent_recoveries", "2") | ||
.build() | ||
); | ||
clusterState = allocationService.reroute(clusterState, "reroute"); | ||
while (clusterState.getRoutingNodes().hasUnassignedShards()) { | ||
clusterState = startInitializingShardsAndReroute(allocationService, clusterState); | ||
} | ||
return clusterState; | ||
} | ||
|
||
private int toInt(String v) { | ||
return Integer.valueOf(v.trim()); | ||
} | ||
|
||
private DiscoveryNodes.Builder setUpClusterNodes(int nodes) { | ||
DiscoveryNodes.Builder nb = DiscoveryNodes.builder(); | ||
for (int i = 1; i <= nodes; i++) { | ||
Map<String, String> attributes = new HashMap<>(); | ||
attributes.put("zone", "zone_" + (i % 3)); | ||
nb.add(Allocators.newNode("node_0_" + i, attributes)); | ||
} | ||
return nb; | ||
} | ||
|
||
private static ClusterState startInitializingShardsAndReroute(AllocationService allocationService, ClusterState clusterState) { | ||
return startShardsAndReroute(allocationService, clusterState, clusterState.routingTable().shardsWithState(INITIALIZING)); | ||
} | ||
|
||
private static ClusterState startShardsAndReroute( | ||
AllocationService allocationService, | ||
ClusterState clusterState, | ||
List<ShardRouting> initializingShards | ||
) { | ||
return allocationService.reroute(allocationService.applyStartedShards(clusterState, initializingShards), "reroute after starting"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5d753a99d299756998a08c488f2efdf9cf26198e |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dab1e18842971a45ca8942491ce005ab86a028d7 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
09425df4d1365cee86a8e031a036bdca4343da4b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
f68949965075b957c12b4c1ef89fd4bab2a0fdb1 |
Oops, something went wrong.