FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fs: add *timeNs properties to BigInt Stats objects by joyeecheung · Pull Request #21387 · nodejs/node · GitHub

/ node Public

fs: add *timeNs properties to BigInt Stats objects - #21387

Closed
joyeecheung wants to merge 1 commit into
nodejs:masterfrom
joyeecheung:bigint-ns
Closed

fs: add *timeNs properties to BigInt Stats objects#21387
joyeecheung wants to merge 1 commit into
nodejs:masterfrom
joyeecheung:bigint-ns

Conversation

Copy link
Copy Markdown
Member
  • Extend the aliased buffer for stats objects to contain
    the entire time spec (seconds and nanoseconds) for the time
    values instead of calculating the milliseconds in C++ and
    lose precision.
  • Calculate the nanosecond-precision time values in JS and expose
    them in BigInt Stats objects as *timeNs. The
    millisecond-precision values are now calculated from the
    nanosecond-precision values.
  • Refactor the hierarchy of stats objects and use ES6 classes.
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

nodejs-github-bot commented Jun 18, 2018
edited
Loading

Copy link
Copy Markdown
Collaborator

nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. labels Jun 18, 2018

Copy link
Copy Markdown
Member Author

Comment thread doc/api/fs.md Outdated
Comment thread doc/api/fs.md Outdated

Fishrock123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I like it. One nit.

Comment thread lib/internal/fs/utils.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

else would a touch clearer

joyeecheung Jun 27, 2018
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@Fishrock123 I think we prefer leaving out the else block for early returns? There used to a PR adding a lint rule for that although it didn't land due to the amount of churn.

jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jun 21, 2018

jasnell commented Jun 21, 2018

Copy link
Copy Markdown
Member

While I'm good with this, changing fs.Stats to a ES6 class is necessarily a semver-major change because fs.Stats() is no longer callable without new.

jasnell commented Jun 22, 2018

Copy link
Copy Markdown
Member

Just a thought... we may want to consider adding a custom toJSON() function to the BitIntStats object to avoid...

> JSON.stringify(fs.statSync('.', { bigint: true }))
TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)

Copy link
Copy Markdown
Member Author

JSON.stringify(fs.statSync('.', { bigint: true }))
TypeError: Do not know how to serialize a BigInt
at JSON.stringify ()

@jasnell hm, thanks for raising that up, but we need to be careful about the format we pick since people may store them into DB or send them to clients that are not implemented in JavaScript...

joyeecheung added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Jun 26, 2018

Copy link
Copy Markdown
Member Author

On a second thought, the ES6 classes probably does not worth making this semver major. I have changed it back to the ES5 way of doing things. @jasnell

joyeecheung removed the semver-major PRs that contain breaking changes and should be released in the next major version. label Jun 27, 2018

joyeecheung commented Jun 27, 2018
edited
Loading

Copy link
Copy Markdown
Member Author

joyeecheung commented Jul 5, 2018
edited
Loading

Copy link
Copy Markdown
Member Author

Ping @jasnell does this look good to you now as a non-semver-major?

jasnell commented Jul 10, 2018

Copy link
Copy Markdown
Member

Yes, looks good

Copy link
Copy Markdown
Member

Previous CI is inaccessible, new CI: https://ci.nodejs.org/job/node-test-pull-request/15855/

Trott commented Jul 18, 2018

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

Looks like it broke something related to #13255 on Windows, I'll investigate.

Failures in job https://ci.nodejs.org/job/node-test-pull-request/15920/

debian8-x86

