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

feat(p/int256): Optimize int256 with two's complement implementation #2846

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

notJoon
Copy link
Member

@notJoon notJoon commented Sep 25, 2024

Description

This PR optimizes the implementation of int256 type. Key changes include:

  • Changed from storing sign and value separately in the Int256 struct to an implementation using two's complement method.
  • This reduces unnecessary operations and improves overall performance.

Performance Result

  • Basic arithmetic operations (addition, subtraction, etc.): About 3x performance improvement (based on Go benchmarks, may differ slightly in gno)
  • Division operations: Up to 5x performance decrease compared to the previous implementation (can be improved by directly manipulating array fields, but not applied to avoid duplication with p/demo/uint256)

Additional improvements:

  • Increased test coverage to 95%.

This change is expected to improve performance for most int256 operations. However, please note the performance degradation in division operations.

See Also

#2750 (review)

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Sep 25, 2024
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.91%. Comparing base (4f6ca96) to head (7053e0b).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2846      +/-   ##
==========================================
- Coverage   60.91%   60.91%   -0.01%     
==========================================
  Files         564      564              
  Lines       75273    75273              
==========================================
- Hits        45851    45850       -1     
- Misses      26053    26054       +1     
  Partials     3369     3369              
Flag Coverage Δ
contribs/gnodev 61.46% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (-0.86%) ⬇️
gno.land 67.17% <ø> (ø)
gnovm 65.77% <ø> (ø)
misc/genstd 80.54% <ø> (ø)
misc/logos 19.88% <ø> (ø)
tm2 62.07% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@notJoon notJoon marked this pull request as ready for review September 26, 2024 09:19
@notJoon notJoon requested review from a team as code owners September 26, 2024 09:19
@notJoon notJoon requested review from gfanton and petar-dambovaliev and removed request for a team September 26, 2024 09:19
@Kouteki Kouteki added review team PRs that should be reviewed first by the review team or external contributors and removed review team PRs that should be reviewed first by the review team or external contributors labels Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Status: In Review
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants