1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

Reduce the frequency of DOM scans to rebuild inlines when scrolling revisions

Summary:
Ref T13513. See PHI1734, which raises a concern about the performance of large revisions near the 100-change threshold.

Currently, `getInlines()` is called whenever the scroll position transitions between two changesets, and it performs a relatively complicated DOM scan to lift inlines out of the document.

This shows up as taking a small but nontrivial amount of time in Firefox profiles and should be safely memoizable.

Test Plan:
  - Under Firefox profiling, scrolled through a large revision.
  - Before change: `getInlines()` appeared as the highest-cost thing we're explicitly doing on profiles.
  - After change: `getInlines()` was no longer meaningfully represented on profiles.
  - Created inlines, edited inlines, etc. Didn't identify any broken behavior.

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21261
This commit is contained in:
epriestley 2020-05-15 08:02:52 -07:00
parent b1351d0fdb
commit c666cb9f0b
2 changed files with 24 additions and 17 deletions

View file

@ -13,7 +13,7 @@ return array(
'core.pkg.js' => '845355f4', 'core.pkg.js' => '845355f4',
'dark-console.pkg.js' => '187792c2', 'dark-console.pkg.js' => '187792c2',
'differential.pkg.css' => '319dca29', 'differential.pkg.css' => '319dca29',
'differential.pkg.js' => '695827fc', 'differential.pkg.js' => 'bb2a17fc',
'diffusion.pkg.css' => '42c75c37', 'diffusion.pkg.css' => '42c75c37',
'diffusion.pkg.js' => 'a98c0bf7', 'diffusion.pkg.js' => 'a98c0bf7',
'maniphest.pkg.css' => '35995d6d', 'maniphest.pkg.css' => '35995d6d',
@ -379,7 +379,7 @@ return array(
'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => 'a2ab19be', 'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => 'a2ab19be',
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9', 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9',
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
'rsrc/js/application/diff/DiffChangeset.js' => 'bfdae878', 'rsrc/js/application/diff/DiffChangeset.js' => 'e02670b5',
'rsrc/js/application/diff/DiffChangesetList.js' => 'b1b8500b', 'rsrc/js/application/diff/DiffChangesetList.js' => 'b1b8500b',
'rsrc/js/application/diff/DiffInline.js' => 'b00168c1', 'rsrc/js/application/diff/DiffInline.js' => 'b00168c1',
'rsrc/js/application/diff/DiffPathView.js' => '8207abf9', 'rsrc/js/application/diff/DiffPathView.js' => '8207abf9',
@ -774,7 +774,7 @@ return array(
'phabricator-darklog' => '3b869402', 'phabricator-darklog' => '3b869402',
'phabricator-darkmessage' => '26cd4b73', 'phabricator-darkmessage' => '26cd4b73',
'phabricator-dashboard-css' => '5a205b9d', 'phabricator-dashboard-css' => '5a205b9d',
'phabricator-diff-changeset' => 'bfdae878', 'phabricator-diff-changeset' => 'e02670b5',
'phabricator-diff-changeset-list' => 'b1b8500b', 'phabricator-diff-changeset-list' => 'b1b8500b',
'phabricator-diff-inline' => 'b00168c1', 'phabricator-diff-inline' => 'b00168c1',
'phabricator-diff-path-view' => '8207abf9', 'phabricator-diff-path-view' => '8207abf9',
@ -2019,19 +2019,6 @@ return array(
'bcec20f0' => array( 'bcec20f0' => array(
'phui-theme-css', 'phui-theme-css',
), ),
'bfdae878' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
'javelin-workflow',
'javelin-router',
'javelin-behavior-device',
'javelin-vector',
'phabricator-diff-inline',
'phabricator-diff-path-view',
'phuix-button-view',
),
'c03f2fb4' => array( 'c03f2fb4' => array(
'javelin-install', 'javelin-install',
), ),
@ -2124,6 +2111,19 @@ return array(
'df3afa61' => array( 'df3afa61' => array(
'phui-inline-comment-view-css', 'phui-inline-comment-view-css',
), ),
'e02670b5' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
'javelin-workflow',
'javelin-router',
'javelin-behavior-device',
'javelin-vector',
'phabricator-diff-inline',
'phabricator-diff-path-view',
'phuix-button-view',
),
'e150bd50' => array( 'e150bd50' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',

View file

@ -817,11 +817,18 @@ JX.install('DiffChangeset', {
}, },
getInlines: function() { getInlines: function() {
if (this._inlines === null) {
this._rebuildAllInlines(); this._rebuildAllInlines();
}
return this._inlines; return this._inlines;
}, },
_rebuildAllInlines: function() { _rebuildAllInlines: function() {
if (this._inlines === null) {
this._inlines = [];
}
var rows = JX.DOM.scry(this._node, 'tr'); var rows = JX.DOM.scry(this._node, 'tr');
var ii; var ii;
for (ii = 0; ii < rows.length; ii++) { for (ii = 0; ii < rows.length; ii++) {