-
Notifications
You must be signed in to change notification settings - Fork 161
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
refactoring of the fs module. #279
Comments
|
TODO: (in no particular order)
|
Thanks, committed with some improvements: cd10a4b. |
@xeioex please take a look. |
Looks promising. Have no issues with the design. |
I've updated the patch above. |
@drsm I am on large (Array objects) refactoring now. I plan to merge the patch this or next week. |
|
JFF var fs = require('fs'), fsp = fs.promises;
var current;
Promise.resolve('100k fs.access(/dev/null)')
.then((name) => {
current = name;
console.log('start', current);
console.time(current);
})
.then(() => {
console.time(current + ' sync');
for (var i = 0; i < 100000; ++i) {
fs.accessSync('/dev/null');
}
console.timeEnd(current + ' sync');
})
.then(() => {
console.time(current + ' promise');
var n = 100000;
var f = () => {
if (n--) {
return fsp.access('/dev/null').then(() => f());
}
console.timeEnd(current + ' promise');
return Promise.resolve();
};
return f();
})
/*.then(() => {
var f = async () => {
console.time(current + ' async');
for (var i = 0; i < 100000; ++i) {
await fsp.access('/dev/null');
}
console.timeEnd(current + ' async');
};
return f();
})*/
.then(() => {
return new Promise((resolve, reject) => {
console.time(current + ' callback');
var n = 100000;
var f = (err) => {
if (err) {
reject(err);
return;
}
if (n--) {
fs.access('/dev/null', f);
return;
}
console.timeEnd(current + ' callback');
resolve();
};
f();
})
})
.then(() => {
console.timeEnd(current);
console.log('stop', current);
current = void 0;
})
.catch((e) => {
console.log(current, 'failed', e)
}); $ node fs_bench.js
start 100k fs.access(/dev/null)
100k fs.access(/dev/null) sync: 131.249ms
100k fs.access(/dev/null) promise: 1226.996ms
100k fs.access(/dev/null) callback: 965.285ms
100k fs.access(/dev/null): 2326.356ms
stop 100k fs.access(/dev/null)
$ build/njs fs_bench.js
start 100k fs.access(/dev/null)
100k fs.access(/dev/null) sync: 123.637338ms
100k fs.access(/dev/null) promise: 426.900264ms
100k fs.access(/dev/null) callback: 151.360074ms
100k fs.access(/dev/null): 781.825911ms
stop 100k fs.access(/dev/null) |
Thanks, committed (096f5aa, d71a881) with some refactoring included. |
|
Thanks, committed with the following patch over . |
please take a look: some code was taken from here |
Added fs.mkdir(), fs.rmdir() and friends. https://gist.github.com/drsm/4785ae96a8b1ccee27a56c2919d6ba18 |
Thanks Artem. Will take a look at the end of the week. |
It seems to me that the concept is very straightforward to put any copyrights here. |
BTW, why not support recursive mode also? |
Committed, thanks. Also added missing parts for |
I'll to do it. |
Please take a look: Improved fs.mkdir() to support recursive directory creation. |
Thanks, committed with some changes. Most notably avoiding any changes to |
Improved fs.rmdir() to support recursive directory removal. The upstream solution is still buggy |
Take a look, https://gist.github.com/xeioex/cf5d4d451642510777552614ca1396af Coverity (static analyser) found the following issue with the previous mkdir patch. |
Yes, there is a race condition. The fix looks fine to me. |
BTW, we may lose an original |
https://gist.github.com/144da2743e6c6230bcb6cddb22ea951d I had to implement |
@xeioex |
Agree, take a look it also eliminates dynamic allocation for path arguments. |
Hi @drsm, You may help by testing the following patch
to test njs test/test262 test/fs/methods.t.js
TOTAL: PASSED [1/1] to compare with node test/test262 --binary=node test/fs/methods.t.js
TOTAL: PASSED [1/1] |
1e9f7f5
The text was updated successfully, but these errors were encountered: