-
Notifications
You must be signed in to change notification settings - Fork 32
Performance: Add database indexes and optimize hot paths #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
View your CI Pipeline Execution ↗ for commit 417b8ec
☁️ Nx Cloud last updated this comment at |
Co-authored-by: JMBeresford <1373954+JMBeresford@users.noreply.github.com>
- Add database indexes for foreign keys and frequently queried columns - Remove unnecessary .clone() calls in Rust code - Replace sequential file operations with parallel execution - Add React.memo to prevent unnecessary component re-renders - Remove redundant into_iter().collect() operation Co-authored-by: JMBeresford <1373954+JMBeresford@users.noreply.github.com>
There was a problem hiding this 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 focuses on performance optimization across multiple areas of the codebase through reduction of unnecessary cloning, improved async operations, and React component memoization.
Key changes:
- Eliminates unnecessary
.clone()operations in Rust code by using references instead - Parallelizes file deletion operations in game and game file deletion handlers
- Adds database indexes for improved query performance
- Memoizes React components to prevent unnecessary re-renders
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/grpc-service/src/library/metadata_handlers.rs | Optimized iteration to avoid cloning entire games collection upfront |
| packages/grpc-service/src/games.rs | Removed unnecessary clones, parallelized disk deletions, and improved error handling |
| packages/db/migrations/2025-11-04-043457_add_performance_indexes/up.sql | Added database indexes for foreign keys and frequently queried columns |
| packages/db/migrations/2025-11-04-043457_add_performance_indexes/down.sql | Rollback migration for performance indexes |
| packages/client/gen/schemas/linux-schema.json | Updated Tauri schema with new permissions and corrected spelling |
| packages/client-web/src/components/side-bar/game-item.tsx | Wrapped component with React.memo for performance |
| packages/client-web/src/components/game-list.tsx | Memoized GameItem and GameImage components to prevent unnecessary re-renders |
| let error_msg = if path.is_dir() { | ||
| format!( | ||
| "Failed to delete game sub-directory {} from disk: {}", | ||
| file_id, why | ||
| ) | ||
| } else { | ||
| format!( | ||
| "Failed to delete game file {} from disk: {}", | ||
| file_id, why | ||
| ) | ||
| }; |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Race condition: The path.is_dir() check at line 395 occurs after the async file system operation completes. If the path was deleted by the operation, this check will fail and produce an incorrect error message. The directory/file check should be performed before the deletion attempt (at line 388) and the result stored for use in the error message.
🤖 I have created a release *beep* *boop* --- ## [0.7.43](v0.7.42...v0.7.43) (2025-11-09) ### Features * update emulatorJS version 4.2.1 -> 4.2.3 ([58de623](58de623)) ### Bug Fixes * built-in ppsspp emulation ([#433](#433)) ([54c97e3](54c97e3)) * cache control header for public files ([2dad54d](2dad54d)) * catch memory access error in web emulation ([08d39c4](08d39c4)) * overlay UI tweaks ([92c4f6f](92c4f6f)) ### Performance Improvements * add database indexes and optimize hot paths ([#427](#427)) ([f80b0e0](f80b0e0)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Profiled the codebase and identified several performance bottlenecks causing slow queries and unnecessary allocations.
Database Indexes
Added migration
2025-11-04-043457_add_performance_indexeswith 10 strategic indexes:game_files(game_id),games(platform_id)- foreign key indexesgame_files(game_id, is_deleted)- composite index for common query patterngames.is_deleted,game_files.is_deleted- filter indexesgame_metadata.igdb_id,platform_metadata.igdb_id- metadata lookup indexesgames(steam_app_id) WHERE steam_app_id IS NOT NULL- partial indexThese eliminate sequential scans on queries like:
Rust Optimizations
grpc-service/src/games.rs:into_iter().collect()allocationgame.path.clone()→ref updated_path)join_all()instead of sequential loopgrpc-service/src/library/metadata_handlers.rs:.iter()+ selective clone vs cloning entire vector upfrontReact Memoization
Added
React.memotoGameItemandGameImagecomponents to prevent re-renders in virtualized lists when parent state changes but props are unchanged.Before:
After:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.