Reuse the same channel for all precompleted contexts
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 13 Jun 2020 15:41:23 +0000 (17:41 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Sun, 14 Jun 2020 13:50:00 +0000 (15:50 +0200)
commit6d43b73af18d23a4cab88dccf8d93a8eb423d2ed
treecd2f73ffe9b20bb6e72a97e1d5118cdbbc7a3674
parent3ee8799a0bb3e7ba3628b83832fb14462241643d
Reuse the same channel for all precompleted contexts

This avoids making a new channel and immediately closing it. `benchcmp`
says:

    benchmark                      old ns/op     new ns/op     delta
    BenchmarkPrecompleted-4        213           138           -35.21%

    benchmark                      old allocs    new allocs    delta
    BenchmarkPrecompleted-4        3             2             -33.33%

    benchmark                      old bytes     new bytes     delta
    BenchmarkPrecompleted-4        176           80            -54.55%
context.go