⚡️ Speed up method JiraDataSource.get_all_available_dashboard_gadgets by 12%
#456
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.
📄 12% (0.12x) speedup for
JiraDataSource.get_all_available_dashboard_gadgetsinbackend/python/app/sources/external/jira/jira.py⏱️ Runtime :
114 milliseconds→102 milliseconds(best of250runs)📝 Explanation and details
The optimization achieves an 11% runtime improvement and 7.3% throughput increase by eliminating redundant URL formatting in the HTTPClient's
executemethod.Key Change:
executemethod to just before theclient.request()callWhy This Improves Performance:
The original code performed
url = f"{request.url.format(**request.path_params)}"at the end of the method, but sinceHTTPRequest.urlis already the complete URL (as shown in the JiraDataSource whereurl = self.base_url + _safe_format_url(rel_path, _path)is passed to HTTPRequest), this formatting was redundant work. By moving it closer to where it's actually needed, we:Impact on Workloads:
This optimization is particularly beneficial for:
get_all_available_dashboard_gadgetswhere path parameters are typically emptyThe test results show consistent improvements across all scales - from basic single requests to high-concurrency scenarios with 100+ simultaneous calls, making this optimization valuable for both low-volume and high-throughput usage patterns.
✅ Correctness verification report:
🌀 Generated Regression Tests and Runtime
To edit these changes
git checkout codeflash/optimize-JiraDataSource.get_all_available_dashboard_gadgets-mhp9c7zqand push.