-
Notifications
You must be signed in to change notification settings - Fork 1.1k
misc performance optimizations #7482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
1. Replace chained withFields to use a single WithFields 2. check for debug log enabled before invoking debug logs 3. store request logger in the context to minimize amount of instantiation calls.
🚨 Jira Linter FailedCommit: The Jira linter failed to validate your PR. Please check the error details below: 🔍 Click to view error detailsNext Steps
This comment will be automatically deleted once the linter passes. |
|
API Changes --- prev.txt 2025-10-24 17:34:40.996472121 +0000
+++ current.txt 2025-10-24 17:34:31.237283261 +0000
@@ -8096,6 +8096,7 @@
CacheOptions
OASDefinition
SelfLooping
+ RequestLogger
)
# Package: ./dlpython
|
🔍 Code Analysis ResultsThis PR introduces several performance optimizations related to logging within the Tyk gateway, aiming to reduce CPU usage and memory allocations during request processing. The changes focus on three areas:
Files Changed Analysis
The changes consistently apply performance best practices for the Architecture & Impact AssessmentWhat this PR accomplishesThis PR improves the performance of the Tyk gateway by optimizing its logging infrastructure. By reducing unnecessary allocations and CPU cycles spent on logging, especially for high-throughput scenarios, the changes contribute to lower latency and better resource utilization. Key technical changes introduced
Affected system componentsThe primary component affected is the Gateway's middleware processing pipeline. Since nearly all requests pass through multiple middlewares, and each middleware performs logging, the impact of these optimizations is system-wide for all API traffic. VisualizationThe following diagram illustrates the change in the logger lifecycle for a single request. graph TD
subgraph Before
A[Request In] --> MW1;
MW1 -- "Creates Logger A" --> MW2;
MW2 -- "Creates Logger B" --> MW3;
MW3 -- "Creates Logger C" --> Response;
end
subgraph After
B[Request In] --> MW1_New[MW1];
MW1_New -- "Creates Logger X & Caches in Context" --> MW2_New[MW2];
MW2_New -- "Reuses Logger X from Context" --> MW3_New[MW3];
MW3_New -- "Reuses Logger X from Context" --> Response_New[Response];
end
style MW1 fill:#f9f,stroke:#333,stroke-width:2px
style MW2 fill:#f9f,stroke:#333,stroke-width:2px
style MW3 fill:#f9f,stroke:#333,stroke-width:2px
style MW1_New fill:#ccf,stroke:#333,stroke-width:2px
style MW2_New fill:#ccf,stroke:#333,stroke-width:2px
style MW3_New fill:#ccf,stroke:#333,stroke-width:2px
Scope Discovery & Context ExpansionThe scope of this change is well-contained within the gateway's request handling logic. The modification to While the PR applies these optimizations in many places, there may be other opportunities for similar improvements. For instance, a quick search reveals other locations that could be converted from chained Metadata
Powered by Visor from Probelabs Last updated: 2025-10-24T17:40:05.579Z | Triggered by: opened | Commit: 8c53f7a 💡 TIP: You can chat with Visor using |
🔍 Code Analysis Results✅ Security Check PassedNo security issues found – changes LGTM. ✅ Architecture Check PassedNo architecture issues found – changes LGTM. ✅ Performance Check PassedNo performance issues found – changes LGTM. Quality Issues (1)
✅ Dependency Check PassedNo dependency issues found – changes LGTM. ✅ Connectivity Check PassedNo connectivity issues found – changes LGTM. Powered by Visor from Probelabs Last updated: 2025-10-24T17:40:06.464Z | Triggered by: opened | Commit: 8c53f7a 💡 TIP: You can chat with Visor using |
Description
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist