Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use small_vector<T,N> for EventCommand::parameters #254

Open
mateofio opened this issue Oct 5, 2018 · 1 comment
Open

Use small_vector<T,N> for EventCommand::parameters #254

mateofio opened this issue Oct 5, 2018 · 1 comment

Comments

@mateofio
Copy link
Contributor

mateofio commented Oct 5, 2018

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.

  1. Survery a bunch of games to find a good value for N.
  2. Write or import a small_vector implementation into liblcf.
  3. Change EventCommand::parameters and 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:

@Ghabry
Copy link
Member

Ghabry commented Oct 30, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants