Skip to content

Conversation

coszio
Copy link
Contributor

@coszio coszio commented Jun 24, 2025

Most changes are related to a refactor to use const generics, which removes a bit of code duplication by drilling down a const generic.

Main change is to use the seq mmap in the Gridstore::iter function. Looks like we missed this when introducing the seq mmap

@coszio coszio requested review from agourlay and JojiiOfficial June 24, 2025 01:45
Comment on lines -546 to +523
let raw = self.read_from_pages(page_id, block_offset, length);
let raw = self.read_from_pages::<true>(page_id, block_offset, length);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main change (which could've been done without the refactor, but it was a quick change 😸)

Copy link
Member

Choose a reason for hiding this comment

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

Yes! I also put it here.

Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

📝 Walkthrough

"""

Walkthrough

This change refactors the reading logic in the Gridstore and Page modules by merging previously separate methods for sequential and random access into unified generic methods parameterized by a compile-time boolean. In Gridstore, the methods read_from_pages and read_from_pages_sequential are consolidated into read_from_pages<const READ_SEQUENTIAL: bool>, and similarly, read_value and read_value_sequential are unified into a generic read_value<const READ_SEQUENTIAL: bool>. In Page, the read_value and read_value_sequential methods are merged into a single generic read_value<const READ_SEQUENTIAL: bool>. All relevant call sites are updated to use the new generic methods.

Possibly related PRs

Suggested reviewers

  • agourlay
    """

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c713ef6 and 33d241f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • lib/gridstore/src/gridstore.rs (6 hunks)
  • lib/gridstore/src/page.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • lib/gridstore/src/page.rs
  • lib/gridstore/src/gridstore.rs
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: test-low-resources
  • GitHub Check: test-shard-snapshot-api-s3-minio
  • GitHub Check: test-snapshot-operations-s3-minio
  • GitHub Check: test-consistency
  • GitHub Check: Basic TLS/HTTPS tests
  • GitHub Check: integration-tests
  • GitHub Check: test-consensus-compose
  • GitHub Check: integration-tests-consensus
  • GitHub Check: rust-tests (windows-latest)
  • GitHub Check: rust-tests (macos-latest)
  • GitHub Check: rust-tests-no-rocksdb (ubuntu-latest)
  • GitHub Check: rust-tests (ubuntu-latest)
  • GitHub Check: storage-compat-test
  • GitHub Check: lint
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Also refactor to use const generics
@coszio coszio force-pushed the gridstore-use-seq-mmap-in-iter branch from c713ef6 to 33d241f Compare June 24, 2025 01:48
///
pub fn read_value(
/// If the `block_offset` starts after the page ends.
pub fn read_value<const READ_SEQUENTIAL: bool>(
Copy link
Member

Choose a reason for hiding this comment

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

Any reason for making this boolean generic? I don't like it that much I must admit.

My assumption is that the compiler will produce exactly the same code when we pass a boolean as argument, because it by itself it constant and we have optimizations enabled.

We can probably check it with Godbolt.

Copy link
Member

@timvisee timvisee Jun 24, 2025

Choose a reason for hiding this comment

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

Yes, it is unnecessary:

https://rust.godbolt.org/z/heEPzY36n

Putting it in a regular parameter produces exactly the same ASM.

I therefore vote to put it back into parameters.

Copy link
Member

Choose a reason for hiding this comment

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

In our daily we agreed to keep it as is. Changing it is not significant enough. And the current approach actually guarantees that we must provide a constant (so the compiler can optimize it away).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Today I learned about this tool, thanks!

@timvisee timvisee merged commit dd63603 into dev Jun 24, 2025
18 checks passed
@timvisee timvisee deleted the gridstore-use-seq-mmap-in-iter branch June 24, 2025 10:56
generall pushed a commit that referenced this pull request Jul 17, 2025
Also refactor to use const generics
@xzfc xzfc mentioned this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants