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

Projects
None yet
10 participants
@targos
Member

targos commented Oct 3, 2015

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

@targos targos added the console label Oct 3, 2015

@targos targos force-pushed the targos:precise-console-time branch Oct 3, 2015

@targos

This comment has been minimized.

Member

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

This comment has been minimized.

@thefourtheye

thefourtheye Oct 3, 2015

Contributor

Why this change is necessary?

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

This comment has been minimized.

@ChALkeR

ChALkeR Oct 7, 2015

Member

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

This comment has been minimized.

@targos

targos Oct 8, 2015

Member

I moved this change to the first commit

@Trott

This comment has been minimized.

Member

Trott commented Oct 3, 2015

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

@Trott

This comment has been minimized.

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 label Oct 3, 2015

@targos

This comment has been minimized.

Member

targos commented Oct 3, 2015

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

@ChALkeR

View changes

doc/api/console.markdown Outdated
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

This comment has been minimized.

@ChALkeR

ChALkeR Oct 3, 2015

Member

Does this break refs?

This comment has been minimized.

@ChALkeR

ChALkeR Oct 3, 2015

Member

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

@ChALkeR

View changes

doc/api/console.markdown Outdated
Stops a timer that was previously started by calling
[`console.time()`](#console_console_time_label) and print the result to the
[`console.time()`](#console_console_time_label) and prints the result to the

This comment has been minimized.

@ChALkeR

ChALkeR Oct 3, 2015

Member

Does this break refs?

@ChALkeR

This comment has been minimized.

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

This comment has been minimized.

Member

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()));

This comment has been minimized.

@aheckmann

aheckmann Oct 5, 2015

Contributor

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.

This comment has been minimized.

@targos

targos Oct 5, 2015

Member

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

This comment has been minimized.

@jasnell

jasnell Oct 6, 2015

Member

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.

This comment has been minimized.

@ChALkeR

ChALkeR Oct 7, 2015

Member

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

@Fishrock123

This comment has been minimized.

Member

Fishrock123 commented Oct 6, 2015

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 label Oct 6, 2015

@targos targos added this to the 5.0.0 milestone Oct 6, 2015

@targos targos added the semver-major label Oct 6, 2015

@targos

This comment has been minimized.

Member

targos commented Oct 6, 2015

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

@targos targos force-pushed the targos:precise-console-time branch Oct 7, 2015

@targos

This comment has been minimized.

Member

targos commented Oct 7, 2015

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

@silverwind

View changes

doc/api/console.markdown Outdated
@@ -74,16 +74,16 @@ Defaults to `false`. Colors are customizable, see below.
### console.time(label)

This comment has been minimized.

@silverwind

silverwind Oct 7, 2015

Contributor

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

This comment has been minimized.

@silverwind

silverwind Oct 7, 2015

Contributor

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

This comment has been minimized.

@targos

targos Oct 8, 2015

Member

done

@ChALkeR

This comment has been minimized.

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

This comment has been minimized.

Member

evanlucas commented Oct 8, 2015

LGTM if CI is green

@Trott

This comment has been minimized.

Member

Trott commented Oct 8, 2015

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

@jasnell

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Contributor

silverwind commented Oct 8, 2015

@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

This comment has been minimized.

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

This comment has been minimized.

Contributor

trevnorris commented Oct 8, 2015

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

This comment has been minimized.

Member

Trott commented Oct 8, 2015

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

@targos targos force-pushed the targos:precise-console-time branch 2 times, most recently Oct 8, 2015

@targos

This comment has been minimized.

Member

targos commented Oct 8, 2015

@Fishrock123

This comment has been minimized.

Member

Fishrock123 commented Oct 9, 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.

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

This comment has been minimized.

Member

Fishrock123 commented Oct 9, 2015

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

This comment has been minimized.

Member

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.

This comment has been minimized.

@Trott

Trott Oct 9, 2015

Member

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 ¯_(ツ)_/¯

This comment has been minimized.

@targos

targos Oct 9, 2015

Member

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.

This comment has been minimized.

@Trott

Trott Oct 9, 2015

Member

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:

This comment has been minimized.

@targos

targos Oct 9, 2015

Member

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

This comment has been minimized.

@Trott

Trott Oct 9, 2015

Member

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

This comment has been minimized.

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

This comment has been minimized.

Contributor

silverwind commented Oct 9, 2015

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

This comment has been minimized.

Member

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 referenced this pull request Oct 16, 2015

Closed

v5.0.0 Planning & Checklist #3397

13 of 13 tasks complete
@targos

This comment has been minimized.

Member

targos commented Oct 16, 2015

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

@trevnorris

This comment has been minimized.

Contributor

trevnorris commented Oct 16, 2015

LGTM

targos added some commits Oct 7, 2015

console: sub-millisecond accuracy for console.time
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>
doc: reword description of console.time
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>
console: rename argument of time and timeEnd
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>

@targos targos force-pushed the targos:precise-console-time branch to 8c043c1 Oct 16, 2015

@targos targos merged commit 8c043c1 into nodejs:master Oct 16, 2015

@targos targos deleted the targos:precise-console-time branch Oct 16, 2015

@targos

This comment has been minimized.

Member

targos commented Oct 16, 2015

Thanks! Landed in 642928b...8c043c1

targos added a commit that referenced this pull request Oct 19, 2015

console: sub-millisecond accuracy for console.time
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

doc: reword description of console.time
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

console: rename argument of time and timeEnd
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 referenced this pull request Oct 21, 2015

Merged

Release proposal: v5.0.0 #3466

rvagg added a commit to rvagg/io.js that referenced this pull request Oct 29, 2015

2015-10-29, Version 5.0.0 (Stable)
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

2015-10-29, Version 5.0.0 (Stable)
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