Performance & critical fixes: Redis, memory, SQL, indexes, CI gate#106
Merged
Performance & critical fixes: Redis, memory, SQL, indexes, CI gate#106
Conversation
… gate Critical: - Gate deploys on CI passing (moved deploy into ci.yml with needs) - Fix Redis connection leak in GpuJob (shared memoized connection) - Stream zip builds for TTS batch & stems downloads (no more memory bomb) Performance: - Replace Ruby sort_by with SQL ORDER BY in blog controllers - Add missing DB indexes (images, review_sections, reviews) - Add counter_cache for story paragraphs - Bulk insert for TTS batch items (insert_all vs N inserts) - Advisory lock for invoice number generation (race condition) - N+1 protection: Client.with_invoice_totals class method Infrastructure: - Pin Postgres 16 and Redis 7 in CI - Delete standalone deploy.yml (consolidated into ci.yml) 109 tests, 0 failures. Rubocop clean.
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.
What
Comprehensive performance and safety fixes from the codebase audit. @frogr
Critical Fixes
needs: [scan_ruby, scan_js, lint, test]. Deleted standalone deploy.yml.GpuJobwas creating a newRedis.new()on every call. Now uses a shared memoized connection.tts_batches#download_allandstems#download_allloaded ALL base64 audio into memory for zip creation. Refactored to use temp files andfind_eachfor streaming.Performance Fixes
sort_bywith SQLORDER BY COALESCE()in blog controllersimages.published,images.position,review_sections.status,reviews.pr_urlstory_paragraphs_countto stories (eliminates 2 COUNT queries per page load)insert_all!instead of N individual insertspg_advisory_lockto prevent duplicatesClient.with_invoice_totalsfor efficient list queriesInfrastructure
latest)Verified
bundle exec rubocop— 213 files, 0 offensesbin/rails test— 109 tests, 0 failures, 0 errorsFiles changed (14)