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

Upgrade RxJS to 7 #129087

Merged
merged 50 commits into from
Apr 12, 2022
Merged

Upgrade RxJS to 7 #129087

merged 50 commits into from
Apr 12, 2022

Conversation

afharo
Copy link
Member

@afharo afharo commented Mar 31, 2022

Summary

I needed an easy and repetitive task to clear my mind, so I thought I'd try what it would take to upgrade RxJS to the latest.

Fun fact: RxJS recently released 7.5.5, and we were sitting on 6.5.5. We're doing a whole major jump 😜

It might close #79751.

Motivation

Recently, we've identified a few performance issues related to RxJS observables:

This PR is to check how hard would it be to upgrade. If green, we can take a look at https://github.com/elastic/kibana-load-testing/ to measure the effect as compared to main.

Main breaking changes

  • TS inference has been improved in RxJS v7 so there are some type errors to fix
  • observable.toPromise() is deprecated. firstValueFrom or lastValueFrom are the way to go now. Refer to https://rxjs.dev/deprecations/to-promise for a deeper explanation.
  • void Subjects now need to be explicit in their declaration new Subject<void>() or calls to .next() will fail because they expect one parameter.
  • Updated some snapshots because the internal properties of the observer changed.
  • Updated redux-observer to 2.0.0 because the previous version did not work with RxJS v7
  • The internal implementation of the Scheduler now does not depend on the setTimeout, so jest.advanceTimers do not work any longer. We can either delay or use the fakeScheduler helper in our tests.

Performance tests results

It appears that the overall response time has been improved, except for the Canvas scenario:
image

cc @dmlemeshko to make better sense of the data 🙏

APM data

cc @lizozom and @mshustov, would you mind helping out to retrieve the APM stats to find out how would this affect the memory consumption?

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@afharo afharo added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting v8.3.0 ci:deploy-cloud labels Apr 1, 2022
Copy link
Contributor

@dokmic dokmic left a comment

Choose a reason for hiding this comment

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

Expressions changes LGTM 👍

@dokmic dokmic requested a review from a team April 6, 2022 13:01
wayneseymour added a commit that referenced this pull request Apr 7, 2022
While searching the ingestion system
for any [upcoming deprecations](#129087), I
noticed these scripts are no longer used.
Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

ML changes LGTM.

Copy link
Contributor

@LeeDr LeeDr left a comment

Choose a reason for hiding this comment

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

LGTM - only 2 files (package.json and yarn.lock) have QA team on them. Since this PR is targeting 8.3.0, we have a good amount of time before FF and GA to ensure there's no negative impacts and it helps to get it merged ASAP.

@afharo afharo removed the request for review from a team April 11, 2022 20:00
@afharo
Copy link
Member Author

afharo commented Apr 11, 2022

removing @elastic/kibana-app-services because this PR already got all the approvals from both sub-teams :)

EDIT: adding @mattkime

@afharo afharo requested a review from mattkime April 11, 2022 20:16
@@ -73,7 +74,7 @@ export class ReportingCsvPanelAction implements ActionDefinition<ActionContext>
}

