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

timestamp opt (20-25% speed increase) #5

Merged
merged 2 commits into from
Mar 9, 2016
Merged

timestamp opt (20-25% speed increase) #5

merged 2 commits into from
Mar 9, 2016

Conversation

davidmarkclements
Copy link
Member

When we profile an isolated benchmark with http://npm.im/0x (again) we can see that toISOString is hot (10.8% on stack 8.72% on top of stack)

screen shot 2016-03-09 at 14 01 02

If we alter out timestamps from ISO to epoch, we get the following flamegraph showing that Date.now() is far less expensive that Date.prototype.toISOString

screen shot 2016-03-09 at 14 01 22

Removing the bottleneck gives us a 20-25% perf increase:

benchPino_10000: 369.998ms
benchPino2_10000: 278.406ms
benchPinoObj_10000: 431.747ms
benchPinoObj2_10000: 347.675ms
benchPino_10000: 344.995ms
benchPino2_10000: 272.239ms
benchPinoObj_10000: 420.123ms
benchPinoObj2_10000: 340.240ms

We can keep consistent log output formatting via the pino command, by applying the toISOString call at the point of transformation.

@davidmarkclements
Copy link
Member Author

oh - also added CLI usage

@mcollina
Copy link
Member

mcollina commented Mar 9, 2016

👍 but we should make this configurable via a constructor option.
There are cases where this is needed.

@davidmarkclements
Copy link
Member Author

My contention is we should provide the most optimal approach to logging

We're positioning pino as the fastest logger, so do we really want to add an option that slows it down?

I'm thinking we should encourage post processing

@davidmarkclements
Copy link
Member Author

ok after discussion we decided to go with an option with an ominous name "slowtime", a warning in the readme, and the ability to transform json logs with the pino command line tool using the -t flag.

mcollina added a commit that referenced this pull request Mar 9, 2016
timestamp opt (20-25% speed increase)
@mcollina mcollina merged commit e358d56 into master Mar 9, 2016
@mcollina mcollina deleted the timestamp branch March 9, 2016 16:16
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants