Conversation
- Increased maximum file upload limit from 10 to 50 to improve user experience. - Implemented batch processing for document uploads to avoid proxy timeouts, splitting files into manageable chunks. - Enhanced garbage collection in chat streaming functions to prevent memory leaks and improve performance. - Added memory delta tracking in system snapshots for better monitoring of resource usage. - Updated LLM router and service configurations to prevent unbounded internal accumulation and improve efficiency.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Review by RecurseML
🔍 Review performed on f2f15f6..b08e8da
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (15)
• surfsense_backend/app/app.py
• surfsense_backend/app/db.py
• surfsense_backend/app/services/llm_router_service.py
• surfsense_backend/app/services/llm_service.py
• surfsense_backend/app/tasks/celery_tasks/__init__.py
• surfsense_backend/app/tasks/celery_tasks/connector_tasks.py
• surfsense_backend/app/tasks/celery_tasks/document_reindex_tasks.py
• surfsense_backend/app/tasks/celery_tasks/document_tasks.py
• surfsense_backend/app/tasks/celery_tasks/podcast_tasks.py
• surfsense_backend/app/tasks/celery_tasks/schedule_checker_task.py
• surfsense_backend/app/tasks/celery_tasks/stale_notification_cleanup_task.py
• surfsense_backend/app/tasks/chat/stream_new_chat.py
• surfsense_backend/app/utils/perf.py
• surfsense_web/components/sources/DocumentUploadTab.tsx
• surfsense_web/lib/apis/documents-api.service.ts
Description
Motivation and Context
FIX #
Screenshots
API Changes
Change Type
Testing Performed
Checklist
High-level PR Summary
This PR optimizes memory management across the application by tuning garbage collection thresholds, disabling unnecessary LiteLLM logging and telemetry, and adding explicit cleanup of circular references in chat streaming. It also improves the document upload process by processing files concurrently with temporary file buffering to avoid blocking the event loop, implementing client-side batching (5 files per request) to prevent proxy timeouts, and consolidating Celery session maker creation into a single shared function. Additionally, database connection pooling is configured with production-ready settings, and enhanced performance monitoring tracks RSS memory deltas and garbage collection statistics.
⏱️ Estimated Review Time: 30-90 minutes
💡 Review Order Suggestion
surfsense_backend/app/utils/perf.pysurfsense_backend/app/app.pysurfsense_backend/app/services/llm_service.pysurfsense_backend/app/services/llm_router_service.pysurfsense_backend/app/tasks/chat/stream_new_chat.pysurfsense_backend/app/db.pysurfsense_backend/app/tasks/celery_tasks/__init__.pysurfsense_backend/app/tasks/celery_tasks/document_tasks.pysurfsense_backend/app/tasks/celery_tasks/connector_tasks.pysurfsense_backend/app/tasks/celery_tasks/document_reindex_tasks.pysurfsense_backend/app/tasks/celery_tasks/podcast_tasks.pysurfsense_backend/app/tasks/celery_tasks/schedule_checker_task.pysurfsense_backend/app/tasks/celery_tasks/stale_notification_cleanup_task.pysurfsense_backend/app/routes/documents_routes.pysurfsense_web/lib/apis/documents-api.service.tssurfsense_web/components/sources/DocumentUploadTab.tsx