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

mod optimisations #239

Merged
merged 1 commit into from
Jan 12, 2024
Merged

Conversation

shramee
Copy link
Contributor

@shramee shramee commented Jan 10, 2024

Pull Request type

Optimisations for mod arithmetics.

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Mod operations not as fast as they can be.

Issue Number: N/A

What is the new behavior?

⚠️ div_mod test included here is added in PR #238

DIVISION OPTIMISATION (from core::math functions)
// div_mod_test     BEFORE gas usage est.: 97351914
// div_mod_test     BEFORE gas usage est.: 277900

MINOR optimisations (from inline)
// add_mod_1_test   BEFORE gas usage est.: 163180
// add_mod_1_test   AFTER gas usage est.:  159880
// add_mod_2_test   BEFORE gas usage est.: 109020
// add_mod_2_test   AFTER gas usage est.:  106820
// add_mod_p_test   BEFORE gas usage est.: 433980
// add_mod_p_test   AFTER gas usage est.:  425180
// mult_mod_1_test  BEFORE gas usage est.: 455340
// mult_mod_1_test  AFTER gas usage est.:  444940
// mult_mod_2_test  BEFORE gas usage est.: 455340
// mult_mod_2_test  AFTER gas usage est.:  444940
// mult_mod_test    BEFORE gas usage est.: 455340
// mult_mod_test    AFTER gas usage est.:  444940
// sub_mod_1_test   BEFORE gas usage est.: 330380
// sub_mod_1_test   AFTER gas usage est.:  319980
// sub_mod_2_test   BEFORE gas usage est.: 330380
// sub_mod_2_test   AFTER gas usage est.:  319980
// sub_mod_test     BEFORE gas usage est.: 356100
// sub_mod_test     AFTER gas usage est.:  346300

Does this introduce a breaking change?

  • Yes
  • No

Other information

@shramee shramee requested a review from 0xLucqs as a code owner January 10, 2024 16:25
@0xLucqs 0xLucqs merged commit 9fe154f into keep-starknet-strange:main Jan 12, 2024
3 checks passed
@shramee shramee deleted the fast-mod-ops branch January 12, 2024 17:57
@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants