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

Fix #42 #43

Merged
merged 5 commits into from
Dec 8, 2017
Merged

Fix #42 #43

merged 5 commits into from
Dec 8, 2017

Conversation

jsumners
Copy link
Member

@jsumners jsumners commented Dec 2, 2017

edger-reqs branch:

##### http-ndjson-equivalent-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg    Stdev   Max
Latency (ms) 9.92   30.01   282
Req/Sec      9869.6 660.97  10215
Bytes/Sec    1.1 MB 85.2 kB 1.18 MB

49k requests in 5s, 5.48 MB read

##### http-ndjson-minimal-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev   Max
Latency (ms) 8.88    26.83   249
Req/Sec      11032.8 803.97  11599
Bytes/Sec    1.23 MB 98.3 kB 1.31 MB

55k requests in 5s, 6.12 MB read

##### no-log-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev  Max
Latency (ms) 3.89    11.74  122
Req/Sec      25195.2 993.21 26095
Bytes/Sec    2.79 MB 128 kB 3.01 MB

126k requests in 5s, 14 MB read

##### pino-extreme-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev   Max
Latency (ms) 6.12    18.41   147
Req/Sec      16008.8 336.03  16279
Bytes/Sec    1.79 MB 26.2 kB 1.84 MB

80k requests in 5s, 8.88 MB read

##### pino-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev  Max
Latency (ms) 6.75    20.31  168
Req/Sec      14533.6 557.24 15079
Bytes/Sec    1.62 MB 49 kB  1.7 MB

73k requests in 5s, 8.07 MB read

master branch:

##### http-ndjson-equivalent-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg    Stdev   Max
Latency (ms) 9.92   30.05   280
Req/Sec      9868   753.84  10311
Bytes/Sec    1.1 MB 85.2 kB 1.18 MB

49k requests in 5s, 5.48 MB read

##### http-ndjson-minimal-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev   Max
Latency (ms) 8.92    27.09   231
Req/Sec      10981.6 1003.59 11823
Bytes/Sec    1.22 MB 112 kB  1.38 MB

55k requests in 5s, 6.09 MB read

##### no-log-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev  Max
Latency (ms) 3.88    11.77  137
Req/Sec      25211.2 981.49 26191
Bytes/Sec    2.79 MB 128 kB 3.01 MB

126k requests in 5s, 14 MB read

##### pino-extreme-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev   Max
Latency (ms) 6.03    18.12   151
Req/Sec      16264.8 310.96  16447
Bytes/Sec    1.79 MB 26.2 kB 1.84 MB

81k requests in 5s, 9.03 MB read

##### pino-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev   Max
Latency (ms) 6.83    20.56   165
Req/Sec      14348   287.56  14535
Bytes/Sec    1.59 MB 26.2 kB 1.64 MB

72k requests in 5s, 7.96 MB read

@coveralls
Copy link

coveralls commented Dec 2, 2017

Coverage Status

Coverage increased (+0.2%) to 98.333% when pulling 765c6b9 on edgar-reqs into c0851b5 on master.

@jsumners
Copy link
Member Author

jsumners commented Dec 3, 2017

I think this is going to be semver major. Custom req serializers no longer directly receive the whole request. They must access it via the req.raw property.

