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

console: sub-millisecond accuracy for console.time #3166

Merged
merged 3 commits into from
Oct 16, 2015

Conversation

targos
Copy link
Member

@targos targos commented Oct 3, 2015

This makes the output of console.timeEnd in line with major browsers.

@targos targos added the console Issues and PRs related to the console subsystem. label Oct 3, 2015
@targos
Copy link
Member Author

targos commented Oct 3, 2015

I just pushed an update to the doc.

@@ -93,7 +92,7 @@ Example:
;
}
console.timeEnd('100-elements');
// prints 100-elements: 262ms
// prints 100-elements: 225.438ms
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change is necessary?

Edit: Ah, I see it now. That is kind of the point of this PR

Copy link
Member

Choose a reason for hiding this comment

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

Bikeshedding: this belongs to the first commit «console: sub-millisecond accuracy for console.time», not to «doc: reword description of console.time».

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 moved this change to the first commit

@Trott
Copy link
Member

Trott commented Oct 3, 2015

Should it be semver-minor? More of an enhancement than a bug fix?

@Trott
Copy link
Member

Trott commented Oct 3, 2015

LGTM if CI is happy and if there's consensus on the semver implications of the change.

@targos targos added the semver-minor PRs that contain new features and should be released in the next minor version. label Oct 3, 2015
@targos
Copy link
Member Author

targos commented Oct 3, 2015

CI: https://ci.nodejs.org/job/node-test-commit/720/
I agree with @Trott about semver-minor.

timer's name as the parameter.
Starts a timer that can be used to compute the duration of an operation. Timers
are identified by a unique name. Use the same name when you call
[`console.timeEnd()`](#console_console_timeend_label) to stop the timer and
Copy link
Member

Choose a reason for hiding this comment

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

Does this break refs?

Copy link
Member

Choose a reason for hiding this comment

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

Btw, this change is not directly related to this PR.

@ChALkeR
Copy link
Member

ChALkeR commented Oct 3, 2015

The JS part LGTM.
I suspect that this breaks the docs, though. Why are those non-trivial changes in docs included in this PR, btw?

@targos
Copy link
Member Author

targos commented Oct 4, 2015

@ChALkeR you are right, the doc refs are broken because I changed the titles. Do you you prefer to review the doc changes in another PR or just a second commit in this one ?

assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim()));
assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim()));
assert.ok(/^constructor: \d+\.\d{3}ms$/.test(strings.shift().trim()));
assert.ok(/^hasOwnProperty: \d+\.\d{3}ms$/.test(strings.shift().trim()));
Copy link
Contributor

Choose a reason for hiding this comment

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

If we consider the output of the console functions to be part of the API, the I think one could view this as semver-major. The change to thses tests demonstrates how downstream apps output parsing will break.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I don't know what is the policy about console output.
Recent changes to the output of util.format were considered semver-minor IIRC.
cc @nodejs/collaborators

Copy link
Member

Choose a reason for hiding this comment

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

I'm going to say semver-minor for changes to console output but it's never as clear cut as it appears. For this, I personally feel it's small enough of a change that -minor is appropriate.

Copy link
Member

Choose a reason for hiding this comment

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

The probability of this breaking anything is near zero. Still, there seems to be no reason for pulling this into 4.x branch.

@Fishrock123
Copy link
Contributor

I'm not sure this isn't actually semver-major.

It's almost irrelevant right now. It'l probably have to land in v5.x anyways, but we should err on the side of caution still.

@targos targos removed the semver-minor PRs that contain new features and should be released in the next minor version. label Oct 6, 2015
@targos targos added this to the 5.0.0 milestone Oct 6, 2015
@targos targos added the semver-major PRs that contain breaking changes and should be released in the next major version. label Oct 6, 2015
@targos
Copy link
Member Author

targos commented Oct 6, 2015

OK for semver-major, this is safer. I added it to the 5.0 milestone.

@targos
Copy link
Member Author

targos commented Oct 7, 2015

I put the doc changes in a separate commit. PTAL.

@@ -74,16 +74,16 @@ Defaults to `false`. Colors are customizable, see below.

### console.time(label)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call the parameter timerName to be in line with mdn?

Copy link
Contributor

Choose a reason for hiding this comment

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

same could be done in code, maybe as a seperate commit too.

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

@ChALkeR
Copy link
Member

ChALkeR commented Oct 7, 2015

«console: sub-millisecond accuracy for console.time» + one-line doc change («262ms» → «225.438ms») LGTM.
«doc: reword description of console.time» — no review from me, I am not a native English speaker. Also, both versions look fine to me.

@evanlucas
Copy link
Contributor

LGTM if CI is green

@Trott
Copy link
Member

Trott commented Oct 8, 2015

semver-major means TSC has to review before landing, right?

@jasnell
Copy link
Member

jasnell commented Oct 8, 2015

@Trott ... no, semver-major changes can land in master at any time so long as there is good review. They cannot land in stable branches, however, without very good reason and TSC or LTS WG review.

@jasnell
Copy link
Member

jasnell commented Oct 8, 2015

That said, if the change may be controversial or particularly disruptive, you may want to hold off landing until more folks have had the time to review it.

@silverwind
Copy link
Contributor

@jasnell is correct. There's no reason to hold off universally approved semver-major commits with our current model, unless you specifically don't want something to land on the next major release.

@Trott
Copy link
Member

Trott commented Oct 8, 2015

The onboarding.md that I have bookmarked says this:

semver-major (breaking) changes must be reviewed in some form by the TSC

Maybe the onboarding.md needs to be updated? Or there's a newer one that I should use instead of the one I've been using? (I'm reluctant to post the link publicly here because it's a secret gist and not a public gist.)

Or maybe it really does need TSC review. As recently as three days ago, that was the conclusion for a different semver-major PR. #3078 (comment)

/cc @Fishrock123

@trevnorris
Copy link
Contributor

I don't think that means we need to have a formal vote on the breaking change. Only that someone from the TSC approves the PR.

@Trott
Copy link
Member

Trott commented Oct 8, 2015

@trevnorris +1 for a liberal interpretation of in some form.

@targos
Copy link
Member Author

targos commented Oct 8, 2015

@Fishrock123
Copy link
Contributor

@Trott ... no, semver-major changes can land in master at any time so long as there is good review. They cannot land in stable branches, however, without very good reason and TSC or LTS WG review.

I would dispute not:

Pull Requests that require an increase in the Major version must be elevated for review by the TSC. This does not necessarily mean that the PR must be put onto the TSC meeting agenda. If enough TSC members sign-off on the PR and there is clear consensus among TSC members for the change, the Pull Request can be landed. Where there is disagreement among TSC members, semver-major Pull Requests should be put on the TSC meeting agenda.

https://github.com/nodejs/dev-policy#accepting-modifications-through-a-consensus-seeking-process

I think it is best to keep it this way, at least for now.

@Fishrock123
Copy link
Contributor

I don't think that means we need to have a formal vote on the breaking change. Only that someone from the TSC approves the PR.

See above. :)

@targos
Copy link
Member Author

targos commented Oct 9, 2015

CI is happy minus the usual test-stringbytes-external.

@Trott @evanlucas @ChALkeR @nodejs/tsc: LGTY ?

