-
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
[APM] Optimize synthtrace #116091
[APM] Optimize synthtrace #116091
Conversation
Improve performance of synthtrace by using worker threads and sequential event ids.
Pinging @elastic/apm-ui (Team:apm) |
const limiter = pLimit(workers); | ||
|
||
return Promise.all(new Array(numBatches).fill(undefined).map((_) => limiter(processNextBatch))); |
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.
Can we speed this up even more by making it multi-threaded using the cluster module or pm2?
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.
Okay, I now see you are using worker_threads
which will add the multi-core support I was alluding to above.
return; | ||
} | ||
uploadNextBatch(); | ||
const worker = new Worker(Path.join(__dirname, './upload_next_batch.js'), { |
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.
Unfortunate that we have to refer to javascript files. Is something like this possible?
const { Worker, isMainThread } = require("worker_threads");
if (isMainThread) {
// start new worker
const worker = new Worker(__filename)
} else {
// run as worker
}
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.
we'd have to write everything in JavaScript (supported by node v16) and not use any compiler, I think.
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.
Why would we have to write everything in javascript? The code is executed at runtime where __filename
would resolve to the javascript file (even if the source is typescript).
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.
you'd have to build it first though?
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.
Nice improvement!
const document = {}; | ||
|
||
Object.assign(document, esDocumentDefaults); |
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.
nit: what about:
const document = {}; | |
Object.assign(document, esDocumentDefaults); | |
const document = { | |
...esDocumentDefaults | |
}; |
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.
performance, trying to squeeze as much perf out of this function as possible, as it's called very often.
Object.assign(values, event, { | ||
'@timestamp': new Date(event['@timestamp']!).toISOString(), | ||
'timestamp.us': event['@timestamp']! * 1000, |
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.
nit:
Object.assign(values, event, { | |
'@timestamp': new Date(event['@timestamp']!).toISOString(), | |
'timestamp.us': event['@timestamp']! * 1000, | |
const values = { | |
...event, | |
'@timestamp': new Date(event['@timestamp']!).toISOString(), | |
'timestamp.us': event['@timestamp']! * 1000, |
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
💔 Backport failed
To backport manually run: |
…-migrate-away-from-injected-css-js * 'master' of github.com:elastic/kibana: (347 commits) [Upgrade Assistant] Disable UI by default in 8.0 (elastic#115782) [Uptime] Added permission for new tls alert (elastic#116107) [APM] Optimize synthtrace (elastic#116091) Fix ux/apm inspector panel (elastic#116188) [RAC]: add experimental badge to alerts (elastic#116090) Unskip jest handled promise rejections (elastic#116021) [Lens] Improve tick placement for binary formatter (elastic#116158) chore: rename getApmHref to getLegacyApmHref (elastic#115689) [Security Solution] Validate ipv4/CIDR with format x.x.x.x/xx (elastic#116127) [Fleet] Use data stream name in query to get data stream info (elastic#115805) [Uptime] TLS and TLS legacy alert translation mismatch (elastic#116113) New field for integrations field (elastic#116175) Set required to false until the input is not visited (elastic#116099) Enable interactive setup by default (elastic#116141) Add not ready response to interactive setup (elastic#116138) Hide or button if needed (elastic#116124) [ML] Adding datafeed api tests (elastic#116133) Add page title to index advanced page (elastic#116134) chore: rename functions in aggregated_transactions helper (elastic#116001) Fix bug where number rendered as date (elastic#116224) ... # Conflicts: # x-pack/plugins/reporting/server/lib/screenshots/observable.ts # x-pack/plugins/reporting/server/lib/screenshots/open_url.ts
Friendly reminder: Looks like this PR hasn’t been backported yet. |
1 similar comment
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
Improve performance (10x) of synthtrace by using worker threads and sequential event ids.
TBD: