basho/riak_kv — pull request #734 by evanmcc (2013-11-23 01:08:09+00:00)
Title: Refactor FSMs to do less work

And hopefully be a little bit faster. (Cluster speed tests will happen after vacation).

Four primary things have been done.:

1. changing the code wherever possible to pile up state mutations into a single operation to best take advantage of the compiler and avoid generating garbage.
1. Debugging and tracing code has been hidden behind the `Trace` variable, which also cuts down on FSM state tuple mutations, and doing extra work on platforms where we cannot benefit from it.
1. `proplists` module calls have been replaced with keyfind operations where possible as keyfind is a BIF.
1. In addition to the `proplists` changes, there has been some refactoring to avoid puling the default props from an ets table over and over again, they're now pulled at the start and merged with the bucket properties.

There are a few inconsistent places that I'll fix when I get back, I just wanted to get this in front of people in case someone had time to start their review before I got back.

Some simple single node performance tests done with this code: https://gist.github.com/evanmcc/c94f5c197760e0def652
The number before the rate type is the number of worker threads, testing was done on r2s10.bos.
```
| state/ref | 1 g/s | 128 g/s | 1 p/s | 128 p/s |
| baseline 2 | 2635 | 51856 | 1335 | 32522 |
| macro cleanup | 3862 | 63320 | 1494 | 37379 |
```