Conversation
Large server lists repeat immutable country, location, endpoint, generation, and label strings across thousands of logical and physical server records. Each decoded copy currently remains reachable through the model. Share equal values within one server-list load. Apply the same policy after a fresh HTTP decode and during cache JSON decoding, where it also lowers peak allocation. Scope the pool to one load so it cannot retain obsolete lists. Other CacheHandler users retain their existing behavior. Tests cover fresh and cached data, value preservation, absent and non-string fields, unchanged plain cache loads, and per-load pool lifetime.
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.
Problem
Large server lists retain separate Python strings for repeated immutable country, location, endpoint, generation, and label values across logical and physical records.
Change
Share equal selected values within one server-list load. Fresh HTTP-decoded lists are normalized before model construction. Cached JSON uses the same policy while decoding, which also lowers peak allocation. The pool is scoped to one load, and
CacheHandlerremains unchanged unless a caller supplies the new optional hook factory.Verification
CacheHandlerbehavior, and per-load pool lifetime.Synthetic comparison on Fedora 44 / Python 3.14.7: 18,000 logical records, two physical records each, five independent processes per case; values below are medians.
This is a synthetic scalability fixture, not a claim about whole-client RSS. The trade is a one-time decode cost for lower retained memory during the much longer server-list lifetime.
Development disclosure: I developed this patch with material assistance from OpenAI Codex under my direction, then reviewed, benchmarked, tested, and signed the final change.