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

[1 of N] Optimizing Line, Area and Utility code for performance improvement #27263

Merged
merged 14 commits into from
Jun 30, 2023

Conversation

ankityadav4
Copy link
Contributor

@ankityadav4 ankityadav4 commented Mar 20, 2023

Previous Behavior

image
image

New Behavior

In this PR we have enhanced the performance by doing:
1.Optimizing code for Line, Area and cartesian chart. We have optimized time complexity for pre computational task which had impact FCP, TTI and TBTMetrics.
2. we have also made DOM lighter by limiting the precision digits for path
3. We have also used 2 flags in our code to roll out the performance changes , first flag enablePerfOptimization which is exposed to user to enable the performance related changes and second flag is _enableComputationOptimization(true by default) which is used internally and is not exposed to user. This second flag is used to control the individual performance changes in code. This will help in debugging code easily if some issue comes after rolling out the changes. _enableComputationOptimization is used for optimized code to group data points by x value from O(n^2) to O(n) using a map.

Performance improvement for Area, Line Charts

image
image

Related Issue(s)

  • Fixes #

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 20, 2023

📊 Bundle size report

Unchanged fixtures
Package & Exports Size (minified/GZIP)
global-context
createContext
510 B
330 B
global-context
createContextSelector
537 B
342 B
priority-overflow
createOverflowManager
4.248 kB
1.671 kB
react-accordion
Accordion (including children components)
88.246 kB
26.712 kB
react-alert
Alert
82.552 kB
21.771 kB
react-avatar
Avatar
47.7 kB
14.504 kB
react-avatar
AvatarGroup
15.682 kB
6.306 kB
react-avatar
AvatarGroupItem
63.876 kB
18.984 kB
react-badge
Badge
23.591 kB
7.264 kB
react-badge
CounterBadge
24.493 kB
7.565 kB
react-badge
PresenceBadge
22.213 kB
7.872 kB
react-button
Button
36.778 kB
9.51 kB
react-button
CompoundButton
43.932 kB
10.99 kB
react-button
MenuButton
40.965 kB
10.705 kB
react-button
SplitButton
49.197 kB
12.27 kB
react-button
ToggleButton
55.06 kB
11.446 kB
react-card
Card - All
89.11 kB
25.236 kB
react-card
Card
83.764 kB
23.685 kB
react-card
CardFooter
9.229 kB
3.9 kB
react-card
CardHeader
11.402 kB
4.683 kB
react-card
CardPreview
10.034 kB
4.248 kB
react-checkbox
Checkbox
33.164 kB
10.699 kB
react-combobox
Combobox (including child components)
86.98 kB
28.084 kB
react-combobox
Dropdown (including child components)
85.321 kB
27.675 kB
react-components
react-components: Button, FluentProvider & webLightTheme
65.162 kB
17.952 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
210.395 kB
58.717 kB
react-components
react-components: FluentProvider & webLightTheme
36.395 kB
11.996 kB
react-datepicker-compat
DatePicker Compat
221.924 kB
59.118 kB
react-dialog
Dialog (including children components)
92.138 kB
27.487 kB
react-divider
Divider
17.477 kB
6.357 kB
react-field
Field
18.003 kB
6.931 kB
react-image
Image
11.55 kB
4.627 kB
react-infobutton
InfoButton
131.191 kB
40.269 kB
react-infobutton
InfoLabel
134.656 kB
41.338 kB
react-input
Input
24.219 kB
7.781 kB
react-label
Label
10.175 kB
4.243 kB
react-link
Link
12.375 kB
5.113 kB
react-menu
Menu (including children components)
132.388 kB
40.52 kB
react-menu
Menu (including selectable components)
135.152 kB
41.012 kB
react-overflow
hooks only
12.505 kB
4.626 kB
react-persona
Persona
54.621 kB
16.435 kB
react-popover
Popover
119.781 kB
36.844 kB
react-portal
Portal
11.82 kB
4.391 kB
react-portal-compat
PortalCompatProvider
6.473 kB
2.196 kB
react-positioning
usePositioning
24.249 kB
8.856 kB
react-progress
ProgressBar
13.927 kB
5.488 kB
react-provider
FluentProvider
18.115 kB
6.719 kB
react-radio
Radio
26.952 kB
8.608 kB
react-radio
RadioGroup
11.362 kB
4.753 kB
react-select
Select
24.915 kB
8.708 kB
react-slider
Slider
34.358 kB
11.107 kB
react-spinbutton
SpinButton
33.452 kB
10.296 kB
react-spinner
Spinner
21.363 kB
7.021 kB
react-switch
Switch
29.472 kB
9.226 kB
react-table
DataGrid
156.955 kB
42.834 kB
react-table
Table (Primitives only)
44.652 kB
12.468 kB
react-table
Table as DataGrid
132.615 kB
33.871 kB
react-table
Table (Selection only)
78.215 kB
19.263 kB
react-table
Table (Sort only)
76.891 kB
18.989 kB
react-tags
Tag
23.153 kB
7.922 kB
react-text
Text - Default
12.563 kB
4.972 kB
react-text
Text - Wrappers
15.713 kB
5.293 kB
react-textarea
Textarea
27.69 kB
9.125 kB
react-theme
Single theme token import
69 B
89 B
react-theme
Teams: all themes
31.987 kB
6.85 kB
react-theme
Teams: Light theme
18.121 kB
5.194 kB
react-tooltip
Tooltip
47.319 kB
16.618 kB
react-utilities
SSRProvider
180 B
159 B
🤖 This report was generated against cbfa9a3717782183ebc86149abcde6468f97afa8

@size-auditor
Copy link

size-auditor bot commented Mar 20, 2023

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: cbfa9a3717782183ebc86149abcde6468f97afa8 (build)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 20, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5b002a4:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 23, 2023

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 574 608 5000
Button mount 280 297 5000
Field mount 1082 1076 5000
FluentProvider mount 652 636 5000
FluentProviderWithTheme mount 79 70 10
FluentProviderWithTheme virtual-rerender 66 69 10
FluentProviderWithTheme virtual-rerender-with-unmount 80 84 10
InfoButton mount 11 8 5000
MakeStyles mount 817 849 50000
Persona mount 1606 1557 5000
SpinButton mount 1263 1281 5000

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 23, 2023

🕵 fluentuiv9 No visual regressions between this PR and main

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 23, 2023

🕵 FluentUI-v0 No visual regressions between this PR and main

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 23, 2023

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
AttachmentMinimalPerf.default 86 75 1.15:1
RefMinimalPerf.default 115 104 1.11:1
IconMinimalPerf.default 389 351 1.11:1
TreeWith60ListItems.default 92 84 1.1:1
AlertMinimalPerf.default 157 145 1.08:1
ChatWithPopoverPerf.default 202 187 1.08:1
InputMinimalPerf.default 552 513 1.08:1
AttachmentSlotsPerf.default 661 626 1.06:1
AvatarMinimalPerf.default 111 106 1.05:1
FormMinimalPerf.default 231 221 1.05:1
AccordionMinimalPerf.default 82 79 1.04:1
ChatDuplicateMessagesPerf.default 152 146 1.04:1
DropdownMinimalPerf.default 1457 1400 1.04:1
LabelMinimalPerf.default 224 216 1.04:1
ListMinimalPerf.default 317 304 1.04:1
ProviderMinimalPerf.default 202 195 1.04:1
DropdownManyItemsPerf.default 405 395 1.03:1
ListCommonPerf.default 394 384 1.03:1
MenuButtonMinimalPerf.default 965 940 1.03:1
SplitButtonMinimalPerf.default 2303 2235 1.03:1
ButtonOverridesMissPerf.default 660 644 1.02:1
ChatMinimalPerf.default 448 439 1.02:1
DialogMinimalPerf.default 455 448 1.02:1
FlexMinimalPerf.default 154 151 1.02:1
ItemLayoutMinimalPerf.default 707 693 1.02:1
MenuMinimalPerf.default 498 487 1.02:1
ProviderMergeThemesPerf.default 671 661 1.02:1
SegmentMinimalPerf.default 199 195 1.02:1
SkeletonMinimalPerf.default 201 198 1.02:1
SliderMinimalPerf.default 754 741 1.02:1
TextAreaMinimalPerf.default 296 290 1.02:1
ToolbarMinimalPerf.default 546 535 1.02:1
VideoMinimalPerf.default 438 431 1.02:1
GridMinimalPerf.default 186 184 1.01:1
HeaderSlotsPerf.default 468 465 1.01:1
ImageMinimalPerf.default 212 209 1.01:1
LoaderMinimalPerf.default 187 186 1.01:1
PortalMinimalPerf.default 84 83 1.01:1
StatusMinimalPerf.default 401 399 1.01:1
AnimationMinimalPerf.default 298 298 1:1
ButtonMinimalPerf.default 89 89 1:1
CheckboxMinimalPerf.default 1151 1156 1:1
DatepickerMinimalPerf.default 3684 3670 1:1
LayoutMinimalPerf.default 201 201 1:1
ListWith60ListItems.default 376 376 1:1
TableMinimalPerf.default 240 240 1:1
TooltipMinimalPerf.default 1253 1248 1:1
CardMinimalPerf.default 308 310 0.99:1
CarouselMinimalPerf.default 258 261 0.99:1
DividerMinimalPerf.default 202 205 0.99:1
EmbedMinimalPerf.default 1845 1867 0.99:1
HeaderMinimalPerf.default 202 205 0.99:1
ListNestedPerf.default 325 327 0.99:1
RadioGroupMinimalPerf.default 265 268 0.99:1
TableManyItemsPerf.default 1104 1117 0.99:1
TextMinimalPerf.default 187 189 0.99:1
CustomToolbarPrototype.default 1465 1483 0.99:1
BoxMinimalPerf.default 194 197 0.98:1
RosterPerf.default 1500 1528 0.98:1
PopupMinimalPerf.default 354 360 0.98:1
ButtonSlotsPerf.default 316 330 0.96:1
TreeMinimalPerf.default 470 490 0.96:1
ReactionMinimalPerf.default 207 218 0.95:1

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 23, 2023

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 614 618 5000
Breadcrumb mount 1641 1639 1000
Checkbox mount 1681 1683 5000
CheckboxBase mount 1451 1430 5000
ChoiceGroup mount 2920 2919 5000
ComboBox mount 638 653 1000
CommandBar mount 6153 6134 1000
ContextualMenu mount 12083 11981 1000
DefaultButton mount 723 738 5000
DetailsRow mount 2175 2215 5000
DetailsRowFast mount 2201 2155 5000
DetailsRowNoStyles mount 1976 1979 5000
Dialog mount 2526 2527 1000
DocumentCardTitle mount 225 226 1000
Dropdown mount 1877 1948 5000
FocusTrapZone mount 1081 1098 5000
FocusZone mount 1024 1013 5000
GroupedList mount 40572 40971 2
GroupedList virtual-rerender 17650 19538 2
GroupedList virtual-rerender-with-unmount 49387 49630 2
GroupedListV2 mount 212 219 2
GroupedListV2 virtual-rerender 202 206 2
GroupedListV2 virtual-rerender-with-unmount 209 217 2
IconButton mount 1059 1052 5000
Label mount 334 337 5000
Layer mount 2684 2687 5000
Link mount 387 378 5000
MenuButton mount 929 921 5000
MessageBar mount 21003 21245 5000
Nav mount 1904 1874 1000
OverflowSet mount 793 777 5000
Panel mount 1743 1734 1000
Persona mount 717 726 1000
Pivot mount 875 900 1000
PrimaryButton mount 812 817 5000
Rating mount 4512 4539 5000
SearchBox mount 879 926 5000
Shimmer mount 1842 1891 5000
Slider mount 1330 1297 5000
SpinButton mount 2831 2819 5000
Spinner mount 376 372 5000
SplitButton mount 1818 1758 5000
Stack mount 408 409 5000
StackWithIntrinsicChildren mount 850 870 5000
StackWithTextChildren mount 2636 2607 5000
SwatchColorPicker mount 5970 5963 5000
TagPicker mount 1444 1490 5000
Text mount 363 375 5000
TextField mount 960 953 5000
ThemeProvider mount 824 828 5000
ThemeProvider virtual-rerender 592 591 5000
ThemeProvider virtual-rerender-with-unmount 1236 1270 5000
Toggle mount 587 613 5000
buttonNative mount 184 193 5000

@AtishayMsft AtishayMsft changed the title Optimizing Line, Area and Utility code for performance improvement [1 of N] Optimizing Line, Area and Utility code for performance improvement May 25, 2023
@fabricteam
Copy link
Collaborator

fabricteam commented May 25, 2023

🕵 fluentuiv8 No visual regressions between this PR and main

@ankityadav4 ankityadav4 marked this pull request as ready for review June 28, 2023 17:37
@ankityadav4 ankityadav4 requested review from a team as code owners June 28, 2023 17:37
@AtishayMsft AtishayMsft merged commit 8fde970 into microsoft:master Jun 30, 2023
@msft-fluent-ui-bot
Copy link
Collaborator

🎉@fluentui/react-charting@v5.16.49 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants