⚡ Bolt: [performance improvement] Cache YAML configuration loads in app utils#516
⚡ Bolt: [performance improvement] Cache YAML configuration loads in app utils#516
Conversation
…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>
|
👋 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 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>
💡 What:
Added
@lru_cache(maxsize=1)toload_framework_registryinml_peg/app/utils/utils.pyand_load_faqs_yamlinml_peg/app/utils/build_components.py. Usedcopy.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) andfaqs.yml(for dropdowns) during component rendering. Theyaml.safe_loadoperation 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()andget_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