compose.ymlのPSQLサイドカーにメモリチューニング設定を追加#1527
Merged
Merged
Conversation
ECSメトリクスでタスク全体のメモリ使用率が2GB中380MB(19%)程度に留まり リソースが遊んでいたため、PostgreSQLが使えるメモリを引き上げる。 - shared_buffers: 128MB → 384MB (ページキャッシュ拡大) - work_mem: 4MB → 64MB (ソート/ハッシュ結合のスピル抑制) - maintenance_work_mem: 64MB → 256MB (ANALYZE/CREATE INDEXの高速化) - effective_cache_size: 4GB → 1GB (プランナーへの実態に即したヒント) UNLOGGEDテーブル運用なのでshared_buffersの効果が通常より大きい。 maintenance_work_memの引き上げはデプロイ時の起動時間短縮に直結する。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthrough
ChangesPostgreSQL パフォーマンス設定
🎯 1 (Trivial) | ⏱️ ~3 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@compose.yml`:
- Line 30: The global PostgreSQL setting work_mem=64MB is too high and risks OOM
under concurrent load; change the compose.yml default to a safer lower value
(e.g., work_mem=16MB or 4-32MB range) and document/instrument the repo to raise
work_mem only for heavy queries using SET LOCAL work_mem or
per-role/per-connection configuration; update the compose.yml entry for work_mem
and add a short note in your DB runbook or comments explaining to use SET LOCAL
work_mem for intensive operations or connection-role specific overrides.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
ローカル開発用
compose.ymlの PostgreSQL サイドカーにshared_buffers/work_mem/maintenance_work_mem/effective_cache_sizeのメモリ系チューニング設定を追加。変更の種類
変更内容
compose.ymlのpsqlサービスにcommandを追加し、PostgreSQL の以下のメモリパラメータをデフォルトから引き上げshared_buffers=384MB(デフォルト 128MB): 内部ページキャッシュwork_mem=64MB(デフォルト 4MB): ソート/ハッシュ結合/集約あたりの上限maintenance_work_mem=256MB(デフォルト 64MB): ANALYZE / CREATE INDEX / VACUUM のワークメモリeffective_cache_size=1GB: プランナーへの実効キャッシュサイズのヒントbuild_stop_route_mappingやintegrate_gtfs_trip_variations_to_typesの重い CTE クエリ・起動時の ANALYZE 速度・ランタイムの JOIN/ソート性能改善を狙うテスト
cargo fmt --all -- --checkが通ることcargo clippy -- -D warningsが通ることcargo test(SQLX_OFFLINE=true)が通ることdocker compose upで立ち上げてSHOW work_mem;等で反映確認可能。関連Issue
スクリーンショット(任意)
Summary by CodeRabbit
shared_buffers、work_mem、maintenance_work_mem、effective_cache_sizeです。既存の環境設定への影響はありません。