nytlabs/st-core — pull request #29 by nikhan (2014-12-26 05:57:24+00:00)
Title: store and block improvements, added first and several benchmarks, introducing interntalState

Big PR!

- stores were improved by moving the mutexes outside of the kernel. The mutexes are now conditionally locked by the block. see how this works [here](https://github.com/nikhan/st-core/blob/master/core/block.go#L188). The block will also block if it requires a external store and wait for an interrupt.
- store.go is now keyvalue.go
- key value kernels now fail properly when handed bad data
- added block_test.go, which is meant for testing end-to-end block patterns. Check this out:

GOMAXPROCS=1
```
BenchmarkAddition	2000000000	0.16 ns/op
BenchmarkRandomMath	1000000000	0.89 ns/op
```
GOMAXPROCS=4
```
BenchmarkAddition-4	1000000000	0.59 ns/op
BenchmarkRandomMath-4	5000	216294 ns/op
```
:confounded: :question: :exclamation:
the docs say that when the operations are really small and there is a lot of channel traffic, having more than one proc available can result in a bunch of context switching. something to tune I suppose.
- null stream test verifies that we can stream nulls
- *added internalState* which allows for stateful blocks like First. This is possibly contentious, but I don't know of any other graceful way to solve it. All internalState is is just a another MessageMap like `in` and `out`, with the only difference is that this map is not cleared each crank.