Skip to content
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

[SPARK-50685][PYTHON][FOLLOW-UP] Improve Py4J performance by leveraging getattr #49412

Closed
wants to merge 3 commits into from

Conversation

HyukjinKwon
Copy link
Member

What changes were proposed in this pull request?

This PR is. a followup of #49313 that fixes more places missed.

This PR fixes Core, SQL, ML and Structured Streaming. Tests codes, MLLib and DStream are not affected.

Why are the changes needed?

To reduce the overhead of Py4J calls.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Manually tested as demonstrated in #49312

Was this patch authored or co-authored using generative AI tooling?

No.

@HyukjinKwon HyukjinKwon force-pushed the SPARK-50685-followup branch from ffef2f7 to 16e672e Compare January 8, 2025 08:26
@zhengruifeng
Copy link
Contributor

zhengruifeng commented Jan 8, 2025

To further optimize Py4J calls, does it make sense to cache the result? e.g.

@functools.lru_cache(maxsize=128)
def get_jvm_attr(jvm: "JVMView", name: str) -> Any:
    return getattr(jvm, name)

@HyukjinKwon
Copy link
Member Author

Yeah but we should think about how it will affect GC in Python and JVM.

@HyukjinKwon HyukjinKwon force-pushed the SPARK-50685-followup branch from 953694a to 5513d51 Compare January 9, 2025 01:25
@HyukjinKwon
Copy link
Member Author

Merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants