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

Improve response times for large number of attacks #11

Closed
damonhook opened this issue Feb 3, 2020 · 1 comment · Fixed by #12
Closed

Improve response times for large number of attacks #11

damonhook opened this issue Feb 3, 2020 · 1 comment · Fixed by #12
Assignees
Labels
api The issue relates to the Nodejs API (Backend) enhancement New feature or request
Milestone

Comments

@damonhook
Copy link
Owner

damonhook commented Feb 3, 2020

Very large numbers of attacks causes a very large number of permutations to be generated. The memory issues have been resolved by moving to a generator, however, the response time is still too high for attacks 10+

Instead of creating results on a per toughness basis, the fighters.ts model should instead loop through the permutations once, appending to lt, eq, and gt objects. These can then be extracted properly in the statsController.

@damonhook damonhook added enhancement New feature or request api The issue relates to the Nodejs API (Backend) labels Feb 3, 2020
@damonhook
Copy link
Owner Author

Another idea is that if the number of attacks exceeds 10, we can switch from population stats, to simulations

@damonhook damonhook linked a pull request Feb 5, 2020 that will close this issue
@damonhook damonhook self-assigned this Feb 5, 2020
@damonhook damonhook added this to the v0.2.0 milestone Feb 5, 2020
damonhook added a commit that referenced this issue Feb 6, 2020
## UI

- The Left Navigation Bar on Desktop has been revamped and will no longer scroll with the content.

## API

- Instead of generating data per toughness, instead build `lt`, `eq`, `gt` properties. Then map that to the different toughness values (Fixes: #13)
    - This should have no difference in the final result, however, should improve performance greatly
- If you try and generate data for attacks > 8, switch to a simulation of dice rolls rather than generating every permutation (Fixes: #13)
- Added Sentry to API to capture errors (Fixes: #11)

## Notes
Here is a table of the number of permutations as the attacks grow:

| Attacks | Permutations  |
|---------|---------------|
| 2       | 36            |
| 4       | 1 296         |
| 6       | 46 656        |
| 8       | 1 679 616     |
| 10      | 60 466 176    |
| 12      | 2 176 782 336 |

Because of this it becomes too expensive to get population permutations for attacks > 8. Hence why it switches over to doing `1 500 000` simulations instead. It should be accurate enough as the probabilities are limited to 2 dec. places on the UI anyway
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api The issue relates to the Nodejs API (Backend) enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant