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

core: faster saveTrace by streaming 500 events at a time #5387

Merged
merged 4 commits into from
Jun 11, 2018

Conversation

paulirish
Copy link
Member

@paulirish paulirish commented May 30, 2018

asset-saver-test.js goes from 12.5s to 7.9s.

cc #2593 #1685

for (const event of eventsIterator) {
yield `,\n ${JSON.stringify(event)}`;
eventsJSON += `,\n ${JSON.stringify(event)}`;
if (--eventsRemaining === 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

inline --x === always makes me think too much, WDYT about a separate statement :)

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

it's also possible messing with the stream these are pushed into would improve things in addition to or instead of this (would avoid the concat + flattening before writing to disk), but improvement is substantial so LGTM :)

* very large traces.
* Generates a JSON representation of traceData line-by-line to avoid OOM due to very large traces.
* COMPAT: As of Node 9, JSON.parse/stringify can handle 256MB+ strings. Once we drop support for
* Node 8, we can 'revert' PR #2593. See https://stackoverflow.com/a/47781288/89484
Copy link
Member

Choose a reason for hiding this comment

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

Once we drop support for Node 8, we can 'revert' PR #2593

not sure if we actually want to anymore...we like the event-per-line formatting, right?

(We could consider shipping the pretty-json-stringify we just used in the snyk snapshot thing—no dependencies and 2.43KB before minification!—but it looks like using it on large traces will depend on Node 9 as well)

@paulirish paulirish merged commit e71bad1 into master Jun 11, 2018
@paulirish paulirish deleted the faster-savetrace branch June 11, 2018 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants