Perf: Implement in-memory caching for Graph and Cluster JSON files 1174 - #1192
Merged
komalharshita merged 2 commits intoJul 18, 2026
Conversation
|
Someone is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel. A member of the Team first needs to authorize it. |
komalharshita
approved these changes
Jul 18, 2026
komalharshita
left a comment
Owner
There was a problem hiding this comment.
Looks good! This PR introduces a clean in-memory caching mechanism for the graph and cluster JSON files, reducing repeated disk reads and improving performance without changing the application's behavior. The addition of cache invalidation support and successful test results further increase confidence in the implementation. Overall, this is a well-scoped performance improvement with no blocking issues.
Approved for merge. ✅
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
This PR addresses issue #1174 by introducing in-memory caching for the Recommender Engine's static JSON files (
clusters.jsonandskill_graph.json). Previously, the backend executed synchronous disk I/O on every API call to read these files, creating a latency bottleneck at scale. By declaring module-level variables (_cached_clustersand_cached_skill_graph) and updating the respective load functions to serve data from memory after the initial read, we eliminate redundant disk reads entirely. Aclear_caches()function is also provided to allow for explicit cache invalidation during unit testing.Related Issue
Closes #1174
Type of Change
data/projects.jsonWhat Was Changed
src/utils/recommender.py_cached_clustersand_cached_skill_graphalongside boolean initialization flags. Updated_load_clusters()and_load_skill_graph()to return the cached references instead of parsing the files off disk. Implementedclear_caches()to reset the global state for testing environments.How to Test This PR
git checkout feat/issue-1174-in-memory-cachingpip install -r requirements.txtpython app.pypython tests/test_basic.py(orpytest tests/test_basic.py) to verify that the caching does not break any assertions.Expected test output:
Test Results
Self-Review Checklist
feat/,fix/,docs/,data/,style/,test/python tests/test_basic.pyand all 27 tests passflake8 .locally and there are no errorsprint()orconsole.log()debug statementsNotes for Reviewer
None