Use small_vector<T,N> for EventCommand::parameters
EventCommands are pervasive and take up a good portion of total memory usage. Event commands have a dynamic list of parameters but most of them use few (< 10?) parameters. Many commands have a fixed size number of parameters. small_vector<T,N> is perfectly suited for this situation.
- Survery a bunch of games to find a good value for N.
- Write or import a small_vector implementation into liblcf.
- Change
EventCommand::parametersand others if it makes sense.
Using small_vector will greatly improve cache locality when interpreting event streams. This should result in higher performance in Player.
It'll also result in dramatically fewer memory allocations, resulting in measurably higher lcf reading performance. Less allocations also means less memory overhead, which should slightly reduce memory usage of liblcf.
Small vector has the same interface as vector, so it can be an easy drop-in replacement.
Some example implementations are here:
- https://github.com/facebook/folly/blob/master/folly/docs/small_vector.md
- http://llvm.org/doxygen/SmallVector_8h_source.html
iirc the only "long" commands are Show/Move Picture, Inn (item list) and Move event (the whole move route), we could parse through all games in our test set and calculate statistics about the parameter length to get the optimal result.