-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[kbn/optimizer] implement more efficient auto transpilation for node #79052
[kbn/optimizer] implement more efficient auto transpilation for node #79052
Conversation
4682ae7
to
6d25fa0
Compare
62b9db2
to
6079712
Compare
…-optimizer-auto-transpile # Conflicts: # yarn.lock
Pinging @elastic/kibana-operations (Team:Operations) |
Pinging @elastic/apm-ui (Team:apm) |
@spalger as this introduces a native module dependency for the kbn optimizer it will cause problems with the bazel remote cache mechanism. Do you think we can fork |
@mistic Do you mind if we work on this after merging? I'd like to suggest using prebuildify to the lmdb-store devs rather than forking and maintaining a fork, but I need to learn about how that works first. |
@spalger that is totally okay! Just wanted to raise a flag here so we can take care of it sooner rather than later 😃 |
// for a much more detailed explanation | ||
require('./register'); | ||
require('./polyfill'); | ||
export * from './node_auto_tranpilation'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spalger why don't we create a new package called @kbn/node-env
or just @kbn/node
in order to store that logic plus the one we have on src/setup_node_env
? Do you think that will be to much and we should just add it to the kbn/optimizer
extending its boundaries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be too little to justify a new package personally, and it fits into what I had imagined @kbn/optimizer
would become. I also plan to move the rest of setup_node_env into @kbn/optimizer/node
but just taking the simplest path for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
💚 Build SucceededMetrics [docs]@kbn/ui-shared-deps asset size
async chunks size
distributable file count
page load bundle size
History
To update your PR or re-run it, just comment with: |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
…lastic#79052) Co-authored-by: spalger <[email protected]> # Conflicts: # packages/kbn-optimizer/package.json # src/dev/build/tasks/create_empty_dirs_and_files_task.ts # src/setup_node_env/babel_register/register.js # yarn.lock
… node (#79052) (#79395) (#79408) * [kbn/optimizer] implement more efficient auto transpilation for node (#79052) Co-authored-by: spalger <[email protected]> # Conflicts: # packages/kbn-optimizer/package.json # src/dev/build/tasks/create_empty_dirs_and_files_task.ts # src/setup_node_env/babel_register/register.js # yarn.lock * fix eslint violation * add core-js production dependency (#79395) Co-authored-by: spalger <[email protected]> (cherry picked from commit 9e1c44f) Co-authored-by: spalger <[email protected]>
* master: (128 commits) add core-js production dependency (elastic#79395) Add support for sharing saved objects to all spaces (elastic#76132) [Alerting UI] Display a banner to users when some alerts have failures, added alert statuses column and filters (elastic#79038) load js-yaml lazily (elastic#79092) skip flaky suite (elastic#77278) Fix agentPolicyUpdateEventHandler() to use app context soClient for creation of actions (elastic#79341) [Security Solution] Untitled Timeline created when first action is to add note (elastic#78988) [Security Solutions][Detection Engine] Updates the edit rules page to:wq! only have what is selected for editing (elastic#79233) Cleanup yarn.lock from duplicates (elastic#66617) [kbn/optimizer] implement more efficient auto transpilation for node (elastic#79052) [Ingest Manager] Rename Fleet setup and requirement, Fleet => Central… (elastic#79291) [core/server/plugins] don't run discovery in dev server parent process (take 2) (elastic#79358) [babel/register] remove from build (take 2) (elastic#79379) [Security Solution] Changes rules table tag display (elastic#77102) define integrationTestRoot in config file and use to define screensho… (elastic#79247) Revert "[babel/register] remove from build (elastic#79176)" skip flaky suite (elastic#75241) [Uptime] Synthetics UI (elastic#77960) [Security Solution] [Detections] Only display actions options if user has "read" privileges (elastic#78812) [babel/register] remove from build (elastic#79176) ...
* master: (288 commits) add core-js production dependency (elastic#79395) Add support for sharing saved objects to all spaces (elastic#76132) [Alerting UI] Display a banner to users when some alerts have failures, added alert statuses column and filters (elastic#79038) load js-yaml lazily (elastic#79092) skip flaky suite (elastic#77278) Fix agentPolicyUpdateEventHandler() to use app context soClient for creation of actions (elastic#79341) [Security Solution] Untitled Timeline created when first action is to add note (elastic#78988) [Security Solutions][Detection Engine] Updates the edit rules page to only have what is selected for editing (elastic#79233) Cleanup yarn.lock from duplicates (elastic#66617) [kbn/optimizer] implement more efficient auto transpilation for node (elastic#79052) [Ingest Manager] Rename Fleet setup and requirement, Fleet => Central… (elastic#79291) [core/server/plugins] don't run discovery in dev server parent process (take 2) (elastic#79358) [babel/register] remove from build (take 2) (elastic#79379) [Security Solution] Changes rules table tag display (elastic#77102) define integrationTestRoot in config file and use to define screensho… (elastic#79247) Revert "[babel/register] remove from build (elastic#79176)" skip flaky suite (elastic#75241) [Uptime] Synthetics UI (elastic#77960) [Security Solution] [Detections] Only display actions options if user has "read" privileges (elastic#78812) [babel/register] remove from build (elastic#79176) ...
Blocked by #78168
Probably fixes: #79052
Experimental reimplementation of
@babel/register
using lmdb-store as the cache instead of a simple object in memory.lmdb-store
provides synchronous access to values stored in a memory-mapped file and does writes batched and asynchronously. This makes it a really nice fit for this use-case and allows us to keep jit-transpilation without the cost of loading the entire cache into memory or writing it all back to disk at once.Additionally, the cache implementation in this PR keeps caches from multiple babel configurations (like you might experience on different branches of Kibana) and automatically prunes values from the cache after they haven't been accessed for 30 days.
Stats:
all these measurements were taken with optimizer bundles fully cached and using the default
--max-old-space-size
(without #78710 merged)master:
time to server listening, no cache: 91 seconds
time to server listening, with cache: 40 seconds
memory of parent process, no cache: ~850mb
idle memory of parent process, with cache: 760mb
idle memory of server process, with cache: 1.1gb
this pr:
time to server listening, no cache: 63 seconds
time to server listening, with cache: 16 seconds
memory of parent process, no cache: ~650mb
idle memory of parent process, with cache: 300mb
idle memory of server process, with cache: 320mb