[SPARK-53104][PS] Introduce ansi_mode_context to avoid multiple config checks per API call #51821
+232
−61
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 changes were proposed in this pull request?
Introduces
ansi_mode_context
to avoid multiple config checks per API call.Why are the changes needed?
Currently
is_ansi_mode_enabled
is called many times, which could cause a performance issue as it retrieves the related config every time it's called.For example:
will cause the roundtrip between the client and the server 500 times. To be exact, classic needs two roundtrips to check configs, so the number is 1000 times.
We should reduce the number of retrievals to at most once (or twice in classic) per API call.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
The existing tests should pass, also manually checked the number of config retrivals.
Was this patch authored or co-authored using generative AI tooling?
No.