Skip to content

⚡ Bolt: [performance improvement] Cache YAML configuration loads in app utils#516

Open
alinelena wants to merge 2 commits intomainfrom
bolt/cache-yaml-loads-utils-9542593272263519501
Open

⚡ Bolt: [performance improvement] Cache YAML configuration loads in app utils#516
alinelena wants to merge 2 commits intomainfrom
bolt/cache-yaml-loads-utils-9542593272263519501

Conversation

@alinelena
Copy link
Copy Markdown
Collaborator

💡 What:
Added @lru_cache(maxsize=1) to load_framework_registry in ml_peg/app/utils/utils.py and _load_faqs_yaml in ml_peg/app/utils/build_components.py. Used copy.deepcopy() before returning the cached values to prevent any unintended mutation from downstream calls.

🎯 Why:
The application frequently needs to read frameworks.yml (for rendering badges) and faqs.yml (for dropdowns) during component rendering. The yaml.safe_load operation combined with disk I/O is a known performance bottleneck in Python. Loading these static files once and caching them drastically speeds up UI generation and avoids repetitive overhead.

📊 Impact:
Prevents file reading and YAML parsing overhead entirely on subsequent calls, replacing it with a quick dictionary deepcopy. This should tangibly reduce Dash app instantiation and render times.

🔬 Measurement:
Run the test suite or manually profile calls to build_faqs() and get_framework_config() before and after this change. The cache hit rate should be nearly 100% on subsequent renders, yielding O(1) time complexity (plus deepcopy time).


PR created automatically by Jules for task 9542593272263519501 started by @alinelena

…pp utils

Added `lru_cache` and `copy.deepcopy()` to `load_framework_registry` and FAQ loading to prevent repeated disk I/O and `yaml.safe_load` overhead on UI render.

Co-authored-by: alinelena <3306823+alinelena@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

…pp utils

Added `lru_cache` and `copy.deepcopy()` to `load_framework_registry` and FAQ loading to prevent repeated disk I/O and `yaml.safe_load` overhead on UI render. Also addressed numpydoc warnings.

Co-authored-by: alinelena <3306823+alinelena@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant