Skip to content

Commit 7ac25ba

Browse files
Deduplicate Index Meta Generations when Deserializing (#65619) (#65664)
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 735457c commit 7ac25ba

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
@@ -608,6 +608,7 @@ private static void parseSnapshots(XContentParser parser, Map<String, SnapshotId
608608
Map<String, Version> snapshotVersions,
609609
Map<SnapshotId, Map<String, String>> indexMetaLookup) throws IOException {
610610
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_ARRAY, parser.nextToken(), parser);
611+
final Map<String, String> stringDeduplicator = new HashMap<>();
611612
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
612613
String name = null;
613614
String uuid = null;
@@ -628,7 +629,7 @@ private static void parseSnapshots(XContentParser parser, Map<String, SnapshotId
628629
state = SnapshotState.fromValue((byte) parser.intValue());
629630
break;
630631
case INDEX_METADATA_LOOKUP:
631-
metaGenerations = parser.mapStrings();
632+
metaGenerations = parser.map(HashMap::new, p -> stringDeduplicator.computeIfAbsent(p.text(), Function.identity()));
632633
break;
633634
case VERSION:
634635
version = Version.fromString(parser.text());

0 commit comments

Comments
 (0)