Skip to content

[KYUUBI #7079] Improve performance of AccessRequest initialization#7081

Closed
wForget wants to merge 18 commits into
apache:masterfrom
wForget:KYUUBI-7079
Closed

[KYUUBI #7079] Improve performance of AccessRequest initialization#7081
wForget wants to merge 18 commits into
apache:masterfrom
wForget:KYUUBI-7079

Conversation

@wForget

@wForget wForget commented Jun 5, 2025

Copy link
Copy Markdown
Member

Why are the changes needed?

Improve performance of authz rules.

Constantize some properties to reduce object creation:

  • AccessRequest initialization requires reflection methods
  • RuleHelper.ugi (different sparkSession may have different authz ugi)

closes #7079

How was this patch tested?

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

No

* @param argClasses the classes of the arguments
* @return an unbound method that can be invoked later
*/
def getMethod(clz: Class[_], methodName: String, argClasses: Class[_]*): UnboundMethod = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not simplify much code, can we inline it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not simplify much code, can we inline it?

Makes sense, changed.

@wForget wForget changed the title [KYUUBI #7079] Improve performance of authz rules [KYUUBI #7079] Improve performance of AccessRequest initialization Jun 5, 2025
@codecov-commenter

codecov-commenter commented Jun 5, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 57 lines in your changes missing coverage. Please review.

Project coverage is 0.00%. Comparing base (cad5a39) to head (bb469c7).
Report is 21 commits behind head on master.

Files with missing lines Patch % Lines
...uubi/plugin/spark/authz/ranger/AccessRequest.scala 0.00% 57 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #7081    +/-   ##
=======================================
  Coverage    0.00%   0.00%            
=======================================
  Files         697     700     +3     
  Lines       43203   43457   +254     
  Branches     5854    5887    +33     
=======================================
- Misses      43203   43457   +254     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wForget wForget marked this pull request as ready for review June 5, 2025 12:17
@wForget wForget requested a review from pan3793 June 6, 2025 02:19
}

private def getUserGroupsFromUserStore(user: UserGroupInformation): Option[JSet[String]] = {
private lazy val userGroupMappingOpt: Option[JHashMap[String, JSet[String]]] = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is safe to cache

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is safe to cache

userGroupMapping may be updated by RangerUserStoreRefresher, I will only cache reflect methods


private val getRolesFromUserAndGroupsMethod: Option[UnboundMethod] =
getMethod(
SparkRangerAdminPlugin.getClass,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SparkRangerAdminPlugin.getClass,
classOf[SparkRangerAdminPlugin],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SparkRangerAdminPlugin is an object and does not seem to work with classOf.


private lazy val getUserGroupMappingMethod: Option[UnboundMethod] =
getMethod(
Class.forName("org.apache.ranger.plugin.util.RangerUserStore"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's located at ranger-plugins-common, should be always accessible?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's located at ranger-plugins-common, should be always accessible?

I don't get your point, but the logic here seems to be consistent with previous.

val userGroupMapping =
invokeAs[JHashMap[String, JSet[String]]](userStore, "getUserGroupMapping")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, it's a new feature of Ranger 2.1, we must use reflection as long as we support lower Ranger versions

wForget and others added 9 commits July 8, 2025 16:58
…kyuubi/plugin/spark/authz/ranger/AccessRequest.scala

Co-authored-by: Cheng Pan <pan3793@gmail.com>
…kyuubi/plugin/spark/authz/ranger/AccessRequest.scala

Co-authored-by: Cheng Pan <pan3793@gmail.com>
…/apache/kyuubi/plugin/spark/authz/ranger/AccessRequest.scala"

This reverts commit 686c45b.
…/apache/kyuubi/plugin/spark/authz/ranger/AccessRequest.scala"

This reverts commit 99e0bd3.
@github-actions

github-actions Bot commented Jan 2, 2026

Copy link
Copy Markdown

Thanks for the PR! This PR is being closed due to inactivity. This isn't a judgement on the merit of the PR in any way. If this is still an issue with the latest version of Kyuubi, please reopen it and ask a committer to remove the Stale tag!

Thank you for using Kyuubi!

@github-actions github-actions Bot added the Stale label Jan 2, 2026
@github-actions github-actions Bot closed this Jan 2, 2026
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.

[FEATURE][AUTHZ] Improve performance of authz rules

3 participants