Skip to content

Commit 745f527

Browse files
Deduplicate Index Meta Generations when Deserializing (#65619) (#65666)
These strings are quite long individually and will be repeated potentially up to the number of snapshots in the repository times. Since these make up more than half of the size of the repository metadata and are likely the same for all snapshots the savings from deduplicating them can make up for more than half the size of `RepositoryData` easily in most real-world cases.
1 parent f8f08ba commit 745f527

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

server/src/main/java/org/elasticsearch/repositories/RepositoryData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ private static void parseSnapshots(XContentParser parser, Map<String, SnapshotId
610610
Map<String, Version> snapshotVersions,
611611
Map<SnapshotId, Map<String, String>> indexMetaLookup) throws IOException {
612612
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_ARRAY, parser.nextToken(), parser);
613+
final Map<String, String> stringDeduplicator = new HashMap<>();
613614
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
614615
String name = null;
615616
String uuid = null;
@@ -630,7 +631,7 @@ private static void parseSnapshots(XContentParser parser, Map<String, SnapshotId
630631
state = SnapshotState.fromValue((byte) parser.intValue());
631632
break;
632633
case INDEX_METADATA_LOOKUP:
633-
metaGenerations = parser.mapStrings();
634+
metaGenerations = parser.map(HashMap::new, p -> stringDeduplicator.computeIfAbsent(p.text(), Function.identity()));
634635
break;
635636
case VERSION:
636637
version = Version.fromString(parser.text());

0 commit comments

Comments
 (0)