You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide access to file system times with nanoseconds resolution #8276
Node.js should provide nanosecond time values in the fs.stat() response structure similar to how process.hrtime() does it.
If there is a module or trick to provide ns I would be happy to use that
Generally on Linux, human readable stat provides the nanoseconds, and epoch time provides the UTC second-level value. The combination is complete. Since Node.js uses ECMAScript Date objects, there is only millisecond resolution.
ext4 and Android has nanosecond time resolution since long time
Most Linux utilities still drop sub-seconds and Linux cannot display birth date easily
Some Android won't give you UTC allowing you to create lots of bugs calculating it
Here's Linux human readable
stat 0 --format %z
2016-06-14 00:50:44.920739523 -0700
If there is a module or trick to provide ns I would be happy to use that
If there isn't one already, you can write your own bindings for uv_fs_stat/uv_fs_fstat/uv_fs_lstat. That is what node.js itself uses and they support nanosecond resolution on file systems that support them and with the usual caveats.
Adding nanoseconds to fs.Stats is something I'd probably veto because of the performance implications. They're already expensive to create; tacking on more properties would only make it worse.
It might be possible to do something clever with interceptors and create values lazily but that would have to be benchmarked very carefully.
Both nanoseconds (kernel 2.6) and birth date (ext4) predates Node.js
These fs api calls should not have been designed this way in the first place. They knowingly lack file system features. The design of fs.*utimes does not adhere to good software engineering practices.
Additional constructive suggestions would be great!
Activity
bnoordhuis commentedon Aug 26, 2016
If there isn't one already, you can write your own bindings for uv_fs_stat/uv_fs_fstat/uv_fs_lstat. That is what node.js itself uses and they support nanosecond resolution on file systems that support them and with the usual caveats.
Adding nanoseconds to
fs.Statsis something I'd probably veto because of the performance implications. They're already expensive to create; tacking on more properties would only make it worse.It might be possible to do something clever with interceptors and create values lazily but that would have to be benchmarked very carefully.
haraldrudell commentedon Aug 26, 2016
The performance impact is to copy 4 C long to ECMAScript number
fs.*utimes() api needs update, too
bnoordhuis commentedon Aug 26, 2016
With all due respect but that comment betrays a certain ignorance of node's and V8's inner workings.
haraldrudell commentedon Aug 29, 2016
Both nanoseconds (kernel 2.6) and birth date (ext4) predates Node.js
These fs api calls should not have been designed this way in the first place. They knowingly lack file system features. The design of fs.*utimes does not adhere to good software engineering practices.
Additional constructive suggestions would be great!
bnoordhuis commentedon Aug 30, 2016
I already provided one:
refack commentedon Apr 25, 2017
In #12607 we are considering exposing the raw numbers in addition to the
Datevaluesfs: expose Stats times as Numbers