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

chore: improve performance on bootstrap permissions #22083

Conversation

dpgaspar
Copy link
Member

@dpgaspar dpgaspar commented Nov 9, 2022

SUMMARY

Improves performance when fetching user permissions for bootstrap data. Previously we were doing 1 query per user role, now it will just do 1 query no matter how many roles a user has.

Measured get_permissions execution time, on 100 executions the avg time was:

0.019353721141815185 <- previous call
0.00747002124786377 <- new call

~60% speed improvement

Performance improvement on FAB: https://github.com/dpgaspar/Flask-AppBuilder/blob/master/flask_appbuilder/security/sqla/manager.py#L398

Followup PR from this: #21313

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dpgaspar dpgaspar marked this pull request as ready for review November 9, 2022 16:42
@codecov
Copy link

codecov bot commented Nov 9, 2022

Codecov Report

Merging #22083 (bf00314) into master (cd1b379) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master   #22083   +/-   ##
=======================================
  Coverage   67.07%   67.07%           
=======================================
  Files        1815     1815           
  Lines       69575    69572    -3     
  Branches     7486     7486           
=======================================
+ Hits        46665    46667    +2     
+ Misses      20974    20969    -5     
  Partials     1936     1936           
Flag Coverage Δ
hive 52.84% <0.00%> (+0.01%) ⬆️
mysql 78.40% <100.00%> (+<0.01%) ⬆️
postgres 78.46% <100.00%> (+<0.01%) ⬆️
presto 52.74% <0.00%> (+0.01%) ⬆️
python 81.58% <100.00%> (+0.01%) ⬆️
sqlite 76.92% <100.00%> (+<0.01%) ⬆️
unit 51.22% <0.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/views/utils.py 80.69% <100.00%> (-0.15%) ⬇️
superset/db_engine_specs/base.py 89.21% <0.00%> (+0.05%) ⬆️
superset/db_engine_specs/presto.py 88.22% <0.00%> (+0.44%) ⬆️
superset/db_engine_specs/bigquery.py 82.58% <0.00%> (+0.53%) ⬆️
superset/db_engine_specs/druid.py 83.33% <0.00%> (+2.38%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM. These types of improvements can have a huge cumulative effect. It would be great to try to see if there's other similar low hanging fruit in the codebase.

@dpgaspar dpgaspar merged commit 35e0e5b into apache:master Nov 10, 2022
@dpgaspar dpgaspar deleted the danielgaspar/sc-56793/fix-superset-permission-performance-improvement branch November 10, 2022 21:48
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/S 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants