Repository navigation
Conversation
Several large libraries were loaded into server memory at plugin setup even though they are only needed when a specific feature is exercised. Convert their single eager import sites to dynamic imports at first use: - apache-arrow (146 modules): alerting_v2 arrow response format; loaded when an arrow-format ES|QL query runs. decodeArrowBatch now receives the Timestamp type id instead of importing the enum at module scope. - openpgp (25 modules): fleet package signature verification; loaded when a key is read or a signature verified. - @elastic/request-crypto + node-jose (134 modules): telemetry encryption; loaded when telemetry is sent. - pdfmake + fontkit + brotli: screenshotting imported worker_dependencies in the main thread purely to keep them in the release bundle; replace with a never-invoked dynamic-import reference so only the PDF worker thread loads them. - @kbn/inference-langchain: inference plugin chat-model factory; loaded when a chat model is requested. - @kbn/agent-builder-genai-utils: esql NL-to-ES|QL and suggest-fix routes; loaded when those routes are called. The langchain entry points only fully unload the langchain tree when the remaining eager roots (security_solution SIEM migrations, automatic_import, elastic_assistant, agent_builder) are also made lazy or disabled; they are still worth fixing at these chokepoints so minimal configurations benefit. All conversions sit inside already-async functions; no public API changes beyond decodeArrowBatch (internal to alerting_v2) gaining a parameter. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several large libraries are loaded into server memory at plugin setup even though they are only needed when a specific feature is exercised. An idle-heap inventory (heap snapshot + full multi-parent
require.cachegraph) showed each of these has a single — or very few — eager import roots, so they can be deferred with contained changes:apache-arrowalerting_v2arrow response format@elastic/request-crypto+node-jose+node-forgetelemetry_collection_managerencryptionopenpgppdfmake+fontkit+brotliscreenshottingmain thread (bundle-inclusion import)@kbn/inference-langchaininferencechat-model factory@kbn/agent-builder-genai-utilsesqlNL-to-ES|QL + suggest-fix routesNotes:
decodeArrowBatch(internal toalerting_v2) receiving the arrowType.Timestampid instead of importing the enum at module scope.screenshottingpreviously executedimport './worker_dependencies'on the main thread purely to keep pdfmake in the release bundle; this is now a never-invoked dynamic-import reference, so only the worker thread pays for it. Flagging for the owning team: please confirm the release-bundle scanner picks up dynamic import specifiers (pdfmake is also a rootpackage.jsondependency).Testing
node scripts/jestfor all touched areas: alerting_v2 formats (22), esql routes (48), telemetry encryption (7), fleet package verification (3), screenshotting pdf (2), inference client (7) — all passnode scripts/type_check --project …for all six touched plugins — pass🤖 Generated with Claude Code
Production measurements (cumulative)
Idle production source builds (
node scripts/build,bin/kibanaagainst a local ES, allocation-tracking preload, 2 min idle, GC-forced heap snapshot + full require graph; same machine and protocol for every row):main(63948de)Single-run samples; heap_used has ±10 MB run noise, snapshot self size is GC-forced and stabler.