See failures on test-softlayer-debian8-x86-1:
not ok 658 parallel/test-fs-utimes
  ---
  duration_ms: 0.331
  severity: fail
  exitcode: 1
  stack: |-
    assert.js:84
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
    + expected - actual
    
    - 2147483648
    + -2147483647.999
        at Object.<anonymous> (/home/iojs/build/workspace/node-test-commit-linux/nodes/debian8-x86/test/parallel/test-fs-utimes.js:196:10)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
        at startup (internal/bootstrap/node.js:266:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
  ...

ubuntu1404-32

See failures on test-digitalocean-ubuntu1404-x86-1:
not ok 601 parallel/test-fs-utimes
  ---
  duration_ms: 0.629
  severity: fail
  exitcode: 1
  stack: |-
    assert.js:84
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
    + expected - actual
    
    - 2147483648
    + -2147483647.999
        at Object.<anonymous> (/home/iojs/build/workspace/node-test-commit-linux/nodes/ubuntu1404-32/test/parallel/test-fs-utimes.js:196:10)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
        at startup (internal/bootstrap/node.js:266:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
  ...

ubuntu1604-32

See failures on test-digitalocean-ubuntu1604-x86-2:
not ok 658 parallel/test-fs-utimes
  ---
  duration_ms: 0.171
  severity: fail
  exitcode: 1
  stack: |-
    assert.js:84
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
    + expected - actual
    
    - 2147483648
    + -2147483647.999
        at Object.<anonymous> (/home/iojs/build/workspace/node-test-commit-linux/nodes/ubuntu1604-32/test/parallel/test-fs-utimes.js:196:10)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
        at startup (internal/bootstrap/node.js:266:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
  ...

COMPILED_BY=vs2017,RUNNER=win10,RUN_SUBSET=3

See failures on test-azure_msft-win10-x64-3:
not ok 165 parallel/test-fs-utimes
  ---
  duration_ms: 0.121
  severity: fail
  exitcode: 1
  stack: |-
    assert.js:84
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
    + expected - actual
    
    - 2147483648
    + -2147483647.999
        at Object.<anonymous> (c:\workspace\node-test-binary-windows\test\parallel\test-fs-utimes.js:196:10)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
        at startup (internal/bootstrap/node.js:266:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
  ...

COMPILED_BY=vs2017,RUNNER=win2008r2-vs2017,RUN_SUBSET=3

See failures on test-rackspace-win2008r2-x64-3:
not ok 165 parallel/test-fs-utimes
  ---
  duration_ms: 0.198
  severity: fail
  exitcode: 1
  stack: |-
    assert.js:84
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
    + expected - actual
    
    - 2147483648
    + -2147483647.999
        at Object.<anonymous> (c:\workspace\node-test-binary-windows\test\parallel\test-fs-utimes.js:196:10)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
        at startup (internal/bootstrap/node.js:266:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
  ...

COMPILED_BY=vs2017,RUNNER=win2016,RUN_SUBSET=3

See failures on test-azure_msft-win2016-x64-3:
not ok 165 parallel/test-fs-utimes
  ---
  duration_ms: 0.120
  severity: fail
  exitcode: 1
  stack: |-
    assert.js:84
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
    + expected - actual
    
    - 2147483648
    + -2147483647.999
        at Object.<anonymous> (c:\workspace\node-test-binary-windows\test\parallel\test-fs-utimes.js:196:10)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
        at startup (internal/bootstrap/node.js:266:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
  ...

COMPILED_BY=vs2017-x86,RUNNER=win2012r2,RUN_SUBSET=3

See failures on test-rackspace-win2012r2-x64-1:
not ok 165 parallel/test-fs-utimes
  ---
  duration_ms: 0.203
  severity: fail
  exitcode: 1
  stack: |-
    assert.js:84
      throw new AssertionError(obj);
      ^
    
    AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
    + expected - actual
    
    - 2147483648
    + -2147483647.999
        at Object.<anonymous> (c:\workspace\node-test-binary-windows\test\parallel\test-fs-utimes.js:196:10)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
        at startup (internal/bootstrap/node.js:266:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
  ...

BridgeAR removed the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Jul 18, 2018

Copy link
Copy Markdown
Member Author

Won't be able to be around a machine to look into this this week

jasnell commented Sep 10, 2018

Copy link
Copy Markdown
Member

What's the status on this one?

jasnell added the stalled Issues and PRs that are stalled. label Sep 10, 2018

Copy link
Copy Markdown

Can we try fixing merge conflicts and running the tests again? I'd be happy to give it a shot in another pull request

- Extend the aliased buffer for stats objects to contain
  the entire time spec (seconds and nanoseconds) for the time
  values instead of calculating the milliseconds in C++ and
  lose precision there.
- Calculate the nanosecond-precision time values in JS and expose
  them in BigInt Stats objects as `*timeNs`. The
  millisecond-precision values are now calculated from the
  nanosecond-precision values.

Copy link
Copy Markdown
Member Author

joyeecheung removed the stalled Issues and PRs that are stalled. label Jun 11, 2019
Comment thread lib/internal/fs/utils.js
stats[3 + offset], stats[4 + offset], stats[5 + offset],
stats[6 + offset], stats[7 + offset], stats[8 + offset],
stats[9 + offset],
msFromTimeSpec(stats[10 + offset], stats[11 + offset]),

joyeecheung Jun 11, 2019
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We can't pass a time spec into the Stats constructor as that would be a breaking change since Stats is public. We may try using some factory function to construct Stats internally from time specs later, and try adding the Ns properties to normal Stats later, though, but there will be some precision losses without bigint and that's not too different from multiplying the Ms ones with 1000

Copy link
Copy Markdown
Member Author

The CI is now green (minus an unrelated failure #27611 )

@jasnell @Fishrock123 can you please take a look again?

Also @devsnek this might be useful for #27850 , whichever lands first..

Comment thread doc/api/fs.md

### stats.atimeNs
<!-- YAML
added: REPLACEME

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This should be changed, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That'll only be available when this is released.

Copy link
Copy Markdown
Member Author

Copy link
Copy Markdown
Member Author

Landed in b245257

joyeecheung added semver-minor PRs that contain new features and should be released in the next minor version. and removed review wanted PRs that need reviews. labels Jun 13, 2019
joyeecheung added a commit that referenced this pull request Jun 13, 2019
- Extend the aliased buffer for stats objects to contain
  the entire time spec (seconds and nanoseconds) for the time
  values instead of calculating the milliseconds in C++ and
  lose precision there.
- Calculate the nanosecond-precision time values in JS and expose
  them in BigInt Stats objects as `*timeNs`. The
  millisecond-precision values are now calculated from the
  nanosecond-precision values.

PR-URL: #21387
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
BridgeAR pushed a commit that referenced this pull request Jun 17, 2019
- Extend the aliased buffer for stats objects to contain
  the entire time spec (seconds and nanoseconds) for the time
  values instead of calculating the milliseconds in C++ and
  lose precision there.
- Calculate the nanosecond-precision time values in JS and expose
  them in BigInt Stats objects as `*timeNs`. The
  millisecond-precision values are now calculated from the
  nanosecond-precision values.

PR-URL: #21387
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
BridgeAR mentioned this pull request Jun 17, 2019
targos mentioned this pull request Aug 19, 2019
2 tasks
BridgeAR pushed a commit that referenced this pull request Sep 3, 2019
- Extend the aliased buffer for stats objects to contain
  the entire time spec (seconds and nanoseconds) for the time
  values instead of calculating the milliseconds in C++ and
  lose precision there.
- Calculate the nanosecond-precision time values in JS and expose
  them in BigInt Stats objects as `*timeNs`. The
  millisecond-precision values are now calculated from the
  nanosecond-precision values.

PR-URL: #21387
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
BridgeAR mentioned this pull request Sep 3, 2019
BridgeAR added a commit that referenced this pull request Sep 3, 2019
Notable changes:

* deps:
  * Update npm to 6.10.3 (isaacs)
    #29023
* fs:
  * Add recursive option to rmdir() (cjihrig)
    #29168
  * Allow passing true to emitClose option (Giorgos Ntemiris)
    #29212
  * Add \*timeNs properties to BigInt Stats objects (Joyee Cheung)
    #21387
* net:
  * Allow reading data into a static buffer (Brian White)
    #25436

PR-URL: #29429
BridgeAR added a commit that referenced this pull request Sep 4, 2019
Notable changes:

* deps:
  * Update npm to 6.10.3 (isaacs)
    #29023
* fs:
  * Add recursive option to rmdir() (cjihrig)
    #29168
  * Allow passing true to emitClose option (Giorgos Ntemiris)
    #29212
  * Add \*timeNs properties to BigInt Stats objects (Joyee Cheung)
    #21387
* net:
  * Allow reading data into a static buffer (Brian White)
    #25436

PR-URL: #29429
BridgeAR added a commit that referenced this pull request Sep 4, 2019
Notable changes:

* deps:
  * Update npm to 6.10.3 (isaacs)
    #29023
* fs:
  * Add recursive option to rmdir() (cjihrig)
    #29168
  * Allow passing true to emitClose option (Giorgos Ntemiris)
    #29212
  * Add \*timeNs properties to BigInt Stats objects (Joyee Cheung)
    #21387
* net:
  * Allow reading data into a static buffer (Brian White)
    #25436

PR-URL: #29429
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.


Back | FazBrowse Home | New Git URL