are identified by a unique name. Use the same name when you call
[`console.timeEnd()`](#console_console_timeend_timername) to stop the timer and
output the elapsed time in milliseconds. Timer durations are accurate to the
sub-millisecond.
Copy link
Member

Choose a reason for hiding this comment

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

Nittiest of all possible nits: The last sentence describes the timer precision, not the accuracy.

Slightly less nitty nit: sub-millisecond is true, but we know that it will be three decimal places, so you could just say it's to the microsecond.

Of course, I can't come up with wording for either of these nits that's better than what's already there, so ¯_(ツ)_/¯

Copy link
Member Author

Choose a reason for hiding this comment

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

The last sentence describes the timer precision, not the accuracy.

You are right, I will replace "accurate" with "precise" when I land it if nobody objects.

... so you could just say it's to the microsecond

I wanted to do that but I am not sure it's true all the time and on all platforms. Perhaps if the CPU is overloaded we can lose precision ? I really don't know.

Copy link
Member

Choose a reason for hiding this comment

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

Another possibility is just to remove that last sentence entirely. I don't think MDN indicates how many decimal places their timer is good for, for example. People can use it and they get as many decimal places as they get.

MDN stuff for reference:

Copy link
Member Author

Choose a reason for hiding this comment

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

For this sentence I took inspiration from https://developer.chrome.com/devtools/docs/console-api#consoletimelabel
I fine with removing it as well

Copy link
Member

Choose a reason for hiding this comment

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

Ah. Well, in that case, I'm fine with leaving it. If it's good enough for Chrome docs, it's good enough for me.

Sorry for all the bikeshedding on this. LGTM no matter which way you decide to go with it (leave it, remove it, change it as described).

@Trott
Copy link
Member

Trott commented Oct 9, 2015

A couple of nits, but I'm OK if they're addressed at a later date or ignored entirely. (They're nits after all.)

LGTM

@silverwind
Copy link
Contributor

Overall LGTM. There's one more slight difference to browser implementations: They limit the amount of active timers to 10000. I don't think we need this, but at least mention it.

@targos
Copy link
Member Author

targos commented Oct 9, 2015

Yes, they also don't throw when you call console.timeEnd() with a non-existing timer. Another difference is that console.time() is a no-op if a timer with the same name is already running. Our implementation restarts it.
I'd like to improve this as well but I think it's out of scope for this PR.

@rvagg rvagg mentioned this pull request Oct 16, 2015
13 tasks
@targos
Copy link
Member Author

targos commented Oct 16, 2015

Can I have a sign-off from someone in @nodejs/tsc ?

@trevnorris
Copy link
Contributor

LGTM

This makes the output of console.timeEnd in line with major browsers.

PR-URL: nodejs#3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: nodejs#3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Name it timerName instead of label. It is clearer that way and matches
the description in the doc. It is also how it's named in MDN.

PR-URL: nodejs#3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
@targos targos merged commit 8c043c1 into nodejs:master Oct 16, 2015
@targos targos deleted the precise-console-time branch October 16, 2015 19:10
@targos
Copy link
Member Author

targos commented Oct 16, 2015

Thanks! Landed in 642928b...8c043c1

targos added a commit that referenced this pull request Oct 19, 2015
This makes the output of console.timeEnd in line with major browsers.

PR-URL: #3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
targos added a commit that referenced this pull request Oct 19, 2015
PR-URL: #3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
targos added a commit that referenced this pull request Oct 19, 2015
Name it timerName instead of label. It is clearer that way and matches
the description in the doc. It is also how it's named in MDN.

PR-URL: #3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
@rvagg rvagg mentioned this pull request Oct 21, 2015
rvagg added a commit to rvagg/io.js that referenced this pull request Oct 29, 2015
Notable changes:

* buffer: (Breaking) Removed both 'raw' and 'raws' encoding types from Buffer,
  these have been deprecated for a long time (Sakthipriyan Vairamani) nodejs#2859.
* console: (Breaking) Values reported by console.time() now have 3 decimals of
  accuracy added (Michaël Zasso) nodejs#3166.
* fs:
  - fs.readFile*(), fs.writeFile*(), and fs.appendFile*() now also accept a file
    descriptor as their first argument (Johannes Wüller) nodejs#3163.
  - (Breaking) In fs.readFile(), if an encoding is specified and the internal
    toString() fails the error is no longer thrown but is passed to the callback
    (Evan Lucas) nodejs#3485.
  - (Breaking) In fs.read() (using the fs.read(fd, length, position, encoding,
    callback) form), if the internal toString() fails the error is no longer
    thrown but is passed to the callback (Evan Lucas) nodejs#3503.
* http:
  - Fixed a bug where pipelined http requests would stall (Fedor Indutny) nodejs#3342.
  - (Breaking) When parsing HTTP, don't add duplicates of the following headers:
    Retry-After, ETag, Last-Modified, Server, Age, Expires. This is in addition
    to the following headers which already block duplicates: Content-Type,
    Content-Length, User-Agent, Referer, Host, Authorization,
    Proxy-Authorization, If-Modified-Since, If-Unmodified-Since, From, Location,
    Max-Forwards (James M Snell) nodejs#3090.
  - (Breaking) The callback argument to OutgoingMessage#setTimeout() must be a
    function or a TypeError is thrown (James M Snell) nodejs#3090.
  - (Breaking) HTTP methods and header names must now conform to the RFC 2616
    "token" rule, a list of allowed characters that excludes control characters
    and a number of separator characters. Specifically, methods and header names
    must now match /^[a-zA-Z0-9_!#$%&'*+.^`|~-]+$/ or a TypeError will be thrown
    (James M Snell) nodejs#2526.
* node:
  - (Breaking) Deprecated the _linklist module (Rich Trott) nodejs#3078.
  - (Breaking) Removed require.paths and require.registerExtension(), both had
    been previously set to throw Error when accessed
    (Sakthipriyan Vairamani) nodejs#2922.
* npm: Upgraded to version 3.3.6 from 2.14.7, see
  https://github.com/npm/npm/releases/tag/v3.3.6 for more details. This is a
  major version bump for npm and it has seen a significant amount of change.
  Please see the original npm v3.0.0 release notes for a list of major changes
  (Rebecca Turner) nodejs#3310.
* src: (Breaking) Bumped NODE_MODULE_VERSION to 47 from 46, this is necessary
  due to the V8 upgrade. Native add-ons will need to be recompiled
  (Rod Vagg) nodejs#3400.
* timers: Attempt to reuse the timer handle for setTimeout().unref(). This fixes
  a long-standing known issue where unrefed timers would perviously hold
  beforeExit open (Fedor Indutny) nodejs#3407.
* tls:
  - Added ALPN Support (Shigeki Ohtsu) nodejs#2564.
  - TLS options can now be passed in an object to createSecurePair()
    (Коренберг Марк) nodejs#2441.
  - (Breaking) The default minimum DH key size for tls.connect() is now 1024
    bits and a warning is shown when DH key size is less than 2048 bits. This a security consideration to prevent "logjam" attacks. A new minDHSize TLS
    option can be used to override the default. (Shigeki Ohtsu) nodejs#1831.
* util:
  - (Breaking) util.p() was deprecated for years, and has now been removed
    (Wyatt Preul) nodejs#3432.
  - (Breaking) util.inherits() can now work with ES6 classes. This is considered
    a breaking change because of potential subtle side-effects caused by a
    change from directly reassigning the prototype of the constructor using
    `ctor.prototype = Object.create(superCtor.prototype, { constructor: { ... } })`
    to using `Object.setPrototypeOf(ctor.prototype, superCtor.prototype)`
    (Michaël Zasso) nodejs#3455.
* v8: (Breaking) Upgraded to 4.6.85.25 from 4.5.103.35 (Ali Ijaz Sheikh) nodejs#3351.
  - Implements the spread operator, see
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator
    for further information.
  - Implements new.target, see
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target
    for further information.
* zlib: Decompression now throws on truncated input (e.g. unexpected end of
  file) (Yuval Brik) nodejs#2595.

PR-URL: nodejs#3466
rvagg added a commit that referenced this pull request Oct 29, 2015
Notable changes:

* buffer: (Breaking) Removed both 'raw' and 'raws' encoding types from Buffer,
  these have been deprecated for a long time (Sakthipriyan Vairamani) #2859.
* console: (Breaking) Values reported by console.time() now have 3 decimals of
  accuracy added (Michaël Zasso) #3166.
* fs:
  - fs.readFile*(), fs.writeFile*(), and fs.appendFile*() now also accept a file
    descriptor as their first argument (Johannes Wüller) #3163.
  - (Breaking) In fs.readFile(), if an encoding is specified and the internal
    toString() fails the error is no longer thrown but is passed to the callback
    (Evan Lucas) #3485.
  - (Breaking) In fs.read() (using the fs.read(fd, length, position, encoding,
    callback) form), if the internal toString() fails the error is no longer
    thrown but is passed to the callback (Evan Lucas) #3503.
* http:
  - Fixed a bug where pipelined http requests would stall (Fedor Indutny) #3342.
  - (Breaking) When parsing HTTP, don't add duplicates of the following headers:
    Retry-After, ETag, Last-Modified, Server, Age, Expires. This is in addition
    to the following headers which already block duplicates: Content-Type,
    Content-Length, User-Agent, Referer, Host, Authorization,
    Proxy-Authorization, If-Modified-Since, If-Unmodified-Since, From, Location,
    Max-Forwards (James M Snell) #3090.
  - (Breaking) The callback argument to OutgoingMessage#setTimeout() must be a
    function or a TypeError is thrown (James M Snell) #3090.
  - (Breaking) HTTP methods and header names must now conform to the RFC 2616
    "token" rule, a list of allowed characters that excludes control characters
    and a number of separator characters. Specifically, methods and header names
    must now match /^[a-zA-Z0-9_!#$%&'*+.^`|~-]+$/ or a TypeError will be thrown
    (James M Snell) #2526.
* node:
  - (Breaking) Deprecated the _linklist module (Rich Trott) #3078.
  - (Breaking) Removed require.paths and require.registerExtension(), both had
    been previously set to throw Error when accessed
    (Sakthipriyan Vairamani) #2922.
* npm: Upgraded to version 3.3.6 from 2.14.7, see
  https://github.com/npm/npm/releases/tag/v3.3.6 for more details. This is a
  major version bump for npm and it has seen a significant amount of change.
  Please see the original npm v3.0.0 release notes for a list of major changes
  (Rebecca Turner) #3310.
* src: (Breaking) Bumped NODE_MODULE_VERSION to 47 from 46, this is necessary
  due to the V8 upgrade. Native add-ons will need to be recompiled
  (Rod Vagg) #3400.
* timers: Attempt to reuse the timer handle for setTimeout().unref(). This fixes
  a long-standing known issue where unrefed timers would perviously hold
  beforeExit open (Fedor Indutny) #3407.
* tls:
  - Added ALPN Support (Shigeki Ohtsu) #2564.
  - TLS options can now be passed in an object to createSecurePair()
    (Коренберг Марк) #2441.
  - (Breaking) The default minimum DH key size for tls.connect() is now 1024
    bits and a warning is shown when DH key size is less than 2048 bits. This a security consideration to prevent "logjam" attacks. A new minDHSize TLS
    option can be used to override the default. (Shigeki Ohtsu) #1831.
* util:
  - (Breaking) util.p() was deprecated for years, and has now been removed
    (Wyatt Preul) #3432.
  - (Breaking) util.inherits() can now work with ES6 classes. This is considered
    a breaking change because of potential subtle side-effects caused by a
    change from directly reassigning the prototype of the constructor using
    `ctor.prototype = Object.create(superCtor.prototype, { constructor: { ... } })`
    to using `Object.setPrototypeOf(ctor.prototype, superCtor.prototype)`
    (Michaël Zasso) #3455.
* v8: (Breaking) Upgraded to 4.6.85.25 from 4.5.103.35 (Ali Ijaz Sheikh) #3351.
  - Implements the spread operator, see
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator
    for further information.
  - Implements new.target, see
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target
    for further information.
* zlib: Decompression now throws on truncated input (e.g. unexpected end of
  file) (Yuval Brik) #2595.

PR-URL: #3466
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
console Issues and PRs related to the console 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.

10 participants