Some further optimization, reducing memory usage

This commit is contained in:
Till Faelligen 2024-01-19 10:13:36 +01:00
parent f6c0c0c488
commit 606a0c552d
No known key found for this signature in database
GPG key ID: ACCDC9606D472758

View file

@ -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 {