This repository was archived by the owner on Apr 4, 2026. It is now read-only.
perf: optimize Cognee memory system for faster recall and dashboard#1
Merged
Conversation
Addresses 30+ second recall delays during chat with 500+ memories. Covers parallel search, startup init, dashboard caching, and O(1) delete. Made-with: Cursor
6 tasks: parallel search, startup init, dashboard cache, bulk delete. TDD approach with bite-sized steps. Made-with: Cursor
Made-with: Cursor
Replace sequential for-loop in Memory._multi_search with asyncio.gather for concurrent execution. Add SEARCH_TIMEOUT=15 class attribute with per-type asyncio.wait_for protection. Made-with: Cursor
Made-with: Cursor
Cache formatted memories in-memory for 60s, keyed by (subdir, area). Pagination slices from cache instead of loading all items from disk. Cache is invalidated on insert/delete/update via memory.py hooks. Made-with: Cursor
…tion - Restore 20 pre-existing tests for helper methods (_read_data_item_content, _format_memory_for_dashboard, _get_knowledge_graph, _get_cognify_status, _get_memory_subdirs, _get_current_memory_subdir, _search_memories offset, _delete_memory, _update_memory, setup-before-action) that were removed during Task 4 cache implementation - Update TestDashboardCallsSetup tests to use current cognee_init module vars instead of obsolete memory.py module-level vars - Remove redundant _invalidate_dashboard_cache() call from update_documents since both delete_documents_by_ids and insert_documents already invalidate Made-with: Cursor
Replace loop-per-id approach in delete_documents_by_ids with a single list_datasets + list_data call per area. For N IDs across 3 areas this reduces from N*3 dataset scans to at most 3, with early exit when all IDs are found. Made-with: Cursor
Reflect startup init, parallel search, dashboard cache, and bulk delete optimizations in architecture docs and fork changes list. Made-with: Cursor
beautifulsoup4>=4.13 breaks transformers import via bs4.__spec__=None. Regression tests updated to test new startup-init architecture instead of the removed runtime configure_cognee() pattern. Made-with: Cursor
Sequential pip install lets cognee pull in beautifulsoup4>=4.13 which overrides the <4.13 pin from requirements.txt. A single pip install with all requirement files resolves constraints together. Made-with: Cursor
Single pip install causes openai version conflict between browser-use and requirements2.txt. Use sequential installs with a shared constraint file to pin beautifulsoup4<4.13 across all install steps. Made-with: Cursor
Docker uses uv which doesn't upgrade already-installed packages on subsequent installs. Regular pip does, causing beautifulsoup4 to get upgraded to 4.13+ (broken __spec__) when cognee is installed. Made-with: Cursor
Production uses uv pip install inside a venv. CI was using plain pip in system Python, causing bs4.__spec__=None (venv initializes it correctly). Now CI mirrors Docker: uv + venv, sequential installs. Made-with: Cursor
beautifulsoup4 4.13+ has bs4.__spec__=None which causes transformers' import_utils.py to crash (huggingface/transformers#31798). Docker worked because older cached version was installed; fresh installs get 4.14.3 which is broken. Pin <4.13 in requirements.txt. Made-with: Cursor
Root cause: conftest.py unconditionally injected _MockModule into sys.modules for ALL optional deps (including bs4, flask, requests). _MockModule lacks a proper __spec__, so importlib.util.find_spec() raised ValueError when transformers checked for bs4 availability. Fix: check importlib.util.find_spec(top_level) before mocking. In CI (all deps installed) nothing gets mocked; locally (partial deps) only genuinely missing packages are stubbed. Also reverts the beautifulsoup4<4.13 pin — no longer needed. Made-with: Cursor
This was referenced Mar 27, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
_multi_cognee_search(recall extension) andMemory._multi_searchnow run all search types concurrently viaasyncio.gatherwith per-type timeouts (15s), reducing recall latency from ~30s to ~5-10sprepare.py, eliminating redundant initialization overheaddelete_documents_by_idsfrom O(N×areas) individual lookups to O(areas) with single scan per dataset using set-based ID matchingTest plan
pytest— 37 tests)Made with Cursor