Skip to content

Comments

[ES|QL] remove worker#218006

Merged
drewdaemon merged 33 commits intoelastic:mainfrom
drewdaemon:217923/remove-worker
Apr 15, 2025
Merged

[ES|QL] remove worker#218006
drewdaemon merged 33 commits intoelastic:mainfrom
drewdaemon:217923/remove-worker

Conversation

@drewdaemon
Copy link
Contributor

@drewdaemon drewdaemon commented Apr 11, 2025

Summary

Fix #217923

Investigations in #217368 showed that there was basically no performance impact to passing the AST across a thread boundary. But we also didn't detect a pressing reason to remove the worker.

Since then, however, we noticed another cost associated with the worker: it's a hefty Javascript file, even in production builds. In addition, we are doing parsing on the main thread and the worker, so the kbn-esql-ast package is actually being loaded and parsed twice by the browser, once for the main thread and once for the worker.

This PR removes our worker. Our parsing associated with validation and autocomplete will still be done asynchronously, but on the main thread.

I do not see any regression in perceived performance.

@drewdaemon drewdaemon added Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana t// backport:version Backport to applied version labels v9.1.0 v8.19.0 release_note:skip Skip the PR/issue when compiling release notes labels Apr 11, 2025
@drewdaemon drewdaemon marked this pull request as ready for review April 13, 2025 00:50
@drewdaemon drewdaemon requested review from a team as code owners April 13, 2025 00:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-esql (Team:ESQL)

@drewdaemon
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor

I will wait for the CI to get green and review afterwards

@stratoula
Copy link
Contributor

stratoula commented Apr 14, 2025

@drewdaemon I see 2 tasks in the same PR:

  • remove wroker
  • remove the deprecated getAstAndSyntaxErrors in favor of parse

They are not connected as far as I can understand, are they? I wonder if it makes sense to break it into 2 PRs as is a bit difficult to me to understand which are the things necessary to change from the worker removal (also in case of revert we will revert only the worker changes)

@stratoula
Copy link
Contributor

/ci

@drewdaemon
Copy link
Contributor Author

@stratoula point taken—they are connected but not strongly—I should probably not have gone as far as I did with the related cleanup.

is a bit difficult to me to understand which are the things necessary to change from the worker removal

You can see just the worker changes in 0a4713e

Hopefully that helps... let me know if you still want me to put in the effort to pull these tasks apart.

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

The commit helped Drew, thanx!

LGTM, I tested it locally and I can't see any performance degradation. (also much simpler code)

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #1 / RegisteredAttachmentsPropertyActions renders the correct number of actions

Metrics [docs]

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/esql-ast 253 248 -5
@kbn/esql-validation-autocomplete 162 160 -2
@kbn/monaco 184 182 -2
total -9

Async chunks

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

id before after diff
dataVisualizer 611.3KB 611.3KB -16.0B
discover 970.7KB 970.6KB -16.0B
total -32.0B

Page load bundle

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

id before after diff
data 400.0KB 400.0KB -16.0B
kbnUiSharedDeps-srcJs 3.6MB 3.6MB -1002.0B
total -1018.0B
Unknown metric groups

API count

id before after diff
@kbn/esql-ast 318 313 -5
@kbn/esql-validation-autocomplete 182 180 -2
@kbn/monaco 184 182 -2
total -9

ESLint disabled in files

id before after diff
@kbn/monaco 8 7 -1

References to deprecated APIs

id before after diff
@kbn/esql-validation-autocomplete 1 3 +2
@kbn/monaco 0 2 +2
total +4

Total ESLint disabled count

id before after diff
@kbn/monaco 14 13 -1

History

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +11 to +12
import { camelCase } from 'lodash';
import capitalize from 'lodash/capitalize';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I understand that IDE just reorganized imports

Suggested change
import { camelCase } from 'lodash';
import capitalize from 'lodash/capitalize';
import { camelCase, capitalize } from 'lodash';

@drewdaemon drewdaemon merged commit 9b4403b into elastic:main Apr 15, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/14474364386

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 218006

Questions ?

Please refer to the Backport tool documentation

@drewdaemon
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

drewdaemon added a commit to drewdaemon/kibana that referenced this pull request Apr 15, 2025
## Summary

Fix elastic#217923

Investigations in elastic#217368 showed
that there was basically no performance impact to passing the AST across
a thread boundary. But we also didn't detect a pressing reason to remove
the worker.

Since then, however, we noticed another cost associated with the worker:
it's a hefty Javascript file, even in production builds. In addition, we
are doing parsing on the main thread _and_ the worker, so the
`kbn-esql-ast` package is actually being loaded and parsed twice by the
browser, once for the main thread and once for the worker.

This PR removes our worker. Our parsing associated with validation and
autocomplete will still be done asynchronously, but on the main thread.

I do not see any regression in perceived performance.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
(cherry picked from commit 9b4403b)

# Conflicts:
#	src/platform/packages/shared/kbn-monaco/src/esql/language.ts
#	src/platform/packages/shared/kbn-monaco/src/esql/lib/converters/suggestions.ts
#	src/platform/packages/shared/kbn-monaco/src/esql/lib/esql_ast_provider.ts
#	src/platform/packages/shared/kbn-monaco/src/esql/lib/signature/index.ts
#	src/platform/packages/shared/kbn-monaco/src/esql/lib/types.ts
#	src/platform/packages/shared/kbn-monaco/src/esql/worker/esql.worker.ts
#	src/platform/packages/shared/kbn-monaco/src/esql/worker/esql_worker.ts
#	src/platform/packages/shared/kbn-monaco/src/register_globals.ts
#	src/platform/packages/shared/kbn-monaco/webpack.config.js
drewdaemon added a commit that referenced this pull request Apr 16, 2025
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] remove worker
(#218006)](#218006)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Drew
Tate","email":"drew.tate@elastic.co"},"sourceCommit":{"committedDate":"2025-04-15T16:18:07Z","message":"[ES|QL]
remove worker (#218006)\n\n## Summary\n\nFix
https://github.com/elastic/kibana/issues/217923\n\nInvestigations in
#217368 showed\nthat there was
basically no performance impact to passing the AST across\na thread
boundary. But we also didn't detect a pressing reason to remove\nthe
worker.\n\nSince then, however, we noticed another cost associated with
the worker:\nit's a hefty Javascript file, even in production builds. In
addition, we\nare doing parsing on the main thread _and_ the worker, so
the\n`kbn-esql-ast` package is actually being loaded and parsed twice by
the\nbrowser, once for the main thread and once for the worker.\n\nThis
PR removes our worker. Our parsing associated with validation
and\nautocomplete will still be done asynchronously, but on the main
thread.\n\nI do not see any regression in perceived
performance.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: Stratoula
Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"9b4403b7dc867de1db520e1f9e8ed07f22f41784","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0"],"title":"[ES|QL]
remove
worker","number":218006,"url":"https://github.com/elastic/kibana/pull/218006","mergeCommit":{"message":"[ES|QL]
remove worker (#218006)\n\n## Summary\n\nFix
https://github.com/elastic/kibana/issues/217923\n\nInvestigations in
#217368 showed\nthat there was
basically no performance impact to passing the AST across\na thread
boundary. But we also didn't detect a pressing reason to remove\nthe
worker.\n\nSince then, however, we noticed another cost associated with
the worker:\nit's a hefty Javascript file, even in production builds. In
addition, we\nare doing parsing on the main thread _and_ the worker, so
the\n`kbn-esql-ast` package is actually being loaded and parsed twice by
the\nbrowser, once for the main thread and once for the worker.\n\nThis
PR removes our worker. Our parsing associated with validation
and\nautocomplete will still be done asynchronously, but on the main
thread.\n\nI do not see any regression in perceived
performance.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: Stratoula
Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"9b4403b7dc867de1db520e1f9e8ed07f22f41784"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218006","number":218006,"mergeCommit":{"message":"[ES|QL]
remove worker (#218006)\n\n## Summary\n\nFix
https://github.com/elastic/kibana/issues/217923\n\nInvestigations in
#217368 showed\nthat there was
basically no performance impact to passing the AST across\na thread
boundary. But we also didn't detect a pressing reason to remove\nthe
worker.\n\nSince then, however, we noticed another cost associated with
the worker:\nit's a hefty Javascript file, even in production builds. In
addition, we\nare doing parsing on the main thread _and_ the worker, so
the\n`kbn-esql-ast` package is actually being loaded and parsed twice by
the\nbrowser, once for the main thread and once for the worker.\n\nThis
PR removes our worker. Our parsing associated with validation
and\nautocomplete will still be done asynchronously, but on the main
thread.\n\nI do not see any regression in perceived
performance.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: Stratoula
Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"9b4403b7dc867de1db520e1f9e8ed07f22f41784"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
drewdaemon added a commit to drewdaemon/kibana that referenced this pull request Apr 30, 2025
Fix elastic#217923

Investigations in elastic#217368 showed
that there was basically no performance impact to passing the AST across
a thread boundary. But we also didn't detect a pressing reason to remove
the worker.

Since then, however, we noticed another cost associated with the worker:
it's a hefty Javascript file, even in production builds. In addition, we
are doing parsing on the main thread _and_ the worker, so the
`kbn-esql-ast` package is actually being loaded and parsed twice by the
browser, once for the main thread and once for the worker.

This PR removes our worker. Our parsing associated with validation and
autocomplete will still be done asynchronously, but on the main thread.

I do not see any regression in perceived performance.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
(cherry picked from commit 9b4403b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels Feature:ES|QL ES|QL related features in Kibana release_note:skip Skip the PR/issue when compiling release notes Team:ESQL ES|QL related features in Kibana t// v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ES|QL] we have a heavy worker

8 participants