Here's why the pre-alloc matters: It *dominates* this benchmark.
Here's why the pre-alloc matters: It *dominates* this benchmark.

Compare against `git diff HEAD^` so the results of the memory-pressure issue in the previous commit aren't a distraction:

-               BenchmarkLatchAllocation                 5000000               322 ns/op
-               BenchmarkBaseline_JsonUnmarshalling      1000000              1967 ns/op
-               BenchmarkLatchTrigger_0Listeners         3000000               538 ns/op
-               BenchmarkLatchTrigger_1Listeners         1000000              1406 ns/op
-               BenchmarkLatchTrigger_2Listeners          500000              2578 ns/op
-               BenchmarkLatchTrigger_4Listeners          300000              4291 ns/op
-               BenchmarkLatchTrigger_8Listeners          200000              8040 ns/op
+               BenchmarkLatchAllocation                 5000000               344 ns/op
+               BenchmarkBaseline_JsonUnmarshalling       100000             14420 ns/op
+               BenchmarkLatchTrigger_0Listeners        10000000               188 ns/op
+               BenchmarkLatchTrigger_1Listeners         5000000               255 ns/op
+               BenchmarkLatchTrigger_2Listeners         5000000               316 ns/op
+               BenchmarkLatchTrigger_4Listeners         3000000               462 ns/op
+               BenchmarkLatchTrigger_8Listeners         2000000               729 ns/op

With this change, the benchmarks still show the (expected, correct) linear progression.  The diff here also shows that the creation and subscription of the channels is on the order of 10x more expensive than the locks used in triggering.  This is a pretty remarkable result; I wouldn't have expected it so high.  Of course, this is also uncontended operations, which is a very degenerate case and may not be representative of many real world situations.

Also, the BenchmarkLatchTrigger* results are now unphased (? or at least certainly not dominated by) the additional costs in memory pressure created by BenchmarkLatchAllocation.  This is probably because, well, there are no more allocs at all inside the loop on those benches; they all happened preceding the `ResetTimer`.

Signed-off-by: Eric Myhre <2346ad27d7568ba9896f1b7da6b5991251debdf2@exultant.us>

polydawn/go-sup,polydawn/go-sup