Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Yegorov
Copy link
Contributor

@Yegorov Yegorov commented Aug 13, 2025

Before

SqliteStoreTest
  test_shrink_cache_if_more_then_10_mb                            PASS (1.51s)

After

SqliteStoreTest
  test_shrink_cache_if_more_then_10_mb                            PASS (0.05s)

Closes #263

Summary by CodeRabbit

  • Tests
    • Updated boundary-condition scenarios for the SQLite-backed store to use larger values and very long keys across sequential writes.
    • Reduced iteration counts while keeping data volume sufficient to hit size thresholds for write skipping and cache shrinking.
    • Test data now uses 8 KB values and 52 successive keys, including an initial extremely long key, to reflect boundary conditions.
    • No changes to user-facing behavior.

@coderabbitai
Copy link

coderabbitai bot commented Aug 13, 2025

Walkthrough

Tests in test/fbe/middleware/test_sqlite_store.rb were modified to change key/value sizes and iteration counts, updating boundary conditions for write-skipping and cache-shrinking behavior.

Changes

Cohort / File(s) Summary
SQLite store tests
test/fbe/middleware/test_sqlite_store.rb
Adjusted two tests: increased value size to 8192 bytes, drastically reduced iterations (to 52), altered key evolution (using key.next), and in one test started from a 65,536-char key to exercise cache/file size thresholds faster.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Assessment against linked issues

Objective Addressed Explanation
Speed up test_shrink_cache_if_more_then_10_mb to <100ms (#263)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Modify boundary test for skip-write behavior: adjust value size to 8192, reduce iterations to 52, change key evolution (test/fbe/middleware/test_sqlite_store.rb) Not referenced in #263; the issue targets only speeding up test_shrink_cache_if_more_then_10_mb. It’s unclear why this separate test required changes.

Possibly related PRs

Suggested reviewers

  • yegor256

Poem

A nibble, a hop, I tweak and I test,
Trim loops to fifty, let caches rest.
Keys grow long like carrot vines,
Bytes at eight K, swift green lines.
Now tests sprint fast—hip hop hooray!
Bug-bunny signs off: all okay. 🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/fbe/middleware/test_sqlite_store.rb (1)

165-165: Consider reducing the key size for better test readability.

While the 65,536-character key works for performance, it may make debugging more difficult if the test fails. Consider using a more reasonable key size (e.g., 1,024 characters) that still achieves the performance goals.

-          key = 'a' * 65_536
+          key = 'a' * 1_024

You may need to adjust the iteration count slightly to maintain the ~10MB target file size.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 61249e0 and 6caa8bf.

📒 Files selected for processing (1)
  • test/fbe/middleware/test_sqlite_store.rb (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Yegorov
PR: zerocracy/fbe#247
File: lib/fbe/middleware/sqlite_store.rb:112-115
Timestamp: 2025-07-10T20:11:32.197Z
Learning: In HTTP response caches like Fbe::Middleware::SqliteStore, updating the created_at timestamp on conflict (when overwriting an existing cache key) is the preferred behavior because fresh data should get a fresh TTL. This aligns with standard cache semantics where new values effectively represent new cache entries.
🔇 Additional comments (1)
test/fbe/middleware/test_sqlite_store.rb (1)

165-170: Performance optimization achieved through strategic data sizing.

The changes successfully reduce test execution time by:

  • Using a very large key (65,536 characters) instead of a short one
  • Increasing value size from ~2KB to ~8KB
  • Dramatically reducing iterations from 10,240 to 52

This maintains the same total data volume (~10MB) while significantly reducing the number of database operations, which is the primary performance bottleneck.

@Yegorov
Copy link
Contributor Author

Yegorov commented Aug 13, 2025

@yegor256 please check

@yegor256 yegor256 merged commit a75a1fe into zerocracy:master Aug 13, 2025
11 checks passed
@yegor256
Copy link
Member

@Yegorov cool, thanks!

@0crat
Copy link

0crat commented Aug 14, 2025

@Yegorov Hey there! 👋 Nice work on your contribution! You've earned +4 points for this one. Here's the breakdown: +16 for showing up, -16 because we missed the code review (let's fix that next time!), and -8 because we're aiming for at least 20 hits-of-code (you had 6). We bumped you up +12 to keep you motivated. Remember, more code and reviews can boost your points even higher! Your total is now +71. Keep the code flowing, and don't forget to check your Zerocracy balance!

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.

test_shrink_cache_if_more_then_10_mb is too slow

3 participants