Skip to content

Conversation

@ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Jan 17, 2026

closes #11973

Summary by CodeRabbit

  • New Features
    • PostgreSQL database server now includes automatic performance optimization that configures memory allocation and runtime parameters for production environments.

✏️ Tip: You can customize this high-level summary in your review settings.

@ysmoradi ysmoradi requested a review from Copilot January 17, 2026 20:20
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

A new PostgreSQL optimization extension method is added to configure memory parameters and container settings. The method computes and applies PostgreSQL runtime arguments based on available container memory, then integrates into the boilerplate application's database provisioning chain.

Changes

Cohort / File(s) Summary
PostgreSQL Optimization Extension
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.AppHost/Extensions/IResourceBuilderExtensions.cs
New public extension method WithOptimizedSetup() added with XML documentation. Configures PostgreSQL memory parameters (shared\_buffers, effective\_cache\_size, maintenance\_work\_mem, etc.) and container memory limits based on total container memory parameter (default 4GB). Calculates optimal values and applies via fluent builder pattern.
PostgreSQL Configuration Usage
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.AppHost/Program.cs
Integration call .WithOptimizedSetup() added to PostgreSQL builder chain between .WithV18DataVolume() and .WithImage(). Single-line addition to invoke the new optimization method.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 With buffers tuned and caches bright,
PostgreSQL learns to dance just right!
Memory sings in harmonious way,
Aspire's setup saves the day,
Optimization hops on through! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: optimizing PostgreSQL setup in bit Boilerplate aspire, which aligns with the changeset that adds WithOptimizedSetup() for PostgreSQL tuning.
Linked Issues check ✅ Passed The PR addresses the linked issue #11973 by implementing PostgreSQL optimizations through the new WithOptimizedSetup() extension method with memory tuning and runtime argument configuration.
Out of Scope Changes check ✅ Passed All changes are scoped to PostgreSQL setup optimization: adding WithOptimizedSetup() method and integrating it into the PostgreSQL configuration chain, with no unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • 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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🤖 Fix all issues with AI agents
In
`@src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.AppHost/Extensions/IResourceBuilderExtensions.cs`:
- Around line 16-39: The WithOptimizedSetup method currently discards the result
of WithContainerRuntimeArgs and also allows totalContainerMemoryMB values that
make availableForPostgres <= 0; fix by validating totalContainerMemoryMB at the
start (throw ArgumentOutOfRangeException or clamp to a minimum like 1024) so
reservedOverhead/availableForPostgres produce positive values, ensure computed
sharedBuffersMB, effectiveCacheSizeMB, and maintenanceWorkMemMB are clamped to
sensible minima, and THEN return the chained result of
builder.WithContainerRuntimeArgs(...) instead of ignoring it so the runtime args
(and memory reservation) are actually applied; reference the WithOptimizedSetup
method, totalContainerMemoryMB, reservedOverhead, availableForPostgres,
sharedBuffersMB, maintenanceWorkMemMB, and WithContainerRuntimeArgs when making
the changes.
🧹 Nitpick comments (1)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.AppHost/Extensions/IResourceBuilderExtensions.cs (1)

44-49: Chain container runtime args and ensure tuning matches actual limits.

WithContainerRuntimeArgs isn’t chained; if it returns a new builder, the reservation may be lost. Also, --memory-reservation is soft; if tuning assumes a fixed cap, consider --memory or update the comment.

♻️ Suggested tweak
-        builder
-            // --- RUNTIME RESOURCES ---
-            // Ensures the container actually gets the RAM we are tuning for.
-            .WithContainerRuntimeArgs("--memory-reservation", $"{totalContainerMemoryMB}m");
-
-        return builder
+        return builder
+            // --- RUNTIME RESOURCES ---
+            // Ensures the container actually gets the RAM we are tuning for.
+            .WithContainerRuntimeArgs("--memory-reservation", $"{totalContainerMemoryMB}m")
             // --- MEMORY TUNING ---
             .WithArgs("-c", $"shared_buffers={sharedBuffersMB}MB")

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.

Pull request overview

This PR optimizes PostgreSQL setup for the Boilerplate template by adding a new WithOptimizedSetup() extension method that configures production-grade tuning for vector search workloads using pgvector and DiskANN.

Changes:

  • Adds a comprehensive PostgreSQL optimization extension method with memory, checkpoint, and I/O tuning
  • Integrates the optimization into the PostgreSQL setup chain in AppHost Program.cs
  • Configures settings optimized for SSD/NVMe storage and vector similarity search operations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/Server/Boilerplate.Server.AppHost/Program.cs Adds .WithOptimizedSetup() call to the PostgreSQL configuration chain
src/Server/Boilerplate.Server.AppHost/Extensions/IResourceBuilderExtensions.cs Implements the WithOptimizedSetup extension method with calculated PostgreSQL parameters for memory management, checkpointing, WAL settings, and performance tuning

@ysmoradi ysmoradi merged commit 183d1bb into bitfoundation:develop Jan 18, 2026
3 checks passed
@ysmoradi ysmoradi deleted the 11973 branch January 18, 2026 09:58
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.

bit Boilerplate aspire's based postgreSQL setup needs optimizations

1 participant