Skip to content

Unified Storage Performance Optimizations#10

Open
everettbu wants to merge 1 commit into
performance-optimization-baselinefrom
unified-storage-enhancements
Open

Unified Storage Performance Optimizations#10
everettbu wants to merge 1 commit into
performance-optimization-baselinefrom
unified-storage-enhancements

Conversation

@everettbu

@everettbu everettbu commented Jul 26, 2025

Copy link
Copy Markdown

Test 10

Summary by CodeRabbit

  • Bug Fixes
    • Improved test stability by skipping a specific integration test for certain environments where it fails in CI.
  • Refactor
    • Unified logging to use internal logger instances for more consistent log output.
    • Centralized server initialization to reduce redundant checks and streamline request handling.
    • Improved tracing context propagation for more accurate monitoring.
    • Optimized locking in search index building for better performance.
  • Chores
    • Removed unused imports and updated comments for clarity.

…#97529)

* dont lazy init unified storage

* Inits index when creating new resource server. Fixes trace propagation by passing span ctx. Update some logging.

* Use finer grained cache locking when building indexes to speed things up. Locking the whole function was slowing things down.

* formatting

* linter fix

* go mod

* make update-workspace

* fix workspaces check error

* update dependency owner in mod file

* wait 1 second before querying metrics

* try with big timeout, see if fixes CI. Wont fail locally.

* skips postgres integration test. Only fails in drone. Will fix later.

* put delay back to 500 ms
@coderabbitai

coderabbitai Bot commented Jul 26, 2025

Copy link
Copy Markdown

Walkthrough

The changes update logging and tracing practices, streamline resource server initialization, and refine concurrency control in index building. Logging is unified under internal loggers, tracing context is properly propagated, and resource server initialization is centralized. Additionally, a test is conditionally skipped based on an environment variable, and some code comments are updated.

Changes

Cohort / File(s) Change Summary
pkg/server/module_server_test.go Test now skips execution for GRAFANA_TEST_DB=postgres, with a TODO for CI failures.
pkg/storage/unified/resource/search.go
pkg/storage/unified/sql/backend.go
Logging unified under internal loggers; tracing context is properly propagated in methods.
pkg/storage/unified/resource/server.go Resource server initialization moved to constructor; handlers no longer call Init per request.
pkg/storage/unified/search/bleve.go Locking in BuildIndex reduced to only cache update; replaced a commented log with a TODO comment.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ResourceServer
    participant SearchIndex
    participant Watcher

    Client->>ResourceServer: NewResourceServer()
    ResourceServer->>ResourceServer: Init(ctx)
    ResourceServer->>SearchIndex: Initialize index
    ResourceServer->>Watcher: Start watcher

    Client->>ResourceServer: Request (Create/Update/...)
    ResourceServer->>ResourceServer: Handle request (assumes already initialized)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

🐇
In the warren where loggers now sing,
And tracing context finds its wing,
The server wakes just once, not more,
While locks are lighter than before.
Tests skip and hop as CI demands—
All tidy now by rabbit hands!

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch unified-storage-enhancements

🪧 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 generate unit tests to generate unit tests for 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.

@everettbu

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 27, 2025

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
pkg/storage/unified/search/bleve.go (1)

100-100: Consider expanding the TODO comment.

The TODO comment could be more descriptive about what needs to be implemented.

-		// TODO, check last RV so we can see if the numbers have changed
+		// TODO: Implement resource version checking to determine if index rebuild is necessary
pkg/server/module_server_test.go (1)

35-38: Reasonable workaround for CI-specific test failures.

The conditional skip for postgres in Drone CI while preserving local test functionality is a pragmatic approach. The TODO comment appropriately indicates this needs to be fixed.

Would you like me to help investigate the postgres-specific issues in the Drone CI environment or create a follow-up issue to track this technical debt?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 871af07 and d762a96.

📒 Files selected for processing (5)
  • pkg/server/module_server_test.go (1 hunks)
  • pkg/storage/unified/resource/search.go (4 hunks)
  • pkg/storage/unified/resource/server.go (2 hunks)
  • pkg/storage/unified/search/bleve.go (2 hunks)
  • pkg/storage/unified/sql/backend.go (1 hunks)
🔇 Additional comments (8)
pkg/storage/unified/search/bleve.go (1)

137-139: Excellent concurrency optimization!

Moving the lock acquisition to only protect the cache assignment significantly improves concurrency by allowing multiple index builds to proceed simultaneously. This reduces contention and improves performance.

pkg/storage/unified/sql/backend.go (1)

126-126: Critical fix for tracing context propagation.

Assigning the returned context from tracer.Start() back to ctx ensures that the span information is properly propagated through subsequent operations in the method. This improves observability and tracing accuracy.

pkg/storage/unified/resource/search.go (4)

173-173: Correct tracing context propagation.

Properly assigning the returned context ensures tracing spans are correctly propagated through the initialization process.


216-216: Good addition of initialization metrics logging.

The informational log provides valuable insights into search index initialization performance and document counts.


280-280: Consistent logging with internal logger.

Using the internal logger instance (s.log) instead of external loggers improves consistency and centralized log configuration.


310-310: Proper tracing context handling.

Correctly assigning the context from tracer.Start() ensures span information is available for the build operation.

pkg/storage/unified/resource/server.go (2)

258-262: Excellent architectural improvement - centralized initialization.

Moving server initialization to the constructor eliminates redundant initialization checks on every request and centralizes error handling. This improves both performance and maintainability by ensuring the server is fully initialized when returned from the constructor.


308-311: Logical ordering of initialization components.

Starting the watcher after search initialization ensures proper dependency ordering and improves the reliability of the initialization sequence.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update or ping for review. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Aug 27, 2025
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it has not had any further activity in the last 2 weeks. Thank you for your contributions!

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.

2 participants