Merged
Conversation
06b5f76 to
fba25d0
Compare
|
This PR has been automatically marked as stale because it has not had activity in the last 30 days. |
f414e95 to
0a3ed4b
Compare
0a3ed4b to
52c4ee3
Compare
52c4ee3 to
5ddf098
Compare
jack-edmonds-dd
approved these changes
Nov 10, 2025
5ddf098 to
d4a53eb
Compare
d4a53eb to
ccbac24
Compare
github-actions bot
pushed a commit
that referenced
this pull request
Nov 12, 2025
* add cache to optimize type checking * pre-commit fixes --------- Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com> 53f79a5
4 tasks
Supam
pushed a commit
that referenced
this pull request
Mar 31, 2026
* Improve type validation without cache This mostly reverts #2737 which caches instances directly leading to memory issues down the line when big responses are hold in memory. There are still some cases where when we fall back on the previous behavior but it should improve the existing dashboard problem. Fixes #3029 * Don't shortcut this case.
github-actions bot
pushed a commit
that referenced
this pull request
Mar 31, 2026
* Improve type validation without cache This mostly reverts #2737 which caches instances directly leading to memory issues down the line when big responses are hold in memory. There are still some cases where when we fall back on the previous behavior but it should improve the existing dashboard problem. Fixes #3029 * Don't shortcut this case. 9b5f1c5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

What does this PR do?
Context
Jira ticket
The
validate_and_convert_typesfunction was causing severe performance degradation whencheck_return_type=True, resulting in 5.0x slowdown for API calls.Root Cause: Exponential validation overhead due to deeply nested API responses. A single dashboard response triggered 108,516+ validation calls with recursive validation of the same nested structures repeatedly.
Failed Optimization Attempts
Early Exit Strategies: Primitive type checks, inheritance checks, and exact type matching were ineffective because inputs were raw JSON data requiring conversion to typed models, not already-typed instances.
The core issue was that we couldn't avoid the validation work through early exits, but we could avoid repeating identical validation work through caching.
Changes
ApiClient-Level Validation Cache
Cache Infrastructure: Added
_validation_cachetoApiClient.__init__()with configurable size limit (default: 1000 entries)Cache Integration: Modified
ApiClient.deserialize()to pass cache tovalidate_and_convert_types()Validation Function Updates: Added
request_cacheparameter throughout validation call chain with_make_hashable()helper for unhashable typesGentle FIFO Memory Management: When cache is full, evict 25% of entries while keeping 75% most recent
Design Decisions:
Tests
Performance Test Setup
Using the exact reproduction case from the original issue:
Performance Results:
Additional Notes
Review checklist
Please check relevant items below:
This PR includes all newly recorded cassettes for any modified tests.
This PR does not rely on API client schema changes.
Or, this PR relies on API schema changes and this is a Draft PR to include tests for that new functionality.