query_namespaces performance improvements #417
Merged
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
Want to improve the performance of the rest implementation of
query_namespaces
Solution
pytest-benchmark
dev dependency and some basic performance tests to interrogate the impact of certain changes. For now these are only run on my local machine, but in the future these could potentially be expanded into an automated suite._preload_content=False
to tell the underlying generated code not to instantiate response objects for all the intermediate results.ThreadPoolExecutor
instead of olderThreadPool
implementation from multiprocessing. This involved some changes to the generated code, but the benefit of this approach is that you get back aconcurrent.futures.Future
instead of anApplyResult
which is much more ergonomic. I'm planning to extract the edited files out of the code gen process very shortly, so there shouldn't be a concern about modifying generated files in this case. I gated this approach behind a new kwarg,async_threadpool_executor
, that lives alongsideasync_req
; eventually I would like to replace all usage ofasync_req
's ThreadPool with ThreadPoolExecutor to bring the rest and grpc implementations closer together, but I can't do that in this PR without creating a breaking change.The net effect of these changes seems to be about ~18% performance improvement.
Type of Change