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: batch size with tmdb wrapper #582

Merged
merged 1 commit into from
Mar 22, 2024
Merged

Conversation

cool-develope
Copy link

@cool-develope cool-develope commented Mar 21, 2024

Description

Unblock the BatchWithFlusher of the iavl/v1. Maybe it won't get the full advantage since NewBatchWithSize is not fully implemented.
Following the goleveldb approach to calc the batch size.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Copy link

coderabbitai bot commented Mar 21, 2024

Walkthrough

The modifications introduce a more efficient way to handle data in the tmdb.go file, focusing on streamlining data size calculation and improving type handling. By adding a new field to track data size directly within the BatchWrapper and refining method implementations, these changes enhance both accuracy and performance in data operations.

Changes

File Summary
.../tmdb.go Added encoding/binary import, refined Iterator and ReverseIterator, updated BatchWrapper, and optimized size calculations in Set, Delete, and GetByteSize.

🐇✨
In the realm of code, under digital skies,
A rabbit hopped, with bright, keen eyes.
"A change," it said, "brings a new sunrise,
Efficiency found, in size it lies."
Through binary lands, it leaps and flies,
Crafting the future, as the old code sighs.
🌟📜🚀

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

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2a10cdb and 6c14228.
Files selected for processing (1)
  • store/wrapper/tmdb.go (4 hunks)
Additional comments: 8
store/wrapper/tmdb.go (8)
  • 4-4: The addition of the encoding/binary import is appropriate given its usage in the Set and Delete methods for calculating sizes. Good practice to include only necessary imports.
  • 44-44: Removing type assertions in the Iterator and ReverseIterator functions can enhance performance and readability. Ensure that the returned types conform to the iavldb.Iterator interface.
  • 74-74: The addition of the size field in the BatchWrapper struct is a crucial enhancement for tracking the size of batch operations. This aligns well with the PR's objectives to optimize batch processing.
  • 82-82: The logic to calculate the size of operations in the Set method is correctly implemented. Consider defining constants for the magic numbers (e.g., 1 + binary.MaxVarintLen32) for better readability and maintainability.
  • 87-87: Similarly, the Delete method's size calculation is appropriate. As with the Set method, using constants for the magic numbers could enhance code readability and maintainability.
  • 92-92: Resetting the size field in the Write method is appropriate for accurately tracking the size of subsequent batch operations.
  • 97-97: Similarly, resetting the size field in the WriteSync method is correctly implemented and necessary for accurate size tracking.
  • 106-106: Modifying the GetByteSize method to return the calculated size is a key enhancement for optimizing batch processing. This aligns well with the PR's objectives.

@czarcas7ic czarcas7ic merged commit dead65a into osmo/v0.47.5 Mar 22, 2024
23 checks passed
@czarcas7ic czarcas7ic deleted the fix/wrapper_batch_size branch March 22, 2024 19:07
mergify bot pushed a commit that referenced this pull request Mar 22, 2024
(cherry picked from commit dead65a)

# Conflicts:
#	store/wrapper/tmdb.go
mergify bot pushed a commit that referenced this pull request Mar 22, 2024
(cherry picked from commit dead65a)
czarcas7ic pushed a commit that referenced this pull request Mar 22, 2024
(cherry picked from commit dead65a)

Co-authored-by: cool-developer <[email protected]>
czarcas7ic added a commit that referenced this pull request Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants