-
Notifications
You must be signed in to change notification settings - Fork 163
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
perf: Cache jstrings during metrics collection #1029
Conversation
…locations. I need to confirm 1) there's actually a performance benefit to this, and 2) these GlobalRefs are being released when I want them to be.
I will update with some benchmark results tomorrow, but initial results look promising. |
The speedup on q4 is pretty impressive! Here are the raw JSON benchmark result files: |
Thanks for running the benchmarks for me. I was struggling to get reproducible results locally. |
edit: posted the wrong pngs from the wrong benchmark - updated now |
This seems correct to me |
I had earlier posted fresh benchmarks that showed a big improvement with the latest commit but I had inadvertently enabled the new |
Spark has a single thread calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @mbutrovich
Which issue does this PR close?
Partially addresses #1024.
Rationale for this change
Comet uses JNI jstrings as the keys to updating metrics values on the Spark side during execution. As described in #1024, currently Comet allocates a jstring for every metric for every invocation of metrics updating. The calls to
jni_NewStringUTF
account for over 1% of the on-CPU time in TPC-H SF10 for me.What changes are included in this PR?
Added a HashMap that maps the native string to a jstring to use in JNI calls. This has the benefit of being many-to-one, whereby multiple nodes with the same metric name will benefit from the cached jstring. This cache is populated on demand: if the entry isn't present, we allocate a jstring and insert it into the cache.
I have some thoughts about this approach that I would love for reviewers to comment on:
ExecutePlan
. However, DF's metrics are Options and don't actually appear to be there until the plan starts executing.How are these changes tested?
Existing tests on the Java side that exercise metrics.