Improved/performance and reliability#2
Conversation
- Limit message history to last 50 messages by default - Reduces memory usage and improves broadcast performance - Added limit parameter to get_all() for flexibility
- Documents all 7 performance and reliability improvements - Includes code examples and impact analysis - Provides testing recommendations - Lists future optimization opportunities
- reduce memory usage with message pagination - faster broadcast with better locking - cache decryptions and improve logging - validate sessions and cleanup resources
KenBot117
left a comment
There was a problem hiding this comment.
GenAI code PRs are ugly. This PR is not recommended.
I do recommended some of the error logging for troubleshooting but there are issues in this that will increase ram usage despite claims for improved performance. I don't use Python as much as I want to but it's easy to see obvious performance degradations that will happen with this version.
| msg["text"] = decrypted | ||
| if "_decrypted_text" not in msg: | ||
| msg["_decrypted_text"] = self.room_fernet.decrypt(msg["text"].encode()).decode() | ||
| msg["text"] = msg["_decrypted_text"] |
There was a problem hiding this comment.
This increases ram by saving data twice
| while True: | ||
| with suppress(asyncio.CancelledError): | ||
| await asyncio.sleep(300) | ||
| await asyncio.sleep(60) |
There was a problem hiding this comment.
Some connections might be too weak for short timeouts
| snapshot = list(self.active_connections.items()) | ||
|
|
||
| dead = [] | ||
| for uid, ws in snapshot: |
There was a problem hiding this comment.
Logging might be nice for troubleshooting but not sure why the shift from user_id to uid
| @@ -0,0 +1,244 @@ | |||
| # Performance Improvements | |||
There was a problem hiding this comment.
These are GenAI reports. Please provide real world testing
Now I see @diorwave removed logging 4 months ago. This PR is now easier to reject. |
Performance Improvements