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

perf: Speedup DecCoin.Sort() when coins is of length 1 #18888

Merged
merged 3 commits into from
Dec 26, 2023

Conversation

DongLieu
Copy link
Contributor

Similar to PR #18875, I think that we should avoid this heap allocation if len(coins) <= 1.

@DongLieu DongLieu requested a review from a team as a code owner December 26, 2023 09:21
Copy link
Contributor

coderabbitai bot commented Dec 26, 2023

Warning

Rate Limit Exceeded

@DongLieu has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 12 minutes and 54 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between b7f60d8 and 297fb33.

Walkthrough

The update to the DecCoins type involves an optimization in its Sort method. The method now includes a conditional check that determines whether to invoke sort.Sort. This check is based on the size of the coins slice, aiming to bypass an unnecessary runtime copy when certain conditions are met, thus potentially improving performance.

Changes

File Path Change Summary
types/dec_coin.go Optimized Sort method in DecCoins to conditionally use sort.Sort, reducing runtime copies for specific slice lengths. Enhanced coins.Sort() method under the types category.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat with CodeRabbit Bot (@coderabbitai)

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your comments unless it is explicitly tagged.

  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file
    • @coderabbitai modularize this function
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai gather interesting statistics about this repository and render them in a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai generate unit tests for the src/utils.ts file.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

CHANGELOG.md Outdated Show resolved Hide resolved
@facundomedica facundomedica added this pull request to the merge queue Dec 26, 2023
@facundomedica facundomedica added backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release labels Dec 26, 2023
Merged via the queue into cosmos:main with commit de4c9e7 Dec 26, 2023
55 of 57 checks passed
mergify bot pushed a commit that referenced this pull request Dec 26, 2023
(cherry picked from commit de4c9e7)

# Conflicts:
#	CHANGELOG.md
mergify bot pushed a commit that referenced this pull request Dec 26, 2023
(cherry picked from commit de4c9e7)

# Conflicts:
#	CHANGELOG.md
tac0turtle added a commit that referenced this pull request Dec 26, 2023
…) (#18889)

Co-authored-by: Dong Lieu <93205232+DongLieu@users.noreply.github.com>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
tac0turtle added a commit that referenced this pull request Dec 26, 2023
…) (#18890)

Co-authored-by: Dong Lieu <93205232+DongLieu@users.noreply.github.com>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
MSalopek pushed a commit to informalsystems/cosmos-sdk that referenced this pull request Feb 27, 2024
…os#18888) (cosmos#18890)

Co-authored-by: Dong Lieu <93205232+DongLieu@users.noreply.github.com>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
@faddat faddat mentioned this pull request Mar 20, 2024
12 tasks
emidev98 pushed a commit to terra-money/cosmos-sdk that referenced this pull request Mar 21, 2024
…os#18888) (cosmos#18890)

Co-authored-by: Dong Lieu <93205232+DongLieu@users.noreply.github.com>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants