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

Button: Removing Stack usage to improve perf #9516

Merged
merged 10 commits into from
Jun 26, 2019

Conversation

khmakoto
Copy link
Member

@khmakoto khmakoto commented Jun 19, 2019

Pull request checklist

  • Addresses an existing issue: Fixes #0000
  • Include a change request file using $ npm run change

Description of changes

This PR removes Stack in favor of emulating it with flex-box styles in Button, MenuButton and SplitButton, in order to improve the performance of the component.

To check for the perf changes I pulled the changes @JasonGore has been working on with puppeteer and flamebearer to get sample counts instead of time counts. These scenarios render the components 5000 times. I ran each scenario 10 times to get an average number and account for variants.

Below are the sample counts for each of the variants before and after the Stack removal.

DefaultButton:

Scenario Run 1 Run 2 Run 3 Run 4 Run 5 Run 6 Run 7 Run 8 Run 9 Run 10 Average
Before Stack removal 1451 1515 1473 1454 1498 1439 1531 1498 1604 1508 1497.1
After Stack removal 1152 1039 1100 1132 1143 1169 1099 1165 1156 1184 1133.9

Improvement of 24.26%.

PrimaryButton:

Scenario Run 1 Run 2 Run 3 Run 4 Run 5 Run 6 Run 7 Run 8 Run 9 Run 10 Average
Before Stack removal 1459 1541 1427 1550 1521 1492 1492 1546 1630 1534 1519.2
After Stack removal 1093 1162 1139 1207 1182 1201 1167 1166 1154 1200 1167.1

Improvement of 23.18%.

MenuButton:

Scenario Run 1 Run 2 Run 3 Run 4 Run 5 Run 6 Run 7 Run 8 Run 9 Run 10 Average
Before Stack removal 2392 2413 2514 2494 2434 2448 2406 2455 2537 2421 2451.4
After Stack removal 2150 2127 2137 2128 2118 2146 2197 2203 2206 2161 2157.3

Improvement of 12.00%.

SplitButton:

Scenario Run 1 Run 2 Run 3 Run 4 Run 5 Run 6 Run 7 Run 8 Run 9 Run 10 Average
Before Stack removal 5088 5024 4988 5015 5102 5026 5031 5117 5110 5098 5059.9
After Stack removal 3810 3847 3910 3771 3810 3656 3709 3724 3847 3803 3788.7

_Improvement of 25.12%.

Microsoft Reviewers: Open in CodeFlow

@size-auditor
Copy link

size-auditor bot commented Jun 19, 2019

Bundle test Size (minified) Diff from master
experiments-Button 85.772 kB BelowBaseline     -2.942 kB

ExceedsTolerance  Exceeds Tolerance     ExceedsBaseline  Exceeds Baseline     BelowBaseline  Below Baseline     1 kB = 1000 bytes

@micahgodbolt micahgodbolt mentioned this pull request Jun 19, 2019
37 tasks
Copy link
Member Author

@khmakoto khmakoto left a comment

Choose a reason for hiding this comment

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

A lot of files were touched because of prettier. I'm marking with comments those files where no logic was changed and only prettier changes were involved.

@msft-github-bot
Copy link
Contributor

msft-github-bot commented Jun 20, 2019

Component Perf Analysis:

Scenario Master Samples * PR Samples *
BaseButton 883 895
BaseButtonNew 3734 2536
DefaultButton 1175 1175
DefaultButtonNew 3241 2039
DetailsRow 8409 8535
DetailsRowNoStyles 6357 6298
DocumentCardTitle 44342 44246
MenuButton 2068 2078
MenuButtonNew 6473 4910
PrimaryButton 1391 1361
PrimaryButtonNew 3658 2427
SplitButton 3845 3847
SplitButtonNew 14086 9225
Toggle 2037 2018
ToggleNew 2553 2485
button 81 70
* Sample counts can vary by up to 30% and shouldn't be used solely for determining regression. Flamegraph links are provided to give a hint on deltas introduced by PRs and potential bottlenecks.

@khmakoto khmakoto removed the request for review from srideshpande June 20, 2019 20:50
@@ -1,6 +1,7 @@
import { IButtonComponent, IButtonStylesReturnType, IButtonTokenReturnType } from './Button.types';
import { getFocusStyle, getGlobalClassNames, FontWeights, HighContrastSelector } from '../../Styling';
import { IsFocusVisibleClassName } from '../../Utilities';
import { parseGap } from 'office-ui-fabric-react/lib/components/Stack/StackUtils';
Copy link
Member

Choose a reason for hiding this comment

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

This path doesn't seem right for a component styles file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was hoping to get your and @dzearing input here. Basically, I didn't want to rewrite the gap parsing function that lives inside Stack and the easiest way was to get it from this path, but I agree that it looks wrong in the context of a component styles file.

One thing we could do is make Stack export the StackUtils file which would allow us to use parseGap in other places just importing it from office-ui-fabric-react but it would increase the bundle-size of the Stack component.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is ok for now since this is an experimental component using an OUFR utility, but it should be changed once it's promoted to a relative path.

@@ -224,7 +224,7 @@ export class FocusZone extends React.Component<IFocusZoneProps, {}> implements I
// root props has been deprecated and should get removed.
// it needs to be marked as "any" since root props expects a div element, but really Tag can
// be any native element so typescript rightly flags this as a problem.
...(rootProps as any)
...rootProps as any
Copy link
Member Author

Choose a reason for hiding this comment

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

Prettier change.

@JasonGore
Copy link
Member

JasonGore commented Jun 25, 2019

PR Samples is off because the test ran against an older version of the perf-test script from a previous build in this PR due to a missed copy step in the CI workflow. I'll make a PR to fix and then merge master into this PR again.

@JasonGore JasonGore mentioned this pull request Jun 25, 2019
2 tasks
@msft-github-bot
Copy link
Contributor

Hello @khmakoto!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msft-github-bot) and give me an instruction to get started! Learn more here.

@msft-github-bot msft-github-bot merged commit 7f01905 into microsoft:master Jun 26, 2019
@khmakoto khmakoto deleted the buttonStackUsage branch June 26, 2019 22:52
@msft-github-bot
Copy link
Contributor

🎉office-ui-fabric-react@v7.6.1 has been released which incorporates this pull request.:tada:

Handy links:

gingeroun pushed a commit to gingeroun/office-ui-fabric-react that referenced this pull request Jul 5, 2019
* Button: Removing Stack usage from slots and view to improve perf.

* Adding change files for packages that were changed because of prettier.

* Deleting perf log files.

* Undoing prettier changes.

* Removing unused change files.

* Removing BaseButton changes from Actionable PR.
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants