perf: fix blocking bcrypt, defer heavy columns, add API key index#40
Open
finish06 wants to merge 1 commit into
Open
perf: fix blocking bcrypt, defer heavy columns, add API key index#40finish06 wants to merge 1 commit into
finish06 wants to merge 1 commit into
Conversation
- Offload bcrypt verify_password to thread pool (run_in_executor) in both login handlers — prevents event loop blocking on every auth request - Defer raw_content and file_list columns on list queries (dashboard sync table + API list endpoint) — reduces memory from MB to KB per query - Add composite index on api_keys(is_active, key_prefix) for fast lookups Spec: specs/performance-optimization.md AC: AC-001, AC-002, AC-010, AC-012, AC-013, AC-020 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
verify_password()now runs in thread pool (run_in_executor) in both login handlers, preventing event loop blocking on every auth requestraw_contentandfile_listexcluded from list queries via SQLAlchemydefer(), reducing memory from MB to KB per dashboard/API list request(is_active, key_prefix)onapi_keystable for fast prefix-based lookupsChanges
app/routes/auth.pyrun_in_executorfor bcrypt in browser loginapp/api/endpoints/auth.pyrun_in_executorfor bcrypt in API loginapp/routes/dashboard.pydefer(raw_content, file_list)on sync table queryapp/api/endpoints/sync_logs.pydefer(raw_content, file_list)on list queryapp/models/sync_log.pyapi_keys(is_active, key_prefix)Expected Impact
(is_active, prefix)Test plan
🤖 Generated with Claude Code