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

http: add doc deprecation for private props #10941

Merged
merged 4 commits into from
Mar 9, 2017

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented Jan 21, 2017

This is one proposed solution to the current backwards compatibility issue (see #10558) in master with end users who directly access outgoingMessage._headers/outgoingMessage._headerNames.

This PR will be simplified some once #10805 is landed (which should land before this PR). Specifically, the ._headers getter can simply just return this.getHeaders().

/cc @nodejs/collaborators

CI: https://ci.nodejs.org/job/node-test-pull-request/6054/

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)
  • http

@mscdex mscdex added http Issues or PRs related to the http subsystem. wip Issues and PRs that are still a work in progress. labels Jan 21, 2017
@nodejs-github-bot nodejs-github-bot added http Issues or PRs related to the http subsystem. dont-land-on-v7.x labels Jan 21, 2017
@@ -182,7 +182,7 @@ function ClientRequest(options, cb) {
'client');
}
self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n',
self._headers);
self._headersStore);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use a Symbol to hide it more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does accessing a value via a Symbol have a perf hit vs. normal property access in master?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know. I'll look into making a benchmark.

Copy link
Member

@targos targos Jan 21, 2017

Choose a reason for hiding this comment

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

Results with the following benchmark (is it worth adding to the repo?): targos@d50c790

# master
$ ./node benchmark/es/object-property-bench.js
es/object-property-bench.js millions=1000 method="property": 1,137.5161172810194
es/object-property-bench.js millions=1000 method="string": 1,133.78613592118
es/object-property-bench.js millions=1000 method="variable": 1,137.9577172760735
es/object-property-bench.js millions=1000 method="symbol": 1,133.090467628974

# v7.4.0
$ node benchmark/es/object-property-bench.js
es/object-property-bench.js millions=1000 method="property": 1,136.7741112855451
es/object-property-bench.js millions=1000 method="string": 1,136.7865674716409
es/object-property-bench.js millions=1000 method="variable": 1,135.1437992275612
es/object-property-bench.js millions=1000 method="symbol": 1,136.4064052769731

# v4.7.1
$ node benchmark/es/object-property-bench.js
es/object-property-bench.js millions=1000 method="property": 1,135.4850535131566
es/object-property-bench.js millions=1000 method="string": 1,134.4381133016345
es/object-property-bench.js millions=1000 method="variable": 78.62998231306928
es/object-property-bench.js millions=1000 method="symbol": 81.82481813228071

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok so it might be worth sticking to properties for now.

As far as adding the benchmark, it could be useful. Although I'd probably put it in misc/ instead of es/ since it doesn't primarily deal with es6+ alternatives (which es/ seems to contain).

Copy link
Member

Choose a reason for hiding this comment

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

it might be worth sticking to properties for now

I don't think so. The numbers are very close and on multiple runs, the order varies a lot. It would be worth only for v4.x

Copy link
Member

Choose a reason for hiding this comment

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

@targos @mscdex this matches my findings. In practice I did not see any perf impact in using symbols since v7.

Copy link
Member

Choose a reason for hiding this comment

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

I've been testing this like crazy lately and from everything I have seen there is essentially zero perf impact from using symbols.

@jasnell
Copy link
Member

jasnell commented Jan 23, 2017

+1 to using a symbol instead.

@mscdex mscdex force-pushed the http-outgoingmessage-headers-deprecate branch from fd32784 to 16bd79c Compare January 25, 2017 21:20
@mscdex
Copy link
Contributor Author

mscdex commented Jan 25, 2017

@mscdex mscdex removed dont-land-on-v7.x wip Issues and PRs that are still a work in progress. labels Jan 25, 2017
@thefourtheye
Copy link
Contributor

Isn't this a major change?

@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jan 30, 2017
@addaleax addaleax added this to the 8.0.0 milestone Feb 15, 2017
@ChALkeR ChALkeR self-requested a review February 19, 2017 09:31
@mscdex
Copy link
Contributor Author

mscdex commented Feb 19, 2017

