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

feat: Optimize create uneval tree via memoization #13476

Merged
merged 22 commits into from
May 18, 2022

Conversation

SatishGandham
Copy link
Contributor

@SatishGandham SatishGandham commented May 2, 2022

Description

For every evaluation, uneval tree is computed on the main thread and sent to the worker. In moderately complex apps, this step takes between 40 to 300ms. Most of the computations in this step are rework because none of the widgets change, and the only change is meta properties.

This PR separates the part dependent on widget and metaprops, and memoizes the expensive part dependent on widget

Fixes #12966

Type of change

  • Non breaking change which improves performance

How Has This Been Tested?

  • Profiled and verified the performance improvements
  • Compared the output of the changes with the old one.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

createUnevalTree_split_memoization

createUnevalTree_memoizing_two_params_together

createUnevalTree_before

Test coverage results 🧪

🟢 Total coverage has increased
// Code coverage diff between base branch:release and head branch: feat/optimized-memoize-create-uneval-tree 
Status File % Stmts % Branch % Funcs % Lines
🟢 total 56.56 (0) 38.53 (0) 35.85 (0.01) 56.81 (0.01)
🔴 app/client/src/entities/DataTree/dataTreeFactory.ts 38.46 (-7.88) 100 (0) 50 (0) 37.25 (-7.75)
🟢 app/client/src/entities/DataTree/dataTreeWidget.ts 98.55 (0.44) 83.33 (0) 100 (0) 98.33 (0.46)
🟢 app/client/src/entities/Widget/utils.ts 91.96 (0.07) 89.13 (0) 100 (0) 91.89 (0.15)
🔴 app/client/src/utils/autocomplete/TernServer.ts 52.71 (-0.23) 40.83 (-0.84) 36.21 (0) 56.74 (-0.25)
🟢 app/client/src/widgets/MultiSelectWidget/component/index.tsx 19.44 (0.26) 0 (0) 0 (0) 20.59 (0.3)

@vercel
Copy link

vercel bot commented May 2, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
appsmith ✅ Ready (Inspect) Visit Preview May 16, 2022 at 5:15AM (UTC)

@github-actions github-actions bot added High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage Performance Pod All things related to Appsmith performance labels May 2, 2022
@SatishGandham
Copy link
Contributor Author

/ok-to-test sha=683a514

@github-actions
Copy link

github-actions bot commented May 2, 2022

Unable to find test scripts. Please add necessary tests to the PR.

@github-actions
Copy link

github-actions bot commented May 2, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2255468977.
Workflow: Appsmith External Integration Test Workflow.
Commit: 683a514.
PR: 13476.

@github-actions
Copy link

github-actions bot commented May 2, 2022

Unable to find test scripts. Please add necessary tests to the PR.

@somangshu somangshu marked this pull request as draft May 2, 2022 05:21
@SatishGandham
Copy link
Contributor Author

/ok-to-test sha=4b80e25

@github-actions
Copy link

github-actions bot commented May 2, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2258750676.
Workflow: Appsmith External Integration Test Workflow.
Commit: 4b80e25.
PR: 13476.

@SatishGandham
Copy link
Contributor Author

/ok-to-test sha=bd271ab

@github-actions
Copy link

github-actions bot commented May 2, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2258930953.
Workflow: Appsmith External Integration Test Workflow.
Commit: bd271ab.
PR: 13476.

@SatishGandham
Copy link
Contributor Author

/ok-to-test sha=7c4e456

@github-actions
Copy link

github-actions bot commented May 2, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2259255341.
Workflow: Appsmith External Integration Test Workflow.
Commit: 7c4e456.
PR: 13476.

@SatishGandham
Copy link
Contributor Author

/ok-to-test sha=21fb4a0

@github-actions
Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2305082364.
Workflow: Appsmith External Integration Test Workflow.
Commit: 21fb4a0.
PR: 13476.

@github-actions
Copy link

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2305082364.
Commit: 21fb4a0.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_CATEGORY
scripting 987.86 1930.58 666.12 1768.14 658.74 987.86 1202.29 50.58 45.24
painting 5.11 4.58 11.28 6.44 4.51 5.11 6.38 44.51 39.81
rendering 383.91 289.4 351.63 284.28 285.48 289.4 318.94 14.44 12.91
BIND_TABLE_DATA
scripting 2276.74 2342.6 2744.1 2309.04 2769.24 2342.6 2488.34 9.89 8.85
painting 18.19 27.45 19.47 20.8 27.36 20.8 22.65 19.56 17.53
rendering 688.73 649.28 591.25 680.33 608.98 649.28 643.71 6.66 5.96
CLICK_ON_TABLE_ROW
scripting 1700.59 1942.5 1694.58 1919.59 1667.25 1700.59 1784.9 7.52 6.73
painting 29.72 22.07 24.01 20.69 13.7 22.07 22.04 26.27 23.50
rendering 304.99 319.16 289.93 301.56 281.18 301.56 299.36 4.86 4.35
UPDATE_POST_TITLE
scripting 3298.7 3217.3 2473.76 2509.63 2873.34 2873.34 2874.55 13.37 11.96
painting 22.28 21.87 24.33 15.12 17.96 21.87 20.31 18.27 16.30
rendering 429.92 490.48 376.62 374 384.76 384.76 411.16 12.11 10.83
OPEN_MODAL
scripting 1233.61 1301.89 1076.64 1146.9 2589.57 1233.61 1469.72 42.99 38.45
painting 11.92 12.81 18.56 13.71 10.79 12.81 13.56 22.12 19.76
rendering 450.15 467.77 448.25 423.9 435.78 448.25 445.17 3.70 3.31
CLOSE_MODAL
scripting 927.74 746.87 2206.74 650.63 678.3 746.87 1042.06 63.33 56.65
painting 6.32 5.66 7.65 4.55 4.61 5.66 5.76 22.40 20.14
rendering 466.13 349.42 346.15 342.5 351.27 349.42 371.09 14.34 12.83
SELECT_WIDGET_MENU_OPEN
scripting 1655.2 1639.08 1498.53 1698.61 1758.15 1655.2 1649.91 5.84 5.22
painting 7.49 9.23 6.13 9.33 7.93 7.93 8.02 16.58 14.84
rendering 656.56 580.96 517.28 522.21 673.96 580.96 590.19 12.41 11.10
SELECT_WIDGET_SELECT_OPTION
scripting 228.69 226.04 307.15 257.46 268.99 257.46 257.67 12.90 11.53
painting 2.7 6.22 4.5 15.01 3.56 4.5 6.4 77.97 69.69
rendering 16.89 16.9 17.26 17.41 21.74 17.26 18.04 11.53 10.31

@SatishGandham
Copy link
Contributor Author

/ok-to-test sha=cee2807

@github-actions
Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2307603615.
Workflow: Appsmith External Integration Test Workflow.
Commit: cee2807.
PR: 13476.

@github-actions
Copy link

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2307603615.
Commit: cee2807.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_CATEGORY
scripting 983.88 1120.06 1089.84 1069.4 1075.72 1075.72 1067.78 4.76 4.26
painting 16.97 17.54 16.63 15.85 9.22 16.63 15.24 22.44 20.08
rendering 414.59 418.24 406.88 422.5 416.86 416.86 415.81 1.39 1.24
BIND_TABLE_DATA
scripting 2018.25 2088.18 2095.15 2122.14 2130.27 2095.15 2090.8 2.12 1.89
painting 55.01 28.9 29.43 24.78 30.89 29.43 33.8 35.71 31.95
rendering 1096.75 1003.13 1089.89 995.22 760.61 1003.13 989.12 13.77 12.31
CLICK_ON_TABLE_ROW
scripting 4711.89 4632.1 4418.86 4754.02 4307.25 4632.1 4564.82 4.24 3.79
painting 95.43 102.81 59.76 100.83 66.43 95.43 85.05 23.94 21.41
rendering 1066.53 1109.12 1100.76 1177.34 1260.29 1109.12 1142.81 6.74 6.03
UPDATE_POST_TITLE
scripting 4476.75 4711.67 4573.2 4415.61 4648.66 4573.2 4565.18 2.65 2.37
painting 35.28 32.12 24.7 23.78 42.57 32.12 31.69 24.58 21.99
rendering 555.7 538.07 542.16 567.42 588.64 555.7 558.4 3.67 3.28
OPEN_MODAL
scripting 1942.19 1975.22 2040.51 1976.6 1880.67 1975.22 1963.04 2.97 2.65
painting 23.15 22.57 14.61 21.72 31 22.57 22.61 25.74 23.04
rendering 612.07 606.5 625.48 625.5 621 621 618.11 1.37 1.23
CLOSE_MODAL
scripting 983.75 1008.76 1014.35 1041.34 1009.9 1009.9 1011.62 2.03 1.81
painting 14.31 12.89 7.83 12.95 16.17 12.95 12.83 24.16 21.59
rendering 511.33 579.24 648.19 626.12 492.93 579.24 571.56 11.97 10.71
SELECT_WIDGET_MENU_OPEN
scripting 2153.13 2089.5 1998.23 2047.29 2025.98 2047.29 2062.83 2.93 2.62
painting 13.09 12.9 28.81 11.6 8.66 12.9 15.01 52.70 47.17
rendering 687.02 714.29 692.81 698.71 701.27 698.71 698.82 1.47 1.31
SELECT_WIDGET_SELECT_OPTION
scripting 324.97 330.8 297.7 404.4 331.15 330.8 337.8 11.75 10.51
painting 4.24 3.96 4.99 17.4 3.99 4.24 6.92 84.97 76.01
rendering 19.2 21.63 18.96 20.32 22.53 20.32 20.53 7.50 6.72

1 similar comment
@github-actions
Copy link

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2307603615.
Commit: cee2807.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_CATEGORY
scripting 983.88 1120.06 1089.84 1069.4 1075.72 1075.72 1067.78 4.76 4.26
painting 16.97 17.54 16.63 15.85 9.22 16.63 15.24 22.44 20.08
rendering 414.59 418.24 406.88 422.5 416.86 416.86 415.81 1.39 1.24
BIND_TABLE_DATA
scripting 2018.25 2088.18 2095.15 2122.14 2130.27 2095.15 2090.8 2.12 1.89
painting 55.01 28.9 29.43 24.78 30.89 29.43 33.8 35.71 31.95
rendering 1096.75 1003.13 1089.89 995.22 760.61 1003.13 989.12 13.77 12.31
CLICK_ON_TABLE_ROW
scripting 4711.89 4632.1 4418.86 4754.02 4307.25 4632.1 4564.82 4.24 3.79
painting 95.43 102.81 59.76 100.83 66.43 95.43 85.05 23.94 21.41
rendering 1066.53 1109.12 1100.76 1177.34 1260.29 1109.12 1142.81 6.74 6.03
UPDATE_POST_TITLE
scripting 4476.75 4711.67 4573.2 4415.61 4648.66 4573.2 4565.18 2.65 2.37
painting 35.28 32.12 24.7 23.78 42.57 32.12 31.69 24.58 21.99
rendering 555.7 538.07 542.16 567.42 588.64 555.7 558.4 3.67 3.28
OPEN_MODAL
scripting 1942.19 1975.22 2040.51 1976.6 1880.67 1975.22 1963.04 2.97 2.65
painting 23.15 22.57 14.61 21.72 31 22.57 22.61 25.74 23.04
rendering 612.07 606.5 625.48 625.5 621 621 618.11 1.37 1.23
CLOSE_MODAL
scripting 983.75 1008.76 1014.35 1041.34 1009.9 1009.9 1011.62 2.03 1.81
painting 14.31 12.89 7.83 12.95 16.17 12.95 12.83 24.16 21.59
rendering 511.33 579.24 648.19 626.12 492.93 579.24 571.56 11.97 10.71
SELECT_WIDGET_MENU_OPEN
scripting 2153.13 2089.5 1998.23 2047.29 2025.98 2047.29 2062.83 2.93 2.62
painting 13.09 12.9 28.81 11.6 8.66 12.9 15.01 52.70 47.17
rendering 687.02 714.29 692.81 698.71 701.27 698.71 698.82 1.47 1.31
SELECT_WIDGET_SELECT_OPTION
scripting 324.97 330.8 297.7 404.4 331.15 330.8 337.8 11.75 10.51
painting 4.24 3.96 4.99 17.4 3.99 4.24 6.92 84.97 76.01
rendering 19.2 21.63 18.96 20.32 22.53 20.32 20.53 7.50 6.72

@SatishGandham SatishGandham changed the title Optimize create uneval tree via memoization feat: Optimize create uneval tree via memoization May 12, 2022
@github-actions github-actions bot added the Enhancement New feature or request label May 12, 2022
Copy link
Contributor

@rishabhrathod01 rishabhrathod01 left a comment

Choose a reason for hiding this comment

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

LGTM

@SatishGandham
Copy link
Contributor Author

/ok-to-test sha=bfb4e9a

@github-actions
Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2330377025.
Workflow: Appsmith External Integration Test Workflow.
Commit: bfb4e9a.
PR: 13476.

@github-actions
Copy link

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2330377025.
Commit: bfb4e9a.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_CATEGORY
scripting 699.85 940.97 644.12 744.41 815.89 744.41 769.05 14.93 13.36
painting 5.28 4.75 4.35 11.7 4.91 4.91 6.2 49.84 44.68
rendering 341.9 430.21 304.2 313.67 360.55 341.9 350.11 14.30 12.79
BIND_TABLE_DATA
scripting 2349.86 2285.51 2260.94 2366.65 2259.25 2285.51 2304.44 2.19 1.96
painting 25.27 16.12 17.84 20.69 21.95 20.69 20.37 17.53 15.71
rendering 650.59 579.1 647.46 682.95 678.5 650.59 647.72 6.41 5.74
CLICK_ON_TABLE_ROW
scripting 2020.69 1607.06 2240.2 2096.57 1788.23 2020.69 1950.55 12.93 11.57
painting 20.67 17.29 25.11 19.99 15.11 19.99 19.63 19.26 17.22
rendering 327.54 282.35 362.19 333.28 318.36 327.54 324.74 8.87 7.94
UPDATE_POST_TITLE
scripting 3018.12 2466.64 2890.29 3054 2478.45 2890.29 2781.5 10.37 9.28
painting 33.79 19.68 31.5 29.02 14.83 29.02 25.76 31.56 28.22
rendering 514.19 378.57 398.78 497.99 373.61 398.78 432.63 15.71 14.05
OPEN_MODAL
scripting 1256.42 1047.74 2591.27 1395.81 1341.47 1341.47 1526.54 39.94 35.73
painting 9.57 8.64 10.47 11.52 22.76 10.47 12.59 45.91 41.06
rendering 504.86 399.74 583.6 484.05 491.88 491.88 492.83 13.28 11.88
CLOSE_MODAL
scripting 1486.02 708.51 874.5 787.04 860.59 860.59 943.33 32.92 29.44
painting 4.66 4.89 14.23 9.55 11.33 9.55 8.93 46.47 41.55
rendering 331.69 331.06 372.81 468.99 393.71 372.81 379.65 14.95 13.37
SELECT_WIDGET_MENU_OPEN
scripting 1556.06 1530.43 1556.79 1488.07 1448.68 1530.43 1516.01 3.09 2.77
painting 8.28 5.61 9.17 12.08 6.07 8.28 8.24 31.67 28.28
rendering 516.67 493.67 522.26 501.39 502.19 502.19 507.24 2.33 2.08
SELECT_WIDGET_SELECT_OPTION
scripting 219.24 253.57 338.31 237.86 234.58 237.86 256.71 18.39 16.45
painting 8.67 9.28 10.62 10.49 4.7 9.28 8.75 27.54 24.57
rendering 17.62 16.32 13.63 15.06 16.01 16.01 15.73 9.47 8.46

1 similar comment
@github-actions
Copy link

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2330377025.
Commit: bfb4e9a.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_CATEGORY
scripting 699.85 940.97 644.12 744.41 815.89 744.41 769.05 14.93 13.36
painting 5.28 4.75 4.35 11.7 4.91 4.91 6.2 49.84 44.68
rendering 341.9 430.21 304.2 313.67 360.55 341.9 350.11 14.30 12.79
BIND_TABLE_DATA
scripting 2349.86 2285.51 2260.94 2366.65 2259.25 2285.51 2304.44 2.19 1.96
painting 25.27 16.12 17.84 20.69 21.95 20.69 20.37 17.53 15.71
rendering 650.59 579.1 647.46 682.95 678.5 650.59 647.72 6.41 5.74
CLICK_ON_TABLE_ROW
scripting 2020.69 1607.06 2240.2 2096.57 1788.23 2020.69 1950.55 12.93 11.57
painting 20.67 17.29 25.11 19.99 15.11 19.99 19.63 19.26 17.22
rendering 327.54 282.35 362.19 333.28 318.36 327.54 324.74 8.87 7.94
UPDATE_POST_TITLE
scripting 3018.12 2466.64 2890.29 3054 2478.45 2890.29 2781.5 10.37 9.28
painting 33.79 19.68 31.5 29.02 14.83 29.02 25.76 31.56 28.22
rendering 514.19 378.57 398.78 497.99 373.61 398.78 432.63 15.71 14.05
OPEN_MODAL
scripting 1256.42 1047.74 2591.27 1395.81 1341.47 1341.47 1526.54 39.94 35.73
painting 9.57 8.64 10.47 11.52 22.76 10.47 12.59 45.91 41.06
rendering 504.86 399.74 583.6 484.05 491.88 491.88 492.83 13.28 11.88
CLOSE_MODAL
scripting 1486.02 708.51 874.5 787.04 860.59 860.59 943.33 32.92 29.44
painting 4.66 4.89 14.23 9.55 11.33 9.55 8.93 46.47 41.55
rendering 331.69 331.06 372.81 468.99 393.71 372.81 379.65 14.95 13.37
SELECT_WIDGET_MENU_OPEN
scripting 1556.06 1530.43 1556.79 1488.07 1448.68 1530.43 1516.01 3.09 2.77
painting 8.28 5.61 9.17 12.08 6.07 8.28 8.24 31.67 28.28
rendering 516.67 493.67 522.26 501.39 502.19 502.19 507.24 2.33 2.08
SELECT_WIDGET_SELECT_OPTION
scripting 219.24 253.57 338.31 237.86 234.58 237.86 256.71 18.39 16.45
painting 8.67 9.28 10.62 10.49 4.7 9.28 8.75 27.54 24.57
rendering 17.62 16.32 13.63 15.06 16.01 16.01 15.73 9.47 8.46

@SatishGandham SatishGandham merged commit 8dc9c0b into release May 18, 2022
@SatishGandham SatishGandham deleted the feat/optimized-memoize-create-uneval-tree branch May 18, 2022 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage Performance Pod All things related to Appsmith performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: DataTreeFactory.create takes >300ms for complex application
4 participants