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

Performance Improvement of create login in BBF #507

Conversation

anju15bharti
Copy link
Contributor

@anju15bharti anju15bharti commented Dec 20, 2024

Description

Extension PR : babelfish-for-postgresql/babelfish_extensions#3291

In Major version 16 Babelfish introduced a new role bbf_admin_role which is a member of all the roles which created implicitly from TSQL. This increases the Load on any Grant/Revoke operations that happen since in BBF to "select the role through which it gets permission to current user to grant", is inefficient and loops over members of members to find the all members of the role even though the required role is find.
This commit optimizes the selection of role with is_admin_option true for babelfish by escaping the search for any TSQL roles conditionally.
Without the changes the time taken to create a login increases drastically and linearly:

Flame graph :
kernel

The average time consumed by create login stmt(with 125 dbs and 125 logins present) : 12836 ms
with these changes we see the time taken to create login increasing linearly but not as drastically as it was before the changes:

Flame graph :
perf-kernel-new-hook

The average time consumed by create login stmt(with 125 dbs and 125 logins present) : 49 ms

Issues Resolved

BABEL-5349

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the PostgreSQL license, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Comment on lines 5080 to 5089
*admin_role = memberid;

/*
* Need not to iterate through all the members
* if admin_role is found.
*/
if (sql_dialect == SQL_DIALECT_TSQL)
{
return NULL;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to restrict this logic to some special roles with significant membership like 'sysadmin' and 'bbf_role_admin'.

Let's get more opinions from perf. experts @surendravishnoi @KushaalShroff

Signed-off-by: ANJU BHARTI <[email protected]>
src/backend/utils/adt/acl.c Outdated Show resolved Hide resolved
src/backend/utils/adt/acl.c Outdated Show resolved Hide resolved
src/backend/utils/adt/acl.c Outdated Show resolved Hide resolved
Signed-off-by: ANJU BHARTI <[email protected]>
@jsudrik jsudrik merged commit 3b4b4ee into babelfish-for-postgresql:BABEL_5_X_DEV__PG_17_X Jan 6, 2025
2 checks passed
jsudrik pushed a commit to babelfish-for-postgresql/babelfish_extensions that referenced this pull request Jan 6, 2025
Engine PR : babelfish-for-postgresql/postgresql_modified_for_babelfish#507

In Major version 16 Babelfish introduced a new role bbf_admin_role which is a member of all the roles which created implicitly from TSQL. This increases the Load on any Grant/Revoke operations that happen since in BBF to "select the role through which it gets permission to current user to grant", is inefficient and loops over members of members to find the all members of the role even though the required role is find.
This commit optimizes the selection of role with is_admin_option true for babelfish by escaping the search for any TSQL roles conditionally.

Signed-off-by: ANJU BHARTI <[email protected]>

Issues Resolved
BABEL-5349
anju15bharti added a commit to amazon-aurora/postgresql_modified_for_babelfish that referenced this pull request Jan 7, 2025
…sql#507)

Extension PR : babelfish-for-postgresql/babelfish_extensions#3291

In Major version 16 Babelfish introduced a new role bbf_admin_role which is a member of all the roles which created implicitly from TSQL. This increases the Load on any Grant/Revoke operations that happen since in BBF to "select the role through which it gets permission to current user to grant", is inefficient and loops over members of members to find the all members of the role even though the required role is find.
This commit optimizes the selection of role with is_admin_option true for babelfish by escaping the search for any TSQL roles conditionally.

Issues Resolved
BABEL-5349
anju15bharti added a commit to amazon-aurora/babelfish_extensions that referenced this pull request Jan 7, 2025
…sql#3291)

Engine PR : babelfish-for-postgresql/postgresql_modified_for_babelfish#507

In Major version 16 Babelfish introduced a new role bbf_admin_role which is a member of all the roles which created implicitly from TSQL. This increases the Load on any Grant/Revoke operations that happen since in BBF to "select the role through which it gets permission to current user to grant", is inefficient and loops over members of members to find the all members of the role even though the required role is find.
This commit optimizes the selection of role with is_admin_option true for babelfish by escaping the search for any TSQL roles conditionally.

Signed-off-by: ANJU BHARTI <[email protected]>

Issues Resolved
BABEL-5349
shardgupta pushed a commit that referenced this pull request Jan 7, 2025
Extension PR : babelfish-for-postgresql/babelfish_extensions#3291

In Major version 16 Babelfish introduced a new role bbf_admin_role which is a member of all the roles which created implicitly from TSQL. This increases the Load on any Grant/Revoke operations that happen since in BBF to "select the role through which it gets permission to current user to grant", is inefficient and loops over members of members to find the all members of the role even though the required role is find.
This commit optimizes the selection of role with is_admin_option true for babelfish by escaping the search for any TSQL roles conditionally.

Task: BABEL-5349

Signed-off-by: Anju Bharti <[email protected]>
shardgupta pushed a commit to babelfish-for-postgresql/babelfish_extensions that referenced this pull request Jan 7, 2025
Engine PR : babelfish-for-postgresql/postgresql_modified_for_babelfish#507

In Major version 16 Babelfish introduced a new role bbf_admin_role which is a member of all the roles which created implicitly from TSQL. This increases the Load on any Grant/Revoke operations that happen since in BBF to "select the role through which it gets permission to current user to grant", is inefficient and loops over members of members to find the all members of the role even though the required role is find.
This commit optimizes the selection of role with is_admin_option true for babelfish by escaping the search for any TSQL roles conditionally.

Task: BABEL-5349

Signed-off-by: ANJU BHARTI <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants