From 606a0c552da468ae16f739756c9a425423307eaa Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:13:36 +0100 Subject: [PATCH] Some further optimization, reducing memory usage --- roomserver/api/perform.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/roomserver/api/perform.go b/roomserver/api/perform.go index 22346df80..1fae40f52 100644 --- a/roomserver/api/perform.go +++ b/roomserver/api/perform.go @@ -94,7 +94,11 @@ type PerformBackfillRequest struct { // PrevEventIDs returns the prev_event IDs of all backwards extremities, de-duplicated in a lexicographically sorted order. func (r *PerformBackfillRequest) PrevEventIDs() []string { // Collect 1k eventIDs, if possible, they may be cleared out below - prevEventIDs := make([]string, 0, len(r.BackwardsExtremities)*3) + maxPrevEventIDs := len(r.BackwardsExtremities) * 3 + if maxPrevEventIDs > 2000 { + maxPrevEventIDs = 2000 + } + prevEventIDs := make([]string, 0, maxPrevEventIDs) for _, pes := range r.BackwardsExtremities { prevEventIDs = append(prevEventIDs, pes...) if len(prevEventIDs) > 1000 {