Skip to content

Commit c35942b

Browse files
committed
Reuse local node in async shard fetch responses
We read various objects from the wire that already exist in the cluster state. The most notable is `DiscoveryNode` which can consume ~2kB in heap for each fresh object, but rarely changes, so it's pretty wasteful to use fresh objects here. There could be thousands (millions?) of `DiscoveryNode` objects in flight from various `TransportNodesAction` responses. This branch adds a `DiscoveryNode` parameter to the response deserialisation method and makes sure that the worst offenders re-use the local object rather than creating a fresh one: - `TransportNodesListShardStoreMetadata` - `TransportNodesListGatewayStartedShards` Relates #77266
1 parent 303d7b8 commit c35942b

File tree

36 files changed

+112
-45
lines changed

36 files changed

+112
-45
lines changed

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsTransportAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.action.FailedNodeException;
1212
import org.elasticsearch.action.support.ActionFilters;
1313
import org.elasticsearch.action.support.nodes.TransportNodesAction;
14+
import org.elasticsearch.cluster.node.DiscoveryNode;
1415
import org.elasticsearch.cluster.service.ClusterService;
1516
import org.elasticsearch.common.inject.Inject;
1617
import org.elasticsearch.common.io.stream.StreamInput;
@@ -57,7 +58,7 @@ protected NodeRequest newNodeRequest(Request request) {
5758
}
5859

5960
@Override
60-
protected NodeResponse newNodeResponse(StreamInput in) throws IOException {
61+
protected NodeResponse newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
6162
return new NodeResponse(in);
6263
}
6364

server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.elasticsearch.action.FailedNodeException;
1313
import org.elasticsearch.action.support.ActionFilters;
1414
import org.elasticsearch.action.support.nodes.TransportNodesAction;
15+
import org.elasticsearch.cluster.node.DiscoveryNode;
1516
import org.elasticsearch.cluster.service.ClusterService;
1617
import org.elasticsearch.common.inject.Inject;
1718
import org.elasticsearch.common.io.stream.StreamInput;
@@ -49,7 +50,7 @@ protected NodeRequest newNodeRequest(NodesHotThreadsRequest request) {
4950
}
5051

5152
@Override
52-
protected NodeHotThreads newNodeResponse(StreamInput in) throws IOException {
53+
protected NodeHotThreads newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
5354
return new NodeHotThreads(in);
5455
}
5556

server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.action.FailedNodeException;
1212
import org.elasticsearch.action.support.ActionFilters;
1313
import org.elasticsearch.action.support.nodes.TransportNodesAction;
14+
import org.elasticsearch.cluster.node.DiscoveryNode;
1415
import org.elasticsearch.cluster.service.ClusterService;
1516
import org.elasticsearch.common.inject.Inject;
1617
import org.elasticsearch.common.io.stream.StreamInput;
@@ -52,7 +53,7 @@ protected NodeInfoRequest newNodeRequest(NodesInfoRequest request) {
5253
}
5354

5455
@Override
55-
protected NodeInfo newNodeResponse(StreamInput in) throws IOException {
56+
protected NodeInfo newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
5657
return new NodeInfo(in);
5758
}
5859

server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/TransportNodesReloadSecureSettingsAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected NodeRequest newNodeRequest(NodesReloadSecureSettingsRequest request) {
6767
}
6868

6969
@Override
70-
protected NodesReloadSecureSettingsResponse.NodeResponse newNodeResponse(StreamInput in) throws IOException {
70+
protected NodesReloadSecureSettingsResponse.NodeResponse newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
7171
return new NodesReloadSecureSettingsResponse.NodeResponse(in);
7272
}
7373

server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.action.FailedNodeException;
1212
import org.elasticsearch.action.support.ActionFilters;
1313
import org.elasticsearch.action.support.nodes.TransportNodesAction;
14+
import org.elasticsearch.cluster.node.DiscoveryNode;
1415
import org.elasticsearch.cluster.service.ClusterService;
1516
import org.elasticsearch.common.inject.Inject;
1617
import org.elasticsearch.common.io.stream.StreamInput;
@@ -54,7 +55,7 @@ protected NodeStatsRequest newNodeRequest(NodesStatsRequest request) {
5455
}
5556

5657
@Override
57-
protected NodeStats newNodeResponse(StreamInput in) throws IOException {
58+
protected NodeStats newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
5859
return new NodeStats(in);
5960
}
6061

server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/TransportNodesUsageAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.action.FailedNodeException;
1212
import org.elasticsearch.action.support.ActionFilters;
1313
import org.elasticsearch.action.support.nodes.TransportNodesAction;
14+
import org.elasticsearch.cluster.node.DiscoveryNode;
1415
import org.elasticsearch.cluster.service.ClusterService;
1516
import org.elasticsearch.common.inject.Inject;
1617
import org.elasticsearch.common.io.stream.StreamInput;
@@ -55,7 +56,7 @@ protected NodeUsageRequest newNodeRequest(NodesUsageRequest request) {
5556
}
5657

5758
@Override
58-
protected NodeUsage newNodeResponse(StreamInput in) throws IOException {
59+
protected NodeUsage newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
5960
return new NodeUsage(in);
6061
}
6162

server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected NodeRequest newNodeRequest(Request request) {
8181
}
8282

8383
@Override
84-
protected NodeSnapshotStatus newNodeResponse(StreamInput in) throws IOException {
84+
protected NodeSnapshotStatus newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
8585
return new NodeSnapshotStatus(in);
8686
}
8787

server/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.cluster.health.ClusterHealthStatus;
2424
import org.elasticsearch.cluster.health.ClusterStateHealth;
2525
import org.elasticsearch.cluster.metadata.Metadata;
26+
import org.elasticsearch.cluster.node.DiscoveryNode;
2627
import org.elasticsearch.cluster.service.ClusterService;
2728
import org.elasticsearch.common.inject.Inject;
2829
import org.elasticsearch.common.io.stream.StreamInput;
@@ -119,7 +120,7 @@ protected ClusterStatsNodeRequest newNodeRequest(ClusterStatsRequest request) {
119120
}
120121

121122
@Override
122-
protected ClusterStatsNodeResponse newNodeResponse(StreamInput in) throws IOException {
123+
protected ClusterStatsNodeResponse newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
123124
return new ClusterStatsNodeResponse(in);
124125
}
125126

server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/TransportFindDanglingIndexAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected NodeFindDanglingIndexRequest newNodeRequest(FindDanglingIndexRequest r
7575
}
7676

7777
@Override
78-
protected NodeFindDanglingIndexResponse newNodeResponse(StreamInput in) throws IOException {
78+
protected NodeFindDanglingIndexResponse newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
7979
return new NodeFindDanglingIndexResponse(in);
8080
}
8181

server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/TransportListDanglingIndicesAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected NodeListDanglingIndicesRequest newNodeRequest(ListDanglingIndicesReque
7676
}
7777

7878
@Override
79-
protected NodeListDanglingIndicesResponse newNodeResponse(StreamInput in) throws IOException {
79+
protected NodeListDanglingIndicesResponse newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
8080
return new NodeListDanglingIndicesResponse(in);
8181
}
8282

0 commit comments

Comments
 (0)