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

Test GMP impact on performance #16

Open
Boyan-MILANOV opened this issue Dec 25, 2021 · 1 comment
Open

Test GMP impact on performance #16

Boyan-MILANOV opened this issue Dec 25, 2021 · 1 comment
Assignees
Labels
core Maat core internals enhancement New feature or request refactoring Code refactoring & restructuration

Comments

@Boyan-MILANOV
Copy link
Collaborator

Following comments about improving performance in #5:

If using GNU MP turns out to be a bottleneck, here are some alternatives to consider

Random thoughts:

  • Using uint512_t instead of true multiprecision numbers could be useful it it allows the library to use stack-allocated objects instead of dynamically allocating them
  • The most important point is not how fast the multi-precision computation is but rather how efficient the object creation/copy is. MP numbers are part of Maat's Number class, and Number objects are created all the time, so the cost of creation of an MP object is by far the most important
@Boyan-MILANOV Boyan-MILANOV added enhancement New feature or request core Maat core internals refactoring Code refactoring & restructuration labels Dec 25, 2021
@Boyan-MILANOV Boyan-MILANOV self-assigned this Dec 25, 2021
@Boyan-MILANOV
Copy link
Collaborator Author

Boyan-MILANOV commented Jan 1, 2022

I need to confirm this but it seems that mpz objects are not initialised when default-constructed, resulting in no extra memory allocation. This means virtually no overhead (except calling the mpz_class constructor) when using Number with values on 64 bits or less. If it is indeed the case then using GMP is less an issue than I originally thought, and the room for improvement gets much smaller (for values on less than 64 bits). We could consider to stick with GMP.

Cases where GMP could still impact performance significantly would be

  • code using A LOT of SSE2/AVX instructions, manipulating mostly 128+ bits values
  • EVM bytecode if we decide to support it, because it uses uint256_t a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Maat core internals enhancement New feature or request refactoring Code refactoring & restructuration
Projects
None yet
Development

No branches or pull requests

1 participant