{{ message }}
fix: Optimize sync memory usage to prevent OOM on large projects - #380
Merged
Conversation
Contributor
Implements P1 and P2 fixes from basicmachines-co/basic-memory-cloud#198 Changes: - Add semaphore to limit concurrent file processing (default: 10 files max) - Add LRU cache with bounded size for file failure tracking (max 100 entries) - Add sync_max_concurrent_files configuration option - Update sync_thread_pool_size documentation Impact: - Reduces peak memory usage by 90%+ on large projects (2000+ files) - Prevents OOM kills on 1GB machines with projects containing 2,621 files - Before: All files could load into memory simultaneously - After: Maximum 10 files in memory at once (configurable) Related: basicmachines-co/basic-memory-cloud#198 Signed-off-by: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
phernandez
force-pushed
the
fix/sync-memory-optimization
branch
from
October 17, 2025 00:57
56f54fc to
772ddbf
Compare
Contributor
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
Implements P1 and P2 memory optimization fixes from basicmachines-co/basic-memory-cloud#198 to prevent OOM kills on large projects.
Changes
P1: Semaphore for Concurrent File Processing
asyncio.Semaphoreto limit concurrent file operations (default: 10 files)_read_file_async()and_compute_checksum_async()with semaphoresync_max_concurrent_filesconfiguration optionP2: LRU Cache for File Failure Tracking
_file_failuresfromDicttoOrderedDictfor LRU behavior_record_failure()to enforce cache size and maintain LRU orderingDocumentation
sync_thread_pool_sizedescription to note optimization for 1-2GB cloud deploymentssync_max_concurrent_filesparameterImpact
Memory Reduction:
OOM Prevention:
Configuration:
Users can tune memory usage via config:
{ "sync_thread_pool_size": 4, // Thread pool workers (default: 4) "sync_max_concurrent_files": 10 // Max concurrent files (default: 10) }For very constrained environments,
sync_max_concurrent_filescan be lowered to 5.Test Plan
Related Issues
🤖 Generated with Claude Code