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

[AMORO-2893] optimize table page loading #2914

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

klion26
Copy link
Member

@klion26 klion26 commented Jun 8, 2024

Why are the changes needed?

Close #2893 .

Optimize the loading process when user open the optimizer page

Brief change log

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@github-actions github-actions bot added the module:core Core module label Jun 8, 2024
@klion26 klion26 force-pushed the fix_optimizer_table_loading branch from e5b1c32 to cb8338a Compare June 8, 2024 09:53
@github-actions github-actions bot removed the module:core Core module label Jun 8, 2024
@klion26
Copy link
Member Author

klion26 commented Jun 8, 2024

Currently, this is a draft version just a better discussion. the open questions are

  1. Do we need to include the table format in what we return to the front end, which right now doesn't seem to be using it?
  2. If we don't need to need to include the table format, which way do we prefer to add the infor no in table_runtime
    2.1. select info from DB for the given tables retrieved in the previous step
    2.2. retrieve the info from TableManager(for example add a function TableManager#getTableRuntime(int tableId)), which needs to maintain an tableId to tableRuntime relationship in memory

I'm leaning towards option 2.2 with not returning the table format to the front end because it reduces the number of DB requests by one

Please let me what you think about this, thanks. @zhoujinsong @majin1102

@baiyangtx
Copy link
Contributor

Now that you have queried the TableRuntimeBean object from the database, why not directly perform sorting or paging operations on this object later?

Copy link
Contributor

@majin1102 majin1102 left a comment

Choose a reason for hiding this comment

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

Thanks for this improvement, I left some comments.
PTAL

Copy link
Contributor

@majin1102 majin1102 left a comment

Choose a reason for hiding this comment

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

Thanks for raising this improvement, I think it's quite necessary and left some comments
Please take a look

@majin1102
Copy link
Contributor

Currently, this is a draft version just a better discussion. the open questions are

  1. Do we need to include the table format in what we return to the front end, which right now doesn't seem to be using it?
  2. If we don't need to need to include the table format, which way do we prefer to add the infor no in table_runtime
    2.1. select info from DB for the given tables retrieved in the previous step
    2.2. retrieve the info from TableManager(for example add a function TableManager#getTableRuntime(int tableId)), which needs to maintain an tableId to tableRuntime relationship in memory

I'm leaning towards option 2.2 with not returning the table format to the front end because it reduces the number of DB requests by one

Please let me what you think about this, thanks. @zhoujinsong @majin1102

I think decoupling from TableService and TableManager is a good idea.
We may seperate dashboard server from ams in the future.
TableFormat seems unnecessary in this page for now

Copy link
Member Author

@klion26 klion26 left a comment

Choose a reason for hiding this comment

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

@majin1102 thanks for the review, I've replied all the comments, could you please take another look when you're free.

@klion26
Copy link
Member Author

klion26 commented Jun 18, 2024

@baiyangtx thanks for the review, the bottle-neck here is not the cost of the sort, but we retrieved too much data from DB, the solution here wants to limit the row number when retrieved from DB(the sort in SQL is needed because we want to show the 'running' status before the 'idle' status in the frontend)

@klion26
Copy link
Member Author

klion26 commented Jul 2, 2024

@majin1102 sorry for the late reply, I've drafted a version such that: TableRuntimeMeta is used for retrieving from db, TableRuntime is used for data transfer object in ams. could you please take a took if this is the right way when you're free? thanks.

@klion26 klion26 force-pushed the fix_optimizer_table_loading branch 3 times, most recently from c0045d9 to 0a0f134 Compare July 26, 2024 13:15
@klion26 klion26 force-pushed the fix_optimizer_table_loading branch from 0a0f134 to 6d41230 Compare July 27, 2024 11:49
@klion26 klion26 marked this pull request as ready for review July 27, 2024 11:49
@klion26 klion26 force-pushed the fix_optimizer_table_loading branch 2 times, most recently from acf96fe to 956f91d Compare July 29, 2024 03:15
@klion26 klion26 force-pushed the fix_optimizer_table_loading branch from 956f91d to 779fc06 Compare July 30, 2024 07:54
@klion26 klion26 force-pushed the fix_optimizer_table_loading branch from 779fc06 to 5750563 Compare July 30, 2024 07:55
@github-actions github-actions bot removed type:build module:ams-dashboard Ams dashboard module labels Jul 30, 2024
@klion26 klion26 force-pushed the fix_optimizer_table_loading branch from 5750563 to f8cacc1 Compare July 31, 2024 07:59
@klion26 klion26 requested a review from majin1102 August 2, 2024 12:07
@klion26
Copy link
Member Author

klion26 commented Aug 2, 2024

@majin1102 @zhoujinsong @baiyangtx I've updated a version, could you please take a look at this when you're free, thanks

@klion26 klion26 force-pushed the fix_optimizer_table_loading branch from 60c5db0 to 016bd01 Compare August 2, 2024 13:10
Copy link
Contributor

@baiyangtx baiyangtx left a comment

Choose a reason for hiding this comment

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

Thanks for this improvement, I left some comments.
PTAL

Copy link
Contributor

@baiyangtx baiyangtx left a comment

Choose a reason for hiding this comment

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

One more point,
the mysql/ams-mysql-init.sql and postgres/ams-postgres-init.sql files also need to be modified synchronously for the schema change.

@klion26
Copy link
Member Author

klion26 commented Aug 3, 2024

@baiyangtx thanks very much for the review, will update the PR % the search pattern about the db soon, that change will change after we reach the consensus.

Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!
I left some comments, you may want to checkout.

@klion26
Copy link
Member Author

klion26 commented Aug 8, 2024

@zhoujinsong thanks very much for the review, will update it and attach some result before and after apply the change

@klion26 klion26 force-pushed the fix_optimizer_table_loading branch from 3cb3d16 to 22c482b Compare August 9, 2024 06:19
Copy link

github-actions bot commented Sep 9, 2024

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@amoro.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Sep 9, 2024
@klion26
Copy link
Member Author

klion26 commented Sep 10, 2024

sorry for the late reply, will rebase the latest master and attach the result asap.

@github-actions github-actions bot removed the stale label Sep 11, 2024
@klion26 klion26 force-pushed the fix_optimizer_table_loading branch 2 times, most recently from 392fd22 to bb4475b Compare September 20, 2024 02:14
@klion26
Copy link
Member Author

klion26 commented Sep 20, 2024

Finally, got the compare result before and after applying the change.

Short answer: This modification has a particularly good performance improvement。
Before the change, the page can be loaded in 45s(this is the default timeout), after the change, the page loading will use some seconds such as below
image

To quickly obtain comparison results in the production environment, no relevant indexes are added to the database. That is to say, after the current PR is merged, the loading effect should be better (because we added indexes to the fields).

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 22.42%. Comparing base (8207efc) to head (bb4475b).
Report is 27 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (8207efc) and HEAD (bb4475b). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (8207efc) HEAD (bb4475b)
core 2 0
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2914      +/-   ##
============================================
- Coverage     29.43%   22.42%   -7.01%     
+ Complexity     3685     2280    -1405     
============================================
  Files           568      379     -189     
  Lines         47267    38044    -9223     
  Branches       6196     5439     -757     
============================================
- Hits          13912     8532    -5380     
+ Misses        32372    28779    -3593     
+ Partials        983      733     -250     
Flag Coverage Δ
core ?
trino 22.42% <ø> (?)

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

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

@klion26 klion26 force-pushed the fix_optimizer_table_loading branch 2 times, most recently from 65e9316 to 5cc731f Compare September 20, 2024 03:20
Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

LGTM.

Thanks for the improvement! @klion26

 tableId is unique for every table we can simplify the key using tableId,

so that we don't need pass other parameters(maybe need retrieve from db) when retrieve info from cache
…tables

Befor the change we'll retrieve all tables from db and sort in the memory,
this will be slow if there are many entriesin the db, after this change
we sort in the db and only retrieve the needed entries.
@majin1102
Copy link
Contributor

Sorry for being late.
look great to me

@zhoujinsong zhoujinsong merged commit 3f627ec into apache:master Sep 23, 2024
4 checks passed
@klion26
Copy link
Member Author

klion26 commented Sep 23, 2024

@zhoujinsong @majin1102 thanks for the review and merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:ams-server Ams server module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: optimize table page loading
5 participants