From cc28305f08e757d44b077ece9fc593cae7cdfc31 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 25 Oct 2021 18:07:08 -0700 Subject: [PATCH] fix: optimize handling for peers with lots of tasks This should fix a CPU hotspot when peers request tons of tiny blocks. --- go.mod | 2 +- go.sum | 4 ++-- internal/decision/taskmerger.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 548ca0de..f17667bc 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/ipfs/go-ipfs-util v0.0.2 github.com/ipfs/go-log v1.0.5 github.com/ipfs/go-metrics-interface v0.0.1 - github.com/ipfs/go-peertaskqueue v0.6.0 + github.com/ipfs/go-peertaskqueue v0.7.0 github.com/jbenet/goprocess v0.1.4 github.com/libp2p/go-buffer-pool v0.0.2 github.com/libp2p/go-libp2p v0.14.3 diff --git a/go.sum b/go.sum index 62b20d19..7f106286 100644 --- a/go.sum +++ b/go.sum @@ -302,8 +302,8 @@ github.com/ipfs/go-log/v2 v2.1.3 h1:1iS3IU7aXRlbgUpN8yTTpJ53NXYjAe37vcI5+5nYrzk= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= -github.com/ipfs/go-peertaskqueue v0.6.0 h1:BT1/PuNViVomiz1PnnP5+WmKsTNHrxIDvkZrkj4JhOg= -github.com/ipfs/go-peertaskqueue v0.6.0/go.mod h1:M/akTIE/z1jGNXMU7kFB4TeSEFvj68ow0Rrb04donIU= +github.com/ipfs/go-peertaskqueue v0.7.0 h1:VyO6G4sbzX80K58N60cCaHsSsypbUNs1GjO5seGNsQ0= +github.com/ipfs/go-peertaskqueue v0.7.0/go.mod h1:M/akTIE/z1jGNXMU7kFB4TeSEFvj68ow0Rrb04donIU= github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= github.com/jackpal/go-nat-pmp v1.0.1/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= diff --git a/internal/decision/taskmerger.go b/internal/decision/taskmerger.go index 19048641..191200e5 100644 --- a/internal/decision/taskmerger.go +++ b/internal/decision/taskmerger.go @@ -24,7 +24,7 @@ func newTaskMerger() *taskMerger { // The request queue uses this Method to decide if a newly pushed task has any // new information beyond the tasks with the same Topic (CID) in the queue. -func (*taskMerger) HasNewInfo(task peertask.Task, existing []peertask.Task) bool { +func (*taskMerger) HasNewInfo(task peertask.Task, existing []*peertask.Task) bool { haveSize := false isWantBlock := false for _, et := range existing {