From 39afdcfdd3013c0c147dc9101c5acd55295a7cb8 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 2 Jul 2021 10:16:18 +0100 Subject: [PATCH] Process EDUs in parallel --- federationapi/routing/send.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go index a817e837..f3dd62e8 100644 --- a/federationapi/routing/send.go +++ b/federationapi/routing/send.go @@ -263,7 +263,12 @@ func (t *txnReq) processTransaction(ctx context.Context) (*gomatrixserverlib.Res pdus = nil // nolint:ineffassign var wg sync.WaitGroup - wg.Add(len(perRoom)) + wg.Add(len(perRoom) + 1) + + go func() { + defer wg.Done() + t.processEDUs(ctx) + }() for _, q := range perRoom { go func(q chan *gomatrixserverlib.Event) { @@ -335,7 +340,6 @@ func (t *txnReq) processTransaction(ctx context.Context) (*gomatrixserverlib.Res perRoom[k] = nil } - t.processEDUs(ctx) if c := len(results); c > 0 { util.GetLogger(ctx).Infof("Processed %d PDUs from transaction %q", c, t.TransactionID) }