Given this, I think it is best to:

  1. Merge this PR
  2. Move the standard serializers out of pino and into pino-http (see Remove headers from standard http serializers pino#265)

That means pino will also see a major release. Not optimal, but the longer we wait the worse it will be.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 98.333% when pulling 626eede on edgar-reqs into c0851b5 on master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 98.333% when pulling 626eede on edgar-reqs into c0851b5 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 98.333% when pulling 626eede on edgar-reqs into c0851b5 on master.

logger.js Outdated
Object.defineProperty(_req, 'raw', {
enumerable: false,
value: req
})
Copy link
Member

Choose a reason for hiding this comment

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

Adding a new property via defineProperty in a serializer (which is a hot-path) is definitely not a good idea perf-wise. We should transform asReqValue in a class, and attach this property to its prototype, and always memorize it internally through a Symbol.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have updated the PR. I hope I have addressed your concern correctly.

@jsumners
Copy link
Member Author

jsumners commented Dec 3, 2017

Benchmarks for commit 5aebe40:

##### http-ndjson-equivalent-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg    Stdev   Max
Latency (ms) 9.98   30.23   273
Req/Sec      9808.8 744.08  10255
Bytes/Sec    1.1 MB 85.2 kB 1.18 MB

49k requests in 5s, 5.44 MB read

##### http-ndjson-minimal-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev   Max
Latency (ms) 8.86    26.8    242
Req/Sec      11066.4 822.95  11679
Bytes/Sec    1.24 MB 78.6 kB 1.31 MB

55k requests in 5s, 6.14 MB read

##### no-log-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev  Max
Latency (ms) 3.79    11.49  129
Req/Sec      25806.4 946.07 26543
Bytes/Sec    2.9 MB  105 kB 3.01 MB

129k requests in 5s, 14.3 MB read

##### pino-extreme-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev   Max
Latency (ms) 6.39    19.21   151
Req/Sec      15352.8 400.98  15751
Bytes/Sec    1.7 MB  52.4 kB 1.77 MB

77k requests in 5s, 8.52 MB read

##### pino-server.js #####

Running 5s test @ http://localhost:3000
100 connections with 10 pipelining factor

Stat         Avg     Stdev   Max
Latency (ms) 6.91    20.82   171
Req/Sec      14183.2 486.64  14527
Bytes/Sec    1.58 MB 52.4 kB 1.64 MB

71k requests in 5s, 7.87 MB read

@coveralls
Copy link

coveralls commented Dec 3, 2017

Coverage Status

Coverage decreased (-1.0%) to 97.183% when pulling 5aebe40 on edgar-reqs into c0851b5 on master.

writable: true,
value: ''
},
raw: {
Copy link
Member

Choose a reason for hiding this comment

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

at this point I fail to see the point of the symbol

@mcollina - thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

It gives a free non-enumerable. While writing this I learned:

const proto = Object.create({}, {
  foo: {
    enumerable: false,
    writable: true,
    value: {}
  }
})

const instance = Object.create(proto)
console.log('%j', instance) // {}

instance.foo = 'foo'
console.log('%j', instance) // {"foo":"foo"}

Copy link
Member

Choose a reason for hiding this comment

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

no sure – but you'd get that without the symbol and the getter/setter

Copy link
Member

Choose a reason for hiding this comment

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

whats req.raw for btw... I saw it in the hapi-pino implementation as well - whats the reasoning

Copy link
Member

@davidmarkclements davidmarkclements Dec 4, 2017

Choose a reason for hiding this comment

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

ah no no wait, you'd need a getter - but you could just return req

Copy link
Member Author

Choose a reason for hiding this comment

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

No, same thing happens with the getter and setter unless you wrap the object in a function with an enclosed variable to contain the value instead of set (val) { this._foo = val }.

As for req.raw, see comments hapijs/hapi-pino#34 (comment) and hapijs/hapi-pino#34 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

gotcha!

@@ -303,3 +303,34 @@ test('does not crash when no request connection object', function (t) {
res.end()
}
})

Copy link
Member

Choose a reason for hiding this comment

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

can we add a test for raw

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 98.592% when pulling 014c271 on edgar-reqs into c0851b5 on master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 98.592% when pulling 014c271 on edgar-reqs into c0851b5 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 98.592% when pulling 014c271 on edgar-reqs into c0851b5 on master.

@jsumners
Copy link
Member Author

jsumners commented Dec 5, 2017

@mcollina @davidmarkclements opinions on #43 (comment)? Or is this PR not semver major?

@davidmarkclements
Copy link
Member

I agree on major for pino-http

Even though I suggested removing serialisers from pino core I'm not sure I want to potentially break something someone is doing for the sake of purity

@davidmarkclements
Copy link
Member

We need to check that Koa integration works with this as well, should do - but worth a check

@jsumners
Copy link
Member Author

jsumners commented Dec 8, 2017

@davidmarkclements

koa-pino-logger zsh

@mcollina
Copy link
Member

mcollina commented Dec 8, 2017

I think we should bite the bullet and do the same thing for res as well, so that we can stop depending on the standard res serializers.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM anyway

@jsumners
Copy link
Member Author

jsumners commented Dec 8, 2017

@mcollina same PR or a different one?

@mcollina
Copy link
Member

mcollina commented Dec 8, 2017

@jsumners up to you :).

Is this semver-minor or semver-major for you? If it's semver-major, then I would combine them in a single release.

@jsumners
Copy link
Member Author

jsumners commented Dec 8, 2017

Both @davidmarkclements and I are of the opinion that this is semver-major.

@mcollina
Copy link
Member

mcollina commented Dec 8, 2017

I would prefer to combine this with the change on res as well before releasing!

@jsumners
Copy link
Member Author

jsumners commented Dec 8, 2017

@mcollina as you wish, it is done :)

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM :D Thanks!

@coveralls
Copy link

coveralls commented Dec 8, 2017

Coverage Status

Coverage increased (+0.6%) to 98.795% when pulling e5cfc82 on edgar-reqs into c0851b5 on master.

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.

4 participants