public async getSearchSource(savedSearch: SavedSearch, _embeddable: ISearchEmbeddable) {
const [{ uiSettings }, { data }] = await this.startServices$.pipe(first()).toPromise();
const [{ uiSettings }, { data }] = await firstValueFrom(this.startServices$.pipe(first()));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe first() is not necessary here:

Suggested change
const [{ uiSettings }, { data }] = await firstValueFrom(this.startServices$.pipe(first()));
const [{ uiSettings }, { data }] = await firstValueFrom(this.startServices$);

Comment on lines 49 to 54
const delays$ = firstValueFrom(
delayOnClaimConflicts(of(maxWorkers), of(pollInterval), taskLifecycleEvents$, 80, 2).pipe(
take(2),
bufferCount(2)
)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

All of these refactoring introducing firstValueFrom seem to have dropped the typing.
Could we bring those back?
Other than that it looks good to me but I don't want to lose the type checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

As agreed on Slack. Even when the types are correctly inferred, we want to be explicit about them. Added them back in the form of firstValueFrom<number[]>(...)

Copy link
Contributor

@gmmorris gmmorris left a comment

Choose a reason for hiding this comment

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

LGTM once the typing is addressed 👍

@afharo afharo enabled auto-merge (squash) April 12, 2022 16:54
@afharo afharo merged commit 9d5aca5 into elastic:main Apr 12, 2022
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 2767 2766 -1
timelines 276 270 -6
total -7

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/std 63 59 -4

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 2.8MB 2.8MB +20.0B
canvas 1.0MB 1.0MB +27.0B
cases 283.8KB 283.8KB +1.0B
cloud 15.1KB 15.1KB +1.0B
cloudSecurityPosture 371.1KB 371.1KB +25.0B
controls 437.6KB 437.6KB +84.0B
core 132.3KB 132.3KB +1.0B
dashboard 295.4KB 295.4KB +16.0B
dataViewFieldEditor 148.0KB 148.0KB -9.0B
discover 407.0KB 407.2KB +152.0B
enterpriseSearch 1.5MB 1.5MB +1.0B
fileUpload 821.1KB 821.1KB +1.0B
fleet 692.7KB 692.7KB +1.0B
grokdebugger 59.1KB 59.1KB +3.0B
kibanaReact 212.0KB 212.0KB +2.0B
kibanaUtils 51.6KB 51.6KB +1.0B
lens 1.0MB 1.0MB +1.0B
maps 2.7MB 2.7MB +69.0B
mapsEms 81.4KB 81.4KB +1.0B
ml 3.3MB 3.3MB +128.0B
monitoring 471.1KB 471.1KB +1.0B
osquery 998.5KB 998.7KB +145.0B
security 493.7KB 493.7KB +3.0B
securitySolution 4.8MB 4.8MB +93.0B
snapshotRestore 258.8KB 258.8KB +1.0B
stackAlerts 202.8KB 202.9KB +22.0B
unifiedSearch 138.3KB 138.3KB +1.0B
ux 170.2KB 170.2KB +1.0B
visTypeTimeseries 470.6KB 470.6KB +6.0B
total +799.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/std 2 1 -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cloudSecurityPosture 4.4KB 4.4KB +48.0B
core 319.1KB 319.1KB +5.0B
crossClusterReplication 11.9KB 11.9KB -19.0B
dashboard 66.7KB 66.7KB +1.0B
data 422.5KB 422.6KB +85.0B
dataViewFieldEditor 24.4KB 24.4KB -59.0B
fleet 110.9KB 110.9KB +1.0B
grokdebugger 4.7KB 4.7KB -19.0B
indexLifecycleManagement 27.1KB 27.0KB -19.0B
indexManagement 27.2KB 27.2KB +1.0B
infra 88.2KB 88.2KB +21.0B
kbnUiSharedDeps-npmDll 4.8MB 4.8MB -31.1KB
kbnUiSharedDeps-srcJs 3.8MB 3.8MB -766.0B
kibanaUtils 67.9KB 67.9KB +1.0B
licenseManagement 10.2KB 10.2KB -19.0B
licensing 8.6KB 8.6KB -10.0B
osquery 16.2KB 16.2KB +48.0B
painlessLab 10.5KB 10.5KB -19.0B
reporting 38.9KB 38.9KB -18.0B
searchprofiler 21.9KB 21.9KB -19.0B
securitySolution 250.5KB 248.3KB -2.2KB
telemetry 27.6KB 27.6KB +1.0B
timelines 286.8KB 282.0KB -4.8KB
upgradeAssistant 19.3KB 19.3KB +1.0B
total -38.8KB
Unknown metric groups

API count

id before after diff
@kbn/std 96 92 -4

ESLint disabled line counts

id before after diff
core 56 57 +1

Total ESLint disabled count

id before after diff
core 66 67 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@afharo afharo deleted the upgrade-rxjs-to-7 branch April 12, 2022 19:40
jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 13, 2022
…disable-server-side

* 'main' of github.com:elastic/kibana: (35 commits)
  [Uptime] remove latency limit warnings when using monitor management (elastic#129597)
  [Security Solution] [ReponseOps] Executes Cases Cypress test when there is a change on cases plugin (elastic#129992)
  Paramaterized Discover tests (elastic#129684)
  [Security Solution][Investigations] - Minor bug fixes (elastic#130054)
  [DOCS} Adds technical preview to Lens annotations (elastic#130058)
  [Security solution] [Endpoint] Revisit blocklist wrong labels (elastic#128773)
  [Security Solutions] Adds API docs for value lists (elastic#129962)
  [CI] Move jest tests to spot instances, and fix spot retries in PRs (elastic#130045)
  chore(NA): upgrades rules_node_js to v5.4.0 (elastic#130051)
  [SecuritySolution] Remove the cell hovers actions for agent status (elastic#130042)
  Upgrade RxJS to 7 (elastic#129087)
  [SecuritySolution] Clean up CaseContext (elastic#130036)
  Revert "chore(NA): upgrades rules_node_js to v5.4.0 (elastic#130021)"
  Use RuleDataReader to query for threshold signal history (elastic#129763)
  Remove securityRulesCancelEnabled setting and set shorter default timeouts (elastic#129769)
  Upgrade EUI to v54.0.0 (elastic#129653)
  [Security Solution] More Ransomware exceptionable fields (elastic#130039)
  Add e2e for the apm integration policy form (elastic#129860)
  chore(NA): upgrades rules_node_js to v5.4.0 (elastic#130021)
  [ML] Fix Single Metric Viewer chart failing to load if no points during calendar event (elastic#130000)
  ...

# Conflicts:
#	x-pack/plugins/screenshotting/server/screenshots/index.test.ts
jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 13, 2022
…rint-media-attempt-2

* 'main' of github.com:elastic/kibana: (75 commits)
  [Lens] Hide disabled toolbar entries (elastic#129994)
  Fix explore tables don't display data when a global filter is applied (elastic#130024)
  [Console] Add option to disable keyboard shortcuts (elastic#128887)
  [Discover] Update refreshOnClick flaky test (elastic#130001)
  [Uptime] remove latency limit warnings when using monitor management (elastic#129597)
  [Security Solution] [ReponseOps] Executes Cases Cypress test when there is a change on cases plugin (elastic#129992)
  Paramaterized Discover tests (elastic#129684)
  [Security Solution][Investigations] - Minor bug fixes (elastic#130054)
  [DOCS} Adds technical preview to Lens annotations (elastic#130058)
  [Security solution] [Endpoint] Revisit blocklist wrong labels (elastic#128773)
  [Security Solutions] Adds API docs for value lists (elastic#129962)
  [CI] Move jest tests to spot instances, and fix spot retries in PRs (elastic#130045)
  chore(NA): upgrades rules_node_js to v5.4.0 (elastic#130051)
  [SecuritySolution] Remove the cell hovers actions for agent status (elastic#130042)
  Upgrade RxJS to 7 (elastic#129087)
  [SecuritySolution] Clean up CaseContext (elastic#130036)
  Revert "chore(NA): upgrades rules_node_js to v5.4.0 (elastic#130021)"
  Use RuleDataReader to query for threshold signal history (elastic#129763)
  Remove securityRulesCancelEnabled setting and set shorter default timeouts (elastic#129769)
  Upgrade EUI to v54.0.0 (elastic#129653)
  ...

# Conflicts:
#	x-pack/plugins/screenshotting/server/formats/pdf/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prepare for RxJS v7