Skip to content

Conversation

@forehalo
Copy link
Collaborator

@forehalo forehalo commented May 9, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved document update handling to optimize storage automatically when garbage collection is enabled.

@graphite-app graphite-app bot requested review from a team May 9, 2025 03:39
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 9, 2025

Walkthrough

A conditional call to store.optimize() was added in the apply_update method of the Doc struct. This call is executed if the gc (garbage collection) option is enabled in the document's options. The change ensures that store optimization occurs after updates are applied, without altering any public interfaces.

Changes

File(s) Change Summary
packages/common/y-octo/core/src/doc/document.rs Added conditional invocation of store.optimize() in Doc::apply_update when GC is enabled.

Poem

In the doc’s deep burrow, a change takes root,
With GC enabled, the store gets cute.
Optimize now, after updates land,
Tidying up, just as planned.
Fewer crumbs left in memory’s warren—
A rabbit’s work is never borin’! 🐇✨


📜 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 d51008b and d1fbc65.

📒 Files selected for processing (1)
  • packages/common/y-octo/core/src/doc/document.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (51)
  • GitHub Check: test-build-mobile-app / build-android-web
  • GitHub Check: test-build-mobile-app / build-ios-web
  • GitHub Check: E2E BlockSuite Test (7)
  • GitHub Check: Build AFFiNE native (aarch64-pc-windows-msvc)
  • GitHub Check: Build @affine/electron renderer
  • GitHub Check: y-octo binding test on aarch64-pc-windows-msvc
  • GitHub Check: Build AFFiNE native (x86_64-pc-windows-msvc)
  • GitHub Check: y-octo binding test on x86_64-pc-windows-msvc
  • GitHub Check: Build AFFiNE native (x86_64-apple-darwin)
  • GitHub Check: y-octo binding test on x86_64-apple-darwin
  • GitHub Check: E2E BlockSuite Test (8)
  • GitHub Check: E2E Test (8)
  • GitHub Check: E2E BlockSuite Test (2)
  • GitHub Check: E2E BlockSuite Cross Browser Test (1, webkit)
  • GitHub Check: E2E BlockSuite Test (6)
  • GitHub Check: Check Git Status
  • GitHub Check: E2E BlockSuite Test (5)
  • GitHub Check: E2E BlockSuite Test (10)
  • GitHub Check: E2E BlockSuite Test (4)
  • GitHub Check: E2E BlockSuite Test (1)
  • GitHub Check: E2E BlockSuite Test (9)
  • GitHub Check: E2E BlockSuite Test (3)
  • GitHub Check: E2E Test (5)
  • GitHub Check: E2E Test (6)
  • GitHub Check: E2E Mobile Test (1)
  • GitHub Check: E2E Test (3)
  • GitHub Check: E2E Test (10)
  • GitHub Check: E2E Test (1)
  • GitHub Check: E2E Mobile Test (4)
  • GitHub Check: E2E Test (9)
  • GitHub Check: E2E Mobile Test (5)
  • GitHub Check: E2E Mobile Test (3)
  • GitHub Check: E2E BlockSuite Cross Browser Test (1, firefox)
  • GitHub Check: E2E Test (7)
  • GitHub Check: E2E BlockSuite Cross Browser Test (1, chromium)
  • GitHub Check: Run native tests
  • GitHub Check: E2E Test (4)
  • GitHub Check: miri code check
  • GitHub Check: E2E Mobile Test (2)
  • GitHub Check: E2E BlockSuite Cross Browser Test (2, firefox)
  • GitHub Check: E2E Test (2)
  • GitHub Check: E2E BlockSuite Cross Browser Test (2, webkit)
  • GitHub Check: E2E BlockSuite Cross Browser Test (2, chromium)
  • GitHub Check: Build Server native
  • GitHub Check: fuzzing
  • GitHub Check: Analyze (typescript, blocksuite)
  • GitHub Check: Analyze (typescript, affine)
  • GitHub Check: Analyze (javascript, affine)
  • GitHub Check: Lint
  • GitHub Check: Analyze (javascript, blocksuite)
  • GitHub Check: Typecheck
🔇 Additional comments (1)
packages/common/y-octo/core/src/doc/document.rs (1)

293-295: LGTM: Automatic GC after update is a good optimization.

This change appropriately adds a conditional garbage collection step after applying an update, but only when the gc option is enabled. This helps manage memory usage more efficiently without changing the public API.

Benefits:

  • Respects user configuration via the gc option
  • Ensures timely cleanup after updates
  • Properly propagates any errors from the optimization process
✨ 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.
    • Generate unit testing code 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 testing code 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 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 generate unit testing code.
    • @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.

@github-actions github-actions bot added the rust label May 9, 2025
Copy link
Collaborator Author

forehalo commented May 9, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link

codecov bot commented May 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.52%. Comparing base (1bfd29d) to head (2b0b64d).

Additional details and impacted files
@@           Coverage Diff           @@
##           canary   #12199   +/-   ##
=======================================
  Coverage   56.52%   56.52%           
=======================================
  Files        2772     2772           
  Lines      141028   141028           
  Branches    21569    21569           
=======================================
+ Hits        79710    79715    +5     
- Misses      59038    59103   +65     
+ Partials     2280     2210   -70     
Flag Coverage Δ
server-test 76.68% <ø> (ø)
unittest 31.91% <ø> (+<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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +293 to +295
if self.opts.gc {
store.optimize()?;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The unconditional call to store.optimize() might be causing test failures. Consider adding error handling to make the optimization more robust, such as: if self.opts.gc { if let Err(e) = store.optimize() { log::warn!("Store optimization failed: {}", e); } }

Spotted by Diamond (based on CI logs)

Is this helpful? React 👍 or 👎 to let us know.

@forehalo forehalo force-pushed the canary branch 4 times, most recently from 1c0c9fc to 8d77c48 Compare June 23, 2025 07:34
Copilot AI review requested due to automatic review settings December 24, 2025 05:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@darkskygit darkskygit merged commit 1b9d065 into canary Dec 29, 2025
108 of 109 checks passed
@darkskygit darkskygit deleted the 61/yocto-auto-gc branch December 29, 2025 13:48
darkskygit added a commit to y-crdt/y-octo that referenced this pull request Jan 10, 2026
Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants