fix: reduce repeated regex checks in suggestions engine - #870
Conversation
|
Hi! Thanks for reviewing my PR. I noticed the PR has been labeled Thanks! |
imDarshanGK
left a comment
There was a problem hiding this comment.
@Tuba1809 This PR does not show or verify improvement in /suggestions response time. Please add a simple benchmark or test proving faster performance and keep changes focused on the issue.
|
@imDarshanGK Thanks for the feedback! I've added a lightweight performance test that repeatedly exercises run_suggestions() and reports execution time while avoiding brittle timing assertions in CI. The optimization remains focused on reducing repeated regex evaluations and preserving existing behavior. |
|
Hi @imDarshanGK, I've addressed the requested changes by adding the benchmark and have also fixed the formatting issues reported by CI. All requested updates have been pushed. Could you please take another look when you have time? Thank you! |
|
Hi @imDarshanGK, I've addressed the formatting issue reported by the CI by sorting the imports and formatting the affected file according to the project's style. The changes have been pushed, and the checks are rerunning. Could you please take another look when you have a chance? Thank you! |
imDarshanGK
left a comment
There was a problem hiding this comment.
@Tuba1809 Please add a short demo showing the performance test execution and its output.
Hi @imDarshanGK, thanks for the feedback. I've added the requested performance demo by running the benchmark test locally and attached the execution output. The benchmark shows the optimized run_suggestions() execution (500 iterations completed in 0.0472s), while keeping the test free of brittle timing assertions for CI stability. Please let me know if you'd like any additional benchmarking details. Thank you!
|



Description
Improves the performance of the
/suggestions/endpoint by reducing repeated regex evaluations inside the suggestion engine.The implementation caches frequently-used regex checks (
has_try,has_logging, andhas_tests) and reuses those results throughout the analysis process instead of performing identical searches multiple times.This change is intended to improve response-time consistency while preserving existing behavior.
Related Issue
Fixes #513
Type of change
Checklist
mainpytest -vand all tests passfeat/fix/docs/test: short descriptionScreenshots (if frontend change)
N/A (backend-only change)
Test evidence
python -m pytest backend/tests/test_endpoints.py ================================= 55 passed, 2 warnings in 1.19s =================================