This PR needs at least one more approval from a @nodejs/ctc member in order for it to land (again, after #10805 lands).

@mscdex mscdex force-pushed the http-outgoingmessage-headers-deprecate branch 2 times, most recently from ce2aab4 to 953b97e Compare February 20, 2017 22:32
@mscdex
Copy link
Contributor Author

mscdex commented Feb 20, 2017

Updated PR to use one of the new http API methods and to reuse StorageObject instead of another custom storage object constructor.

CI: https://ci.nodejs.org/job/node-test-pull-request/6518/

@rvagg
Copy link
Member

rvagg commented Feb 21, 2017

do we have any ecosystem usage metrics for this? that's my only concern before agreeing.

@mscdex
Copy link
Contributor Author

mscdex commented Feb 21, 2017

@rvagg I don't know, all I can do is run in CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/586/

express/send has already started the process of migrating to using the existing getHeader() instead of _headers FWIW.

@rvagg
Copy link
Member

rvagg commented Feb 21, 2017

@ChALkeR are you still the one to find this data?

@dougwilson
Copy link
Member

P.S. I know I shouldn't have done this, but had some code that was

function clearHeaders (res) {
  res._headers = {}
  res._headerNames = {}
}

Obviously needs to change. Right now works on Node.js 8, but this landing will break even that without any warning. Should probably keep that working with a warning if the getters would keep working, right?

@mscdex
Copy link
Contributor Author

mscdex commented Feb 22, 2017

@dougwilson Yeah I'm not sure what the best solution to that would be as far as the behavior of the setter, since we'd probably have to just copy the values out of the object instead of just using the same object reference (because the internal representation changed). Should we blindly copy values in the ._headers setter or should we pass each name and value to .setHeader()?

Thoughts on this @nodejs/collaborators ?

@mscdex
Copy link
Contributor Author

mscdex commented Mar 6, 2017

I'll land this on Tuesday if there are no more objections before then.

Here's another CI: https://ci.nodejs.org/job/node-test-pull-request/6720/

@mikeal
Copy link
Contributor

mikeal commented Mar 6, 2017

It looks like a lot of reverse compatibility work has been done here, can we get a redux of what won't work anymore after this change?

@evanlucas
Copy link
Contributor

I'm still a bit concerned with deprecating res._headers. Although it isn't documented as a public api, it is used in so many places. Is it really justifiable to break the ecosystem like this?

@mscdex
Copy link
Contributor Author

mscdex commented Mar 7, 2017

@mikeal As far as I know there shouldn't really be any difference with the getters/setters in place.

@evanlucas I don't understand the concern, there is no runtime deprecation anymore. It's a documentation deprecation. Also there are now other public http APIs that cover all of the use cases I've seen thus far for accessing the private properties.

@mscdex mscdex force-pushed the http-outgoingmessage-headers-deprecate branch from 8126753 to 0cc96d1 Compare March 7, 2017 01:33
@evanlucas
Copy link
Contributor

@mscdex even with a docs only deprecation, that still more than likely means we are going to remove it eventually. I'm just not sure whether it is justified.

I do seem to be in the minority on this one though so ¯\(ツ)

@mscdex
Copy link
Contributor Author

mscdex commented Mar 8, 2017

@evanlucas Well yes, that is the plan for deprecations. I don't see how it's a problem considering it's only a docs deprecation for v8.0.0 and there are public methods that cover the current use cases for these private properties (these methods should be backported to v4.x and v6.x). IMHO there will be plenty of time for people to convert their code to use these new methods before the old, private properties become a runtime deprecation and eventually removed.

This PR also fixes a backwards compatibility issue that currently exists in master, so that is why I've been wanting to get this landed sooner than later.

@mscdex mscdex force-pushed the http-outgoingmessage-headers-deprecate branch from 0cc96d1 to 9be372f Compare March 9, 2017 08:43
@mscdex
Copy link
Contributor Author

mscdex commented Mar 9, 2017

mscdex added 4 commits March 9, 2017 05:50
PR-URL: nodejs#10941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: nodejs#10941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: nodejs#10941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: nodejs#10941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@mscdex mscdex force-pushed the http-outgoingmessage-headers-deprecate branch from 9be372f to 8243ca0 Compare March 9, 2017 10:50
@mscdex mscdex changed the title http: add deprecation warnings for private props http: add doc deprecation for private props Mar 9, 2017
@mscdex mscdex merged commit 8243ca0 into nodejs:master Mar 9, 2017
@mscdex mscdex removed the ctc-review label Mar 9, 2017
@mscdex mscdex deleted the http-outgoingmessage-headers-deprecate branch March 9, 2017 10:52
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
PR-URL: nodejs#10941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
PR-URL: nodejs#10941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
PR-URL: nodejs#10941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
PR-URL: nodejs#10941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@jasnell jasnell mentioned this pull request Apr 4, 2017
@tniessen tniessen added the deprecations Issues and PRs related to deprecations. label Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecations Issues and PRs related to deprecations. http Issues or PRs related to